mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
feat: ✨ Added the ability to provide your own custom plex url
This commit is contained in:
parent
d24c390fe4
commit
6c6b7bb498
7 changed files with 95 additions and 3 deletions
|
@ -3,6 +3,8 @@ using System.Threading.Tasks;
|
|||
using Microsoft.Extensions.Logging;
|
||||
using Ombi.Core.Models.Search;
|
||||
using Ombi.Core.Rule.Interfaces;
|
||||
using Ombi.Core.Settings;
|
||||
using Ombi.Core.Settings.Models.External;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Store.Entities;
|
||||
using Ombi.Store.Repository;
|
||||
|
@ -11,10 +13,13 @@ namespace Ombi.Core.Rule.Rules.Search
|
|||
{
|
||||
public class PlexAvailabilityRule : BaseSearchRule, IRules<SearchViewModel>
|
||||
{
|
||||
public PlexAvailabilityRule(IPlexContentRepository repo, ILogger<PlexAvailabilityRule> log)
|
||||
private readonly ISettingsService<PlexSettings> _plexSettings;
|
||||
|
||||
public PlexAvailabilityRule(IPlexContentRepository repo, ILogger<PlexAvailabilityRule> log, ISettingsService<PlexSettings> plexSettings)
|
||||
{
|
||||
PlexContentRepository = repo;
|
||||
Log = log;
|
||||
_plexSettings = plexSettings;
|
||||
}
|
||||
|
||||
private IPlexContentRepository PlexContentRepository { get; }
|
||||
|
@ -72,13 +77,20 @@ namespace Ombi.Core.Rule.Rules.Search
|
|||
|
||||
if (item != null)
|
||||
{
|
||||
var settings = await _plexSettings.GetSettingsAsync();
|
||||
var firstServer = settings.Servers.FirstOrDefault();
|
||||
var host = string.Empty;
|
||||
if (firstServer != null)
|
||||
{
|
||||
host = firstServer.ServerHostname;
|
||||
}
|
||||
if (useId)
|
||||
{
|
||||
obj.TheMovieDbId = obj.Id.ToString();
|
||||
useTheMovieDb = true;
|
||||
}
|
||||
obj.Available = true;
|
||||
obj.PlexUrl = item.Url;
|
||||
obj.PlexUrl = PlexHelper.BuildPlexMediaUrl(item.Url, host);
|
||||
obj.Quality = item.Quality;
|
||||
|
||||
if (obj.Type == RequestType.TvShow)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue