mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Readding the image redownloader & adding a sub extract button
This commit is contained in:
parent
0594104153
commit
79b0e57b82
@ -46,7 +46,8 @@
|
||||
|
||||
<mat-menu #showMenu="matMenu">
|
||||
<button mat-menu-item (click)="editMetadata()">Edit metadata</button>
|
||||
<button mat-menu-item (click)="redownloadImages()">Redownload images</button>
|
||||
<button mat-menu-item (click)="redownloadImages()">Re-download images</button>
|
||||
<button mat-menu-item (click)="extractSubs()">Re-extract subtitles</button>
|
||||
</mat-menu>
|
||||
|
||||
<div class="row pt-3 d-md-none">
|
||||
|
@ -1,27 +1,28 @@
|
||||
import { AfterViewInit, Component } from "@angular/core";
|
||||
import { AfterViewInit, Component, OnDestroy } from "@angular/core";
|
||||
import { MatSnackBar } from "@angular/material/snack-bar";
|
||||
import { DomSanitizer, Title } from "@angular/platform-browser";
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import { DomSanitizer, SafeStyle, Title } from "@angular/platform-browser";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { Episode } from "../../models/resources/episode";
|
||||
import { Show } from "../../models/resources/show";
|
||||
import {MatDialog} from "@angular/material/dialog";
|
||||
import {TrailerDialogComponent} from "../trailer-dialog/trailer-dialog.component";
|
||||
import {MetadataEditComponent} from "../metadata-edit/metadata-edit.component";
|
||||
import {Season} from "../../models/resources/season";
|
||||
import {EpisodeService, PeopleService, SeasonService} from "../../services/api.service";
|
||||
import {Page} from "../../models/page";
|
||||
import {People} from "../../models/resources/people";
|
||||
import { MatDialog } from "@angular/material/dialog";
|
||||
import { TrailerDialogComponent } from "../trailer-dialog/trailer-dialog.component";
|
||||
import { MetadataEditComponent } from "../metadata-edit/metadata-edit.component";
|
||||
import { Season } from "../../models/resources/season";
|
||||
import { EpisodeService, PeopleService, SeasonService } from "../../services/api.service";
|
||||
import { Page } from "../../models/page";
|
||||
import { People } from "../../models/resources/people";
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
|
||||
@Component({
|
||||
selector: 'app-show-details',
|
||||
templateUrl: './show-details.component.html',
|
||||
styleUrls: ['./show-details.component.scss']
|
||||
selector: "app-show-details",
|
||||
templateUrl: "./show-details.component.html",
|
||||
styleUrls: ["./show-details.component.scss"]
|
||||
})
|
||||
export class ShowDetailsComponent implements AfterViewInit
|
||||
export class ShowDetailsComponent implements AfterViewInit, OnDestroy
|
||||
{
|
||||
show: Show;
|
||||
seasons: Season[];
|
||||
season: number = 1;
|
||||
season = 1;
|
||||
episodes: Page<Episode>[] = [];
|
||||
people: Page<People>;
|
||||
|
||||
@ -35,13 +36,14 @@ export class ShowDetailsComponent implements AfterViewInit
|
||||
private title: Title,
|
||||
private router: Router,
|
||||
private dialog: MatDialog,
|
||||
private http: HttpClient,
|
||||
private seasonService: SeasonService,
|
||||
private episodeService: EpisodeService,
|
||||
private peopleService: PeopleService)
|
||||
{
|
||||
this.route.queryParams.subscribe(params =>
|
||||
{
|
||||
this.season = params["season"] ?? 1;
|
||||
this.season = params.season ?? 1;
|
||||
});
|
||||
|
||||
this.route.data.subscribe(data =>
|
||||
@ -51,22 +53,23 @@ export class ShowDetailsComponent implements AfterViewInit
|
||||
|
||||
this.peopleService.getFromShow(this.show.slug).subscribe(x => this.people = x);
|
||||
|
||||
if (this.show.isMovie)
|
||||
if (this.show.isMovie) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.seasonService.getForShow(this.show.slug, {limit: 0}).subscribe(x =>
|
||||
{
|
||||
this.seasons = x.items;
|
||||
if (x.items.find(x => x.seasonNumber == this.season) == null)
|
||||
if (x.items.find(y => y.seasonNumber === this.season) == null)
|
||||
{
|
||||
this.season = 1;
|
||||
this.getEpisodes(1);
|
||||
}
|
||||
});
|
||||
this.getEpisodes(this.season);});
|
||||
this.getEpisodes(this.season); });
|
||||
}
|
||||
|
||||
ngAfterViewInit()
|
||||
ngAfterViewInit(): void
|
||||
{
|
||||
this.scrollZone = document.getElementById("main");
|
||||
this.toolbar = document.getElementById("toolbar");
|
||||
@ -77,7 +80,7 @@ export class ShowDetailsComponent implements AfterViewInit
|
||||
this.scrollZone.addEventListener("scroll", () => this.scroll());
|
||||
}
|
||||
|
||||
ngOnDestroy()
|
||||
ngOnDestroy(): void
|
||||
{
|
||||
this.title.setTitle("Kyoo");
|
||||
this.toolbar.setAttribute("style", `background-color: #000000 !important`);
|
||||
@ -86,31 +89,30 @@ export class ShowDetailsComponent implements AfterViewInit
|
||||
this.scrollZone.removeEventListener("scroll", () => this.scroll());
|
||||
}
|
||||
|
||||
scroll()
|
||||
scroll(): void
|
||||
{
|
||||
let opacity: number = 2 * this.scrollZone.scrollTop / this.backdrop.clientHeight;
|
||||
const opacity: number = 2 * this.scrollZone.scrollTop / this.backdrop.clientHeight;
|
||||
this.toolbar.setAttribute("style", `background-color: rgba(0, 0, 0, ${opacity}) !important`);
|
||||
};
|
||||
}
|
||||
|
||||
getThumb(slug: string)
|
||||
getThumb(slug: string): SafeStyle
|
||||
{
|
||||
return this.sanitizer.bypassSecurityTrustStyle("url(/poster/" + slug + ")");
|
||||
}
|
||||
|
||||
playClicked()
|
||||
playClicked(): void
|
||||
{
|
||||
if (this.show.isMovie)
|
||||
if (this.show.isMovie) {
|
||||
this.router.navigate(["/watch/" + this.show.slug]);
|
||||
else
|
||||
}
|
||||
else {
|
||||
this.router.navigate(["/watch/" + this.show.slug + "-s1e1"]);
|
||||
}
|
||||
}
|
||||
|
||||
getEpisodes(season: number)
|
||||
getEpisodes(season: number): void
|
||||
{
|
||||
if (season < 0)
|
||||
return;
|
||||
|
||||
if (this.episodes[season] != undefined)
|
||||
if (season < 0 || this.episodes[season])
|
||||
return;
|
||||
|
||||
this.episodeService.getFromSeasonNumber(this.show.slug, this.season).subscribe(x =>
|
||||
@ -119,26 +121,44 @@ export class ShowDetailsComponent implements AfterViewInit
|
||||
});
|
||||
}
|
||||
|
||||
openTrailer()
|
||||
openTrailer(): void
|
||||
{
|
||||
this.dialog.open(TrailerDialogComponent, {width: "80%", height: "45vw", data: this.show.trailerUrl, panelClass: "panel"});
|
||||
}
|
||||
|
||||
editMetadata()
|
||||
|
||||
editMetadata(): void
|
||||
{
|
||||
this.dialog.open(MetadataEditComponent, {width: "80%", data: this.show}).afterClosed().subscribe((result: Show) =>
|
||||
{
|
||||
if (result)
|
||||
if (result) {
|
||||
this.show = result;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
redownloadImages()
|
||||
redownloadImages(): void
|
||||
{
|
||||
// this.http.post("api/show/download-images/" + this.show.slug, undefined).subscribe(() => { }, error =>
|
||||
// {
|
||||
// console.log(error.status + " - " + error.message);
|
||||
// this.snackBar.open("An unknown error occured while re-downloading images.", null, { horizontalPosition: "left", panelClass: ['snackError'], duration: 2500 });
|
||||
// });
|
||||
this.http.put(`api/task/extract/show/${this.show.slug}/thumbnails`, undefined).subscribe(() => { }, error =>
|
||||
{
|
||||
console.log(error.status + " - " + error.message);
|
||||
this.snackBar.open("An unknown error occurred while re-downloading images.", null, {
|
||||
horizontalPosition: "left",
|
||||
panelClass: ["snackError"],
|
||||
duration: 2500
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
extractSubs(): void
|
||||
{
|
||||
this.http.put(`api/task/extract/show/${this.show.slug}/subs`, undefined).subscribe(() => { }, error =>
|
||||
{
|
||||
console.log(error.status + " - " + error.message);
|
||||
this.snackBar.open("An unknown error occurred while re-downloading images.", null, {
|
||||
horizontalPosition: "left",
|
||||
panelClass: ["snackError"],
|
||||
duration: 2500
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -12,17 +12,11 @@
|
||||
},
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": true,
|
||||
"curly": true,
|
||||
"deprecation": {
|
||||
"severity": "warning"
|
||||
},
|
||||
"eofline": true,
|
||||
"import-spacing": true,
|
||||
"indent": {
|
||||
"options": [
|
||||
"tabs"
|
||||
]
|
||||
},
|
||||
"max-classes-per-file": false,
|
||||
"max-line-length": [
|
||||
true,
|
||||
|
Loading…
x
Reference in New Issue
Block a user