This commit is contained in:
tidusjar 2020-03-31 15:56:37 +01:00
parent 10430cfb40
commit b09d4e41f9
2 changed files with 9 additions and 8 deletions

View file

@ -25,9 +25,10 @@ namespace Ombi.Helpers.Tests
get get
{ {
var mediaId = 1; var mediaId = 1;
yield return new TestCaseData(mediaId.ToString(), "http://google.com").Returns($"http://google.com/#!/item/item.html?id={mediaId}").SetName("EmbyHelper_GetMediaUrl_WithCustomDomain_WithoutTrailingSlash"); yield return new TestCaseData(mediaId.ToString(), "http://google.com").Returns($"http://google.com/#!/item?id={mediaId}").SetName("EmbyHelper_GetMediaUrl_WithCustomDomain_WithoutTrailingSlash");
yield return new TestCaseData(mediaId.ToString(), "http://google.com/").Returns($"http://google.com/#!/item/item.html?id={mediaId}").SetName("EmbyHelper_GetMediaUrl_WithCustomDomain"); yield return new TestCaseData(mediaId.ToString(), "http://google.com/").Returns($"http://google.com/#!/item?id={mediaId}").SetName("EmbyHelper_GetMediaUrl_WithCustomDomain");
yield return new TestCaseData(mediaId.ToString(), "https://google.com/").Returns($"https://google.com/#!/item/item.html?id={mediaId}").SetName("EmbyHelper_GetMediaUrl_WithCustomDomain_Https"); yield return new TestCaseData(mediaId.ToString(), "https://google.com/").Returns($"https://google.com/#!/item?id={mediaId}").SetName("EmbyHelper_GetMediaUrl_WithCustomDomain_Https");
yield return new TestCaseData(mediaId.ToString(), string.Empty).Returns($"https://app.emby.media/#!/item?id={mediaId}").SetName("EmbyHelper_GetMediaUrl_WithOutCustomDomain");
} }
} }

View file

@ -4,22 +4,22 @@
{ {
public static string GetEmbyMediaUrl(string mediaId, string customerServerUrl = null, bool isJellyfin = false) public static string GetEmbyMediaUrl(string mediaId, string customerServerUrl = null, bool isJellyfin = false)
{ {
string path = "item/item"; string path = "item";
if (isJellyfin) if (isJellyfin)
{ {
path = "itemdetails"; path = "itemdetails.html";
} }
if (customerServerUrl.HasValue()) if (customerServerUrl.HasValue())
{ {
if (!customerServerUrl.EndsWith("/")) if (!customerServerUrl.EndsWith("/"))
{ {
return $"{customerServerUrl}/#!/{path}.html?id={mediaId}"; return $"{customerServerUrl}/#!/{path}?id={mediaId}";
} }
return $"{customerServerUrl}#!/{path}.html?id={mediaId}"; return $"{customerServerUrl}#!/{path}?id={mediaId}";
} }
else else
{ {
return $"https://app.emby.media/#!/{path}.html?id={mediaId}"; return $"https://app.emby.media/#!/{path}?id={mediaId}";
} }
} }
} }