Major rework of media handelling, and collections

This commit is contained in:
X4Lo committed 2024-09-13 21:27:01 +01:00
1 parent b42e055691
commit f7cb2bed53
37 files changed
+1120 -411

No files matched your search

@@ -22,6 +22,7 @@ import { EntrySeen } from '../../../shared/models/entrySeen.model';
import { EpisodeSeenModalComponent } from '../../../shared/components/modals/episode-seen-modal/episode-seen-modal.component';
import { MediaModalComponent } from '../media-modal/media-modal.component';
import { environment } from '../../../../environments/environment.prod';
import { UserCollection } from '../../../shared/models/userCollection.model';
@Component({
selector: 'app-entry-page',
@@ -76,6 +77,14 @@ export class EntryPageComponent implements OnInit {
this.entry = data['entry'] as Entry;
this.entry.isInLibrary = true;
this.entry.collections = this.entry.collections.map((c) => {
c.mediasCount = c.medias.length;
c.selectedBackdrop = this.getCollectionBackdropPath(c);
c.medias = [];
return c;
});
if (this.entry.is_tvseries) {
// ? sorting seasons
this.entry.seasons = this.entry.seasons.sort((a, b) => {
@@ -316,6 +325,50 @@ export class EntryPageComponent implements OnInit {
}
}
getCollectionBackdropPath(collection: UserCollection) {
console.log(`collection media:`, collection.medias);
if (collection.medias && collection.medias.length != 0) {
const backdrops = collection.medias.filter((m) => m.type == 'backdrop');
if (backdrops.length != 0) {
const selectedBackdrops = backdrops.filter(
(m) => m.type == 'backdrop' && m.isSelected
);
console.log(selectedBackdrops);
let selectedBackdrop;
if (selectedBackdrops.length != 0) {
selectedBackdrop = selectedBackdrops[0].path;
} else {
selectedBackdrop = backdrops[0].path;
}
return (
environment.API_URL +
`/media/collections/backdrops/preview/${selectedBackdrop}`
);
}
}
// if (collection.entries && collection.entries.length != 0) {
// // * use the poster of the first entry in the collection
// // * if the collection is empty
// return this.getEntryBackdropPath(collection.entries[0]);
// } else
if (collection.backdropPath) {
// * use first remote tmdb poster
// * if collection has none and has no entry
return `https://image.tmdb.org/t/p/w1280/${collection.backdropPath}`;
} else {
// * use default poster
// * if collection has totaly no poster
return 'assets/images/default/default-backdrop.png';
}
}
getEntryBackdropPath(entry: Entry) {
return '';
}
refrechEntry() {
this.lockActions = true;
this.entryService.refrechEntryById(this.entry.id).subscribe({
@@ -417,7 +470,7 @@ export class EntryPageComponent implements OnInit {
addEpisodeSeen() {
if (!this.entry) return;
this.seenHistory[0]
this.seenHistory[0];
const dialogRef = this.dialog.open(EpisodeSeenModalComponent, {
width: '360px',