add media download service and started using it
This commit is contained in:
1 parent
78399912f7
commit
06be888123
12 files changed
+614
-80
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
<div class="movie-card" @fadeInOut>
|
||||
<div class="card-head">
|
||||
<img class="card-img" [src]="getPostPath()" alt="Movie Poster">
|
||||
<img class="card-img" [src]="posterPath" alt="Movie Poster">
|
||||
|
||||
<div class="card-overlay">
|
||||
<div class="rating">
|
||||
|
||||
+28
-8
@@ -1,6 +1,5 @@
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { LibraryService } from '../../../../core/services/library.service';
|
||||
import { Entry } from '../../../../shared/models/entry.model';
|
||||
import { trigger, transition, style, animate } from '@angular/animations';
|
||||
import { UserCollectionService } from '../../../../core/services/userCollection.service';
|
||||
@@ -27,14 +26,12 @@ export class UserCollectionGridCardComponent implements OnInit {
|
||||
@Output() refrechEvent = new EventEmitter();
|
||||
|
||||
constructor(
|
||||
private libraryService: LibraryService,
|
||||
private userCollectionService: UserCollectionService,
|
||||
public dialog: MatDialog,
|
||||
private router: Router
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
ngOnInit(): void {}
|
||||
|
||||
get releaseYear(): number {
|
||||
return new Date(this.entry.release_date).getFullYear();
|
||||
@@ -49,13 +46,36 @@ export class UserCollectionGridCardComponent implements OnInit {
|
||||
return `https://www.themoviedb.org/${type}/${this.entry.entryId.tmdb_id}`;
|
||||
}
|
||||
|
||||
getPostPath() {
|
||||
if (this.entry.poster_path == null) return 'https://pic.pnnet.dev/256x256';
|
||||
get posterPath() {
|
||||
// * Not in library, use TMDB poster
|
||||
if (!this.entry.isInLibrary)
|
||||
return `https://image.tmdb.org/t/p/w300` + this.entry.poster_path;
|
||||
|
||||
return `https://image.tmdb.org/t/p/w500` + this.entry.poster_path;
|
||||
// * Is in library: use a local poster
|
||||
if (this.entry.medias) {
|
||||
const selectedPosters = this.entry.medias.filter(
|
||||
(m) => m.type == 'poster' && m.is_selected
|
||||
);
|
||||
|
||||
if (
|
||||
selectedPosters.length &&
|
||||
selectedPosters[0] &&
|
||||
selectedPosters[0].path
|
||||
) {
|
||||
const name = selectedPosters[0].path.split('.')[0];
|
||||
const extention = selectedPosters[0].path.split('.')[1];
|
||||
return `http://localhost:4000/api/v1/media/entries/posters/${name}_preview.${extention}`;
|
||||
}
|
||||
}
|
||||
|
||||
// * No local poster available, Use TMDB poster
|
||||
if (this.entry.poster_path)
|
||||
return `https://image.tmdb.org/t/p/w300` + this.entry.poster_path;
|
||||
|
||||
// * No poster found, use default poster image as a last stand
|
||||
return 'assets/images/default/default-poster.png';
|
||||
}
|
||||
|
||||
|
||||
removeEntryFromList() {
|
||||
const dialogRef = this.dialog.open(ConfirmModalComponent, {
|
||||
width: '400px',
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
<div class="col-md-8 right-col">
|
||||
<!-- Movie Title -->
|
||||
<div class="d-flex justify-content-between align-items-center ">
|
||||
<h2 class="title">{{this.entry.title}}</h2>
|
||||
<h2 class="title" (click)="redirectToTmdb()">{{this.entry.title}}</h2>
|
||||
|
||||
<!-- Interraction buttons -->
|
||||
<div class="row entry-actions">
|
||||
|
||||
@@ -70,7 +70,7 @@ export class EntryPageComponent implements OnInit {
|
||||
this.route.data.subscribe(
|
||||
(data) => {
|
||||
this.entry = data['entry'] as Entry;
|
||||
// console.log(this.entry);
|
||||
this.entry.isInLibrary = true;
|
||||
|
||||
if (this.entry.is_tvseries) {
|
||||
// ? sorting seasons
|
||||
@@ -98,6 +98,7 @@ export class EntryPageComponent implements OnInit {
|
||||
{
|
||||
tapToDismiss: true,
|
||||
progressBar: true,
|
||||
positionClass: 'bottom-right',
|
||||
progressAnimation: 'increasing',
|
||||
}
|
||||
);
|
||||
@@ -205,6 +206,7 @@ export class EntryPageComponent implements OnInit {
|
||||
this.toastr.success('success', `Removed successfuly.`, {
|
||||
tapToDismiss: true,
|
||||
progressBar: true,
|
||||
positionClass: 'bottom-right',
|
||||
progressAnimation: 'increasing',
|
||||
});
|
||||
this.entry.entrySeen = this.entry.entrySeen.filter(
|
||||
@@ -279,7 +281,12 @@ export class EntryPageComponent implements OnInit {
|
||||
next: (entry) => {
|
||||
this.entry = entry;
|
||||
// console.log(`Entry refreched: `, entry);
|
||||
// TODO show updated notification
|
||||
this.toastr.success(`Movie refreshed successfuly.`, 'Success', {
|
||||
tapToDismiss: true,
|
||||
progressBar: true,
|
||||
positionClass: 'bottom-right',
|
||||
progressAnimation: 'increasing',
|
||||
});
|
||||
},
|
||||
error: (error) => {
|
||||
// TODO show error notification
|
||||
@@ -484,13 +491,45 @@ export class EntryPageComponent implements OnInit {
|
||||
this.showAll = !this.showAll;
|
||||
}
|
||||
|
||||
enlargePoster() {
|
||||
redirectToTmdb() {
|
||||
let type = this.entry.is_tvseries ? 'tv' : 'movie';
|
||||
window.open(
|
||||
'https://image.tmdb.org/t/p/original' + this.entry.poster_path,
|
||||
`https://www.themoviedb.org/${type}/${this.entry.entryId.tmdb_id}`,
|
||||
'_blank'
|
||||
);
|
||||
}
|
||||
|
||||
enlargePoster() {
|
||||
let poster;
|
||||
// * Not in library, use TMDB poster
|
||||
if (!this.entry.isInLibrary)
|
||||
poster = `https://image.tmdb.org/t/p/w300` + this.entry.poster_path;
|
||||
|
||||
// * Is in library: use a local poster
|
||||
if (!poster && this.entry.medias) {
|
||||
const selectedPosters = this.entry.medias.filter(
|
||||
(m) => m.type == 'poster' && m.is_selected
|
||||
);
|
||||
|
||||
if (
|
||||
selectedPosters.length &&
|
||||
selectedPosters[0] &&
|
||||
selectedPosters[0].path
|
||||
) {
|
||||
poster = `http://localhost:4000/api/v1/media/entries/posters/${selectedPosters[0].path}`;
|
||||
}
|
||||
}
|
||||
|
||||
// * No local poster available, Use TMDB poster
|
||||
if (!poster && this.entry.poster_path)
|
||||
poster = `https://image.tmdb.org/t/p/original` + this.entry.poster_path;
|
||||
|
||||
// * No poster found, use default poster image as a last stand
|
||||
if (!poster) poster = 'assets/images/default/default-poster.png';
|
||||
|
||||
window.open(poster, '_blank');
|
||||
}
|
||||
|
||||
// * getters
|
||||
get status() {
|
||||
return this.entry.status;
|
||||
@@ -505,17 +544,55 @@ export class EntryPageComponent implements OnInit {
|
||||
}
|
||||
|
||||
get poster(): string {
|
||||
if (this.entry.poster_path == null)
|
||||
return 'assets/images/default/default-poster.png';
|
||||
// * Not in library, use TMDB poster
|
||||
if (!this.entry.isInLibrary)
|
||||
return `https://image.tmdb.org/t/p/w300` + this.entry.poster_path;
|
||||
|
||||
return `https://image.tmdb.org/t/p/w500` + this.entry.poster_path;
|
||||
// * Is in library: use a local poster
|
||||
if (this.entry.medias) {
|
||||
const selectedPosters = this.entry.medias.filter(
|
||||
(m) => m.type == 'poster' && m.is_selected
|
||||
);
|
||||
|
||||
if (
|
||||
selectedPosters.length &&
|
||||
selectedPosters[0] &&
|
||||
selectedPosters[0].path
|
||||
) {
|
||||
return `http://localhost:4000/api/v1/media/entries/posters/${selectedPosters[0].path}`;
|
||||
}
|
||||
}
|
||||
|
||||
// * No local poster available, Use TMDB poster
|
||||
if (this.entry.poster_path)
|
||||
return `https://image.tmdb.org/t/p/w300` + this.entry.poster_path;
|
||||
|
||||
// * No poster found, use default poster image as a last stand
|
||||
return 'assets/images/default/default-poster.png';
|
||||
}
|
||||
|
||||
get banner(): string {
|
||||
if (this.entry.banner_path == null)
|
||||
return 'assets/images/default/default-poster.png';
|
||||
// * Is in library: use a local backdrop
|
||||
if (this.entry.medias) {
|
||||
const selectedBackdrop = this.entry.medias.filter(
|
||||
(m) => m.type == 'backdrop' && m.is_selected
|
||||
);
|
||||
|
||||
return `https://image.tmdb.org/t/p/w1280` + this.entry.banner_path;
|
||||
if (
|
||||
selectedBackdrop.length &&
|
||||
selectedBackdrop[0] &&
|
||||
selectedBackdrop[0].path
|
||||
) {
|
||||
return `http://localhost:4000/api/v1/media/entries/backdrops/${selectedBackdrop[0].path}`;
|
||||
}
|
||||
}
|
||||
|
||||
// * No local backdrop available, Use TMDB backdrop
|
||||
if (this.entry.banner_path)
|
||||
return `https://image.tmdb.org/t/p/w1280` + this.entry.banner_path;
|
||||
|
||||
// * No backdrop found, use default backdrop image as a last stand
|
||||
return 'assets/images/default/default-poster.png';
|
||||
}
|
||||
|
||||
get nextEpisode() {
|
||||
|
||||
Reference in new issue
Block a user