Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Knocking out LC requirements in issue #2124 #2125

Merged
merged 16 commits into from
Apr 16, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Ombi/ClientApp/app/requests/requests.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { TvRequestsComponent } from "./tvrequests.component";

import { SidebarModule, TreeTableModule } from "primeng/primeng";

import { IdentityService, RadarrService, RequestService, SonarrService } from "../services";
import { IdentityService, RadarrService, RequestService, SonarrService, SearchService } from "../services";

import { AuthGuard } from "../auth/auth.guard";

Expand Down Expand Up @@ -51,6 +51,7 @@ const routes: Routes = [
RequestService,
RadarrService,
SonarrService,
SearchService,
],

})
Expand Down
2 changes: 1 addition & 1 deletion src/Ombi/ClientApp/app/requests/tvrequests.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

<div class="col-sm-5 small-padding">
<div>
<a href="http://www.imdb.com/title/{{node.data.imdbId}}/" target="_blank">
<a href="{{node.data.imdbId}}" target="_blank">
<h4 class="request-title">{{node.data.title}} ({{node.data.releaseDate | date: 'yyyy'}})</h4>
</a>
</div>
Expand Down
23 changes: 19 additions & 4 deletions src/Ombi/ClientApp/app/requests/tvrequests.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import "rxjs/add/operator/distinctUntilChanged";
import "rxjs/add/operator/map";

import { AuthService } from "../auth/auth.service";
import { NotificationService, RequestService, SonarrService } from "../services";
import { NotificationService, RequestService, SonarrService, SearchService } from "../services";

import { TreeNode } from "primeng/primeng";
import { IIssueCategory, ISonarrProfile, ISonarrRootFolder, ITvRequests } from "../interfaces";
Expand Down Expand Up @@ -46,6 +46,7 @@ export class TvRequestsComponent implements OnInit {
constructor(private requestService: RequestService,
private auth: AuthService,
private sanitizer: DomSanitizer,
private searchService: SearchService,
private imageService: ImageService,
private sonarrService: SonarrService,
private notificationService: NotificationService) {
Expand Down Expand Up @@ -201,9 +202,7 @@ export class TvRequestsComponent implements OnInit {
.subscribe(x => {
this.tvRequests = x;
this.tvRequests.forEach((val, index) => {
if (val.data.posterPath === null) {
val.data.posterPath = "../../../images/default_tv_poster.png";
}
this.setDefaults(val);
this.loadBackdrop(val);
this.setOverride(val.data);
});
Expand All @@ -223,6 +222,22 @@ export class TvRequestsComponent implements OnInit {
this.loadInit();
}

private setDefaults(val: any) {
if (val.data.posterPath === null) {
val.data.posterPath = "../../../images/default_tv_poster.png";
}

if (val.data.imdbId.length === 0) {
this.searchService.getShowInformationTreeNode(val.data.tvDbId).subscribe(x => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't be using the SearchService to get the TvDbId and Imdbid.

There should be a new API if we need this information, or return it as part of the current API

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In search results the TreeNode data has seriesId attribute which can be used with the url: https://www.tvmaze.com/shows/{seriesId} in order to display titles with urls in the event that that tvmaze data does not contain an imdbId for the particular show.

However inside the requests page the TreeNode data does not have a seriesId attribute, so the only way I thought of to get this since we do have the tvDbId is to use the search service call to obtain this very reliably and this way tv show titles don't just link to a 404 imdb page.

What do you think is a better approach? I mean we can set the imdbId attribute accordingly during search so we don't have to do this and this would work for new requests but then I was just thinking of the existing requests...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well we do try and set the IMDb Id, but we can't always get it because it's not available sometimes. What I'd recommend is if we dont have it then we either create a new api and get it OR get it on the requests API that returns the requested items.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I will investigate this further. What I am leaning towards is using OMDb API since if we pass it the exact title we get from TvMaze it seems to return a reliable result which has the IMDb Id 😃

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine! We just need a new API assembly like all the other external API's.

Should be pretty simple to do.

if (x.data) {
val.data.imdbId = "https://www.tvmaze.com/shows/" + x.data.seriesId;
}
});
} else {
val.data.imdbId = "http://www.imdb.com/title/" + val.data.imdbId + "/";
}
}

private loadBackdrop(val: TreeNode): void {
this.imageService.getTvBanner(val.data.tvDbId).subscribe(x => {
val.data.background = this.sanitizer.bypassSecurityTrustStyle
Expand Down