Skip to content

Commit

Permalink
Merge pull request #4225 from Ombi-app/develop-kuraki
Browse files Browse the repository at this point in the history
Develop kuraki
  • Loading branch information
tidusjar authored Jun 12, 2021
2 parents be975d8 + 31427c3 commit 09ac840
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
19 changes: 14 additions & 5 deletions src/Ombi.Core/Rule/Rules/Search/PlexAvailabilityRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ public async Task<RuleResult> Execute(SearchViewModel obj)
var useTheMovieDb = false;
var useId = false;
var useTvDb = false;

PlexMediaTypeEntity type = ConvertType(obj.Type);

if (obj.ImdbId.HasValue())
{
item = await PlexContentRepository.Get(obj.ImdbId, ProviderType.ImdbId);
item = await PlexContentRepository.GetByType(obj.ImdbId, ProviderType.ImdbId, type);
if (item != null)
{
useImdb = true;
Expand All @@ -39,15 +42,15 @@ public async Task<RuleResult> Execute(SearchViewModel obj)
{
if (obj.Id > 0)
{
item = await PlexContentRepository.Get(obj.Id.ToString(), ProviderType.TheMovieDbId);
item = await PlexContentRepository.GetByType(obj.Id.ToString(), ProviderType.TheMovieDbId, type);
if (item != null)
{
useId = true;
}
}
if (obj.TheMovieDbId.HasValue())
{
item = await PlexContentRepository.Get(obj.TheMovieDbId, ProviderType.TheMovieDbId);
item = await PlexContentRepository.GetByType(obj.TheMovieDbId, ProviderType.TheMovieDbId, type);
if (item != null)
{
useTheMovieDb = true;
Expand All @@ -58,7 +61,7 @@ public async Task<RuleResult> Execute(SearchViewModel obj)
{
if (obj.TheTvDbId.HasValue())
{
item = await PlexContentRepository.Get(obj.TheTvDbId, ProviderType.TvDbId);
item = await PlexContentRepository.GetByType(obj.TheTvDbId, ProviderType.TvDbId, type);
if (item != null)
{
useTvDb = true;
Expand Down Expand Up @@ -100,6 +103,12 @@ public async Task<RuleResult> Execute(SearchViewModel obj)
return Success();
}


private PlexMediaTypeEntity ConvertType(RequestType type) =>
type switch
{
RequestType.Movie => PlexMediaTypeEntity.Movie,
RequestType.TvShow => PlexMediaTypeEntity.Show,
_ => PlexMediaTypeEntity.Movie,
};
}
}
2 changes: 1 addition & 1 deletion src/Ombi.Helpers/PlexHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static ProviderId GetProviderIdFromPlexGuid(string guid)
public static string GetPlexMediaUrl(string machineId, int mediaId)
{
var url =
$"https://app.plex.tv/web/app#!/server/{machineId}/details?key=library%2Fmetadata%2F{mediaId}";
$"https://app.plex.tv/web/app#!/server/{machineId}/details?key=%2flibrary%2Fmetadata%2F{mediaId}";
return url;
}

Expand Down
1 change: 1 addition & 0 deletions src/Ombi.Store/Repository/IPlexContentRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public interface IPlexContentRepository : IExternalRepository<PlexServerContent>
{
Task<bool> ContentExists(string providerId);
Task<PlexServerContent> Get(string providerId, ProviderType type);
Task<PlexServerContent> GetByType(string providerId, ProviderType type, PlexMediaTypeEntity plexType);
Task<PlexServerContent> GetByKey(int key);
Task Update(PlexServerContent existingContent);
IQueryable<PlexEpisode> GetAllEpisodes();
Expand Down
17 changes: 17 additions & 0 deletions src/Ombi.Store/Repository/PlexContentRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,23 @@ public async Task<PlexServerContent> Get(string providerId, ProviderType type)
return null;
}

public async Task<PlexServerContent> GetByType(string providerId, ProviderType type, PlexMediaTypeEntity plexType)
{
switch (type)
{
case ProviderType.ImdbId:
return await Db.PlexServerContent.FirstOrDefaultAsync(x => x.ImdbId == providerId && x.Type == plexType);
case ProviderType.TheMovieDbId:
return await Db.PlexServerContent.FirstOrDefaultAsync(x => x.TheMovieDbId == providerId && x.Type == plexType);
case ProviderType.TvDbId:
return await Db.PlexServerContent.FirstOrDefaultAsync(x => x.TvDbId == providerId && x.Type == plexType);
default:
break;
}

return null;
}

public async Task<PlexServerContent> GetByKey(int key)
{
return await Db.PlexServerContent.Include(x => x.Seasons).FirstOrDefaultAsync(x => x.Key == key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
{{'Search.ViewOnEmby' | translate}}
<i class="far fa-play-circle fa-2x"></i>
</a>
<a id="viewOnJellyfinButton" *ngIf="movie.jellyfinUrl" href="{{movie.jellyfinUrl}}" mat-raised-button target="_blank" class="btn-spacing viewon-btn jellyfinUrl">
<a id="viewOnJellyfinButton" *ngIf="movie.jellyfinUrl" href="{{movie.jellyfinUrl}}" mat-raised-button target="_blank" class="btn-spacing viewon-btn jellyfin">
{{'Search.ViewOnJellyfin' | translate}}
<i class="far fa-play-circle fa-2x"></i>
</a>
Expand Down

0 comments on commit 09ac840

Please sign in to comment.