< Summary - Jellyfin

Information
Class: MediaBrowser.Providers.Plugins.Tmdb.TmdbExternalUrlProvider
Assembly: MediaBrowser.Providers
File(s): /srv/git/jellyfin/MediaBrowser.Providers/Plugins/Tmdb/TmdbExternalUrlProvider.cs
Line coverage
100%
Covered lines: 1
Uncovered lines: 0
Coverable lines: 1
Total lines: 98
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Name()100%11100%

File(s)

/srv/git/jellyfin/MediaBrowser.Providers/Plugins/Tmdb/TmdbExternalUrlProvider.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using MediaBrowser.Controller.Entities;
 4using MediaBrowser.Controller.Entities.Movies;
 5using MediaBrowser.Controller.Entities.TV;
 6using MediaBrowser.Controller.Providers;
 7using MediaBrowser.Model.Entities;
 8using TMDbLib.Objects.TvShows;
 9
 10namespace MediaBrowser.Providers.Plugins.Tmdb;
 11
 12/// <summary>
 13/// External URLs for TMDb.
 14/// </summary>
 15public class TmdbExternalUrlProvider : IExternalUrlProvider
 16{
 17    /// <inheritdoc/>
 2118    public string Name => "TMDB";
 19
 20    /// <inheritdoc/>
 21    public IEnumerable<string> GetExternalUrls(BaseItem item)
 22    {
 23        switch (item)
 24        {
 25            case Series:
 26                if (item.TryGetProviderId(MetadataProvider.Tmdb, out var externalId))
 27                {
 28                    yield return TmdbUtils.BaseTmdbUrl + $"tv/{externalId}";
 29                }
 30
 31                break;
 32            case Season season:
 33                if (season.Series.TryGetProviderId(MetadataProvider.Tmdb, out var seriesExternalId))
 34                {
 35                    var orderString = season.Series.DisplayOrder;
 36                    var seasonNumber = season.IndexNumber;
 37                    if (string.IsNullOrEmpty(orderString) && seasonNumber is not null)
 38                    {
 39                        // Default order is airdate
 40                        yield return TmdbUtils.BaseTmdbUrl + $"tv/{seriesExternalId}/season/{seasonNumber}";
 41                    }
 42
 43                    if (Enum.TryParse<TvGroupType>(season.Series.DisplayOrder, out var order))
 44                    {
 45                        if (order.Equals(TvGroupType.OriginalAirDate) && seasonNumber is not null)
 46                        {
 47                            yield return TmdbUtils.BaseTmdbUrl + $"tv/{seriesExternalId}/season/{seasonNumber}";
 48                        }
 49                    }
 50                }
 51
 52                break;
 53            case Episode episode:
 54                if (episode.Series.TryGetProviderId(MetadataProvider.Imdb, out seriesExternalId))
 55                {
 56                    var orderString = episode.Series.DisplayOrder;
 57                    var seasonNumber = episode.Season?.IndexNumber;
 58                    var episodeNumber = episode.IndexNumber;
 59                    if (string.IsNullOrEmpty(orderString) && seasonNumber is not null && episodeNumber is not null)
 60                    {
 61                        // Default order is airdate
 62                        yield return TmdbUtils.BaseTmdbUrl + $"tv/{seriesExternalId}/season/{seasonNumber}/episode/{epis
 63                    }
 64
 65                    if (Enum.TryParse<TvGroupType>(orderString, out var order))
 66                    {
 67                        if (order.Equals(TvGroupType.OriginalAirDate) && seasonNumber is not null && episodeNumber is no
 68                        {
 69                            yield return TmdbUtils.BaseTmdbUrl + $"tv/{seriesExternalId}/season/{seasonNumber}/episode/{
 70                        }
 71                    }
 72                }
 73
 74                break;
 75            case Movie:
 76                if (item.TryGetProviderId(MetadataProvider.Tmdb, out externalId))
 77                {
 78                    yield return TmdbUtils.BaseTmdbUrl + $"movie/{externalId}";
 79                }
 80
 81                break;
 82            case Person:
 83                if (item.TryGetProviderId(MetadataProvider.Tmdb, out externalId))
 84                {
 85                    yield return TmdbUtils.BaseTmdbUrl + $"person/{externalId}";
 86                }
 87
 88                break;
 89            case BoxSet:
 90                if (item.TryGetProviderId(MetadataProvider.Tmdb, out externalId))
 91                {
 92                    yield return TmdbUtils.BaseTmdbUrl + $"collection/{externalId}";
 93                }
 94
 95                break;
 96        }
 97    }
 98}

Methods/Properties

get_Name()