feat: Added the ability to provide your own custom plex url

This commit is contained in:
tidusjar 2021-09-06 20:34:06 +01:00
parent d24c390fe4
commit 6c6b7bb498
7 changed files with 95 additions and 3 deletions

View file

@ -107,10 +107,40 @@ namespace Ombi.Helpers
public static string GetPlexMediaUrl(string machineId, int mediaId)
{
var url =
$"https://app.plex.tv/web/app#!/server/{machineId}/details?key=%2flibrary%2Fmetadata%2F{mediaId}";
$"web/app#!/server/{machineId}/details?key=%2flibrary%2Fmetadata%2F{mediaId}";
return url;
}
public static string BuildPlexMediaUrl(string savedUrl, string plexHost)
{
if (savedUrl.Contains("app.plex.tv"))
{
var split = savedUrl.Split("https://app.plex.tv/", StringSplitOptions.RemoveEmptyEntries);
if (split.Length == 1)
{
savedUrl = split[0];
}
else
{
throw new ArgumentException($"Attempt to parse url {savedUrl} and could not");
}
}
if (!plexHost.HasValue())
{
plexHost = "https://app.plex.tv/";
}
else
{
if (plexHost[plexHost.Length - 1] != '/')
{
plexHost += '/';
}
}
return $"{plexHost}{savedUrl}";
}
public static ProviderId GetProviderIdsFromMetadata(params string[] guids)
{
var providerIds = new ProviderId();