-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec984e9
commit d8baf85
Showing
8 changed files
with
127 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
Jellyfin.Plugin.Tvdb/Providers/ExternalId/TvdbSeriesSlugExternalId.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using MediaBrowser.Controller.Entities.TV; | ||
using MediaBrowser.Controller.Providers; | ||
using MediaBrowser.Model.Entities; | ||
using MediaBrowser.Model.Providers; | ||
|
||
namespace Jellyfin.Plugin.Tvdb.Providers.ExternalId | ||
{ | ||
/// <inheritdoc /> | ||
public class TvdbSeriesSlugExternalId : IExternalId | ||
{ | ||
/// <inheritdoc /> | ||
public string ProviderName => TvdbPlugin.ProviderName + " Slug"; | ||
|
||
/// <inheritdoc /> | ||
public string Key => TvdbPlugin.SlugProviderId; | ||
|
||
/// <inheritdoc /> | ||
public ExternalIdMediaType? Type => ExternalIdMediaType.Series; | ||
|
||
/// <inheritdoc /> | ||
public string? UrlFormatString => null; | ||
|
||
/// <inheritdoc /> | ||
public bool Supports(IHasProviderIds item) => item is Series; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
using System; | ||
using System.Collections.Frozen; | ||
using System.Collections.Generic; | ||
using MediaBrowser.Controller.Entities; | ||
using MediaBrowser.Controller.Entities.Movies; | ||
using MediaBrowser.Controller.Entities.TV; | ||
using MediaBrowser.Controller.Providers; | ||
using MediaBrowser.Model.Entities; | ||
|
||
namespace Jellyfin.Plugin.Tvdb.Providers | ||
{ | ||
/// <summary> | ||
/// Provides external urls for TheTVDB. | ||
/// </summary> | ||
public class TvdbExternalUrlProvider : IExternalUrlProvider | ||
{ | ||
private readonly FrozenSet<string> _supportedOrders = new[] { "official", "regional", "alternate", "altdvd", "dvd", "absolute" }.ToFrozenSet(); | ||
|
||
/// <inheritdoc/> | ||
public string Name => TvdbPlugin.ProviderName; | ||
|
||
/// <inheritdoc/> | ||
public IEnumerable<string> GetExternalUrls(BaseItem item) | ||
{ | ||
var externalId = item.GetProviderId(TvdbPlugin.ProviderId); | ||
var slugId = item.GetProviderId(TvdbPlugin.SlugProviderId); | ||
|
||
switch (item) | ||
{ | ||
case Series: | ||
if (string.IsNullOrEmpty(slugId) && !string.IsNullOrEmpty(externalId)) | ||
{ | ||
yield return TvdbUtils.TvdbBaseUrl + $"?tab=series&id={externalId}"; | ||
} | ||
else if (!string.IsNullOrEmpty(slugId)) | ||
{ | ||
yield return TvdbUtils.TvdbBaseUrl + $"series/{slugId}"; | ||
} | ||
|
||
break; | ||
case Season season: | ||
season.Series.ProviderIds.TryGetValue(TvdbPlugin.SlugProviderId, out var seriesSlugId); | ||
var displayOrder = season.Series.DisplayOrder; | ||
if (string.IsNullOrEmpty(displayOrder)) | ||
{ | ||
displayOrder = "official"; | ||
} | ||
|
||
if (_supportedOrders.Contains(displayOrder) && !string.IsNullOrEmpty(seriesSlugId)) | ||
{ | ||
yield return TvdbUtils.TvdbBaseUrl + $"series/{seriesSlugId}/seasons/{displayOrder}/{item.IndexNumber}"; | ||
} | ||
else if (string.Equals(displayOrder, "official", StringComparison.OrdinalIgnoreCase) && !string.IsNullOrEmpty(externalId)) | ||
{ | ||
// This url format only works for official order | ||
yield return TvdbUtils.TvdbBaseUrl + $"dereferrer/season/{externalId}"; | ||
} | ||
|
||
break; | ||
case Episode episode: | ||
episode.Series.ProviderIds.TryGetValue(TvdbPlugin.SlugProviderId, out seriesSlugId); | ||
if (!string.IsNullOrEmpty(seriesSlugId) && !string.IsNullOrEmpty(externalId)) | ||
{ | ||
yield return TvdbUtils.TvdbBaseUrl + $"series/{seriesSlugId}/episodes/{externalId}"; | ||
} | ||
else if (!string.IsNullOrEmpty(externalId)) | ||
{ | ||
yield return TvdbUtils.TvdbBaseUrl + $"?tab=episode&id={externalId}"; | ||
} | ||
|
||
break; | ||
case Movie: | ||
if (!string.IsNullOrEmpty(slugId)) | ||
{ | ||
yield return TvdbUtils.TvdbBaseUrl + $"movies/{slugId}"; | ||
} | ||
|
||
break; | ||
case Person: | ||
if (!string.IsNullOrEmpty(externalId)) | ||
{ | ||
yield return TvdbUtils.TvdbBaseUrl + $"people/{externalId}"; | ||
} | ||
|
||
break; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters