mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-24 23:15:23 -07:00
commit
0e6c38f231
2 changed files with 54 additions and 4 deletions
46
src/Ombi.Helpers.Tests/EmbyHelperTests.cs
Normal file
46
src/Ombi.Helpers.Tests/EmbyHelperTests.cs
Normal file
|
@ -0,0 +1,46 @@
|
|||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Ombi.Helpers.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class EmbyHelperTests
|
||||
{
|
||||
[TestCaseSource(nameof(UrlData))]
|
||||
public string TestUrl(string mediaId, string url)
|
||||
{
|
||||
return EmbyHelper.GetEmbyMediaUrl(mediaId, url);
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(JellyfinUrlData))]
|
||||
public string TestJellyfinUrl(string mediaId, string url)
|
||||
{
|
||||
return EmbyHelper.GetEmbyMediaUrl(mediaId, url, true);
|
||||
}
|
||||
|
||||
public static IEnumerable<TestCaseData> UrlData
|
||||
{
|
||||
get
|
||||
{
|
||||
var mediaId = 1;
|
||||
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?id={mediaId}").SetName("EmbyHelper_GetMediaUrl_WithCustomDomain");
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<TestCaseData> JellyfinUrlData
|
||||
{
|
||||
get
|
||||
{
|
||||
var mediaId = 1;
|
||||
yield return new TestCaseData(mediaId.ToString(), "http://google.com").Returns($"http://google.com/#!/itemdetails.html?id={mediaId}").SetName("EmbyHelperJellyfin_GetMediaUrl_WithCustomDomain_WithoutTrailingSlash");
|
||||
yield return new TestCaseData(mediaId.ToString(), "http://google.com/").Returns($"http://google.com/#!/itemdetails.html?id={mediaId}").SetName("EmbyHelperJellyfin_GetMediaUrl_WithCustomDomain");
|
||||
yield return new TestCaseData(mediaId.ToString(), "https://google.com/").Returns($"https://google.com/#!/itemdetails.html?id={mediaId}").SetName("EmbyHelperJellyfin_GetMediaUrl_WithCustomDomain_Https");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,18 +4,22 @@
|
|||
{
|
||||
public static string GetEmbyMediaUrl(string mediaId, string customerServerUrl = null, bool isJellyfin = false)
|
||||
{
|
||||
string path = "item/item";
|
||||
string path = "item";
|
||||
if (isJellyfin)
|
||||
{
|
||||
path = "itemdetails";
|
||||
path = "itemdetails.html";
|
||||
}
|
||||
if (customerServerUrl.HasValue())
|
||||
{
|
||||
return $"{customerServerUrl}#!/{path}.html?id={mediaId}";
|
||||
if (!customerServerUrl.EndsWith("/"))
|
||||
{
|
||||
return $"{customerServerUrl}/#!/{path}?id={mediaId}";
|
||||
}
|
||||
return $"{customerServerUrl}#!/{path}?id={mediaId}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"https://app.emby.media/#!/{path}.html?id={mediaId}";
|
||||
return $"https://app.emby.media/#!/{path}?id={mediaId}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue