Merge branch 'jellyfin:master' into master
This commit is contained in:
commit
e977aade77
|
@ -2590,9 +2590,9 @@ namespace Emby.Server.Implementations.Library
|
|||
{
|
||||
/*
|
||||
Anime series don't generally have a season in their file name, however,
|
||||
tvdb needs a season to correctly get the metadata.
|
||||
TVDb needs a season to correctly get the metadata.
|
||||
Hence, a null season needs to be filled with something. */
|
||||
// FIXME perhaps this would be better for tvdb parser to ask for season 1 if no season is specified
|
||||
// FIXME perhaps this would be better for TVDb parser to ask for season 1 if no season is specified
|
||||
episode.ParentIndexNumber = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -376,7 +376,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
|
|||
|
||||
if (!justName.IsEmpty)
|
||||
{
|
||||
// check for tmdb id
|
||||
// Check for TMDb id
|
||||
var tmdbid = justName.GetAttributeValue("tmdbid");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(tmdbid))
|
||||
|
@ -387,7 +387,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
|
|||
|
||||
if (!string.IsNullOrEmpty(item.Path))
|
||||
{
|
||||
// check for imdb id - we use full media path, as we can assume, that this will match in any use case (either id in parent dir or in file name)
|
||||
// Check for IMDb id - we use full media path, as we can assume that this will match in any use case (whether id in parent dir or in file name)
|
||||
var imdbid = item.Path.AsSpan().GetAttributeValue("imdbid");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(imdbid))
|
||||
|
|
|
@ -2192,16 +2192,15 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||
|
||||
private void HandleDuplicateShowIds(List<TimerInfo> timers)
|
||||
{
|
||||
foreach (var timer in timers.Skip(1))
|
||||
// sort showings by HD channels first, then by startDate, record earliest showing possible
|
||||
foreach (var timer in timers.OrderByDescending(t => _liveTvManager.GetLiveTvChannel(t, this).IsHD).ThenBy(t => t.StartDate).Skip(1))
|
||||
{
|
||||
// TODO: Get smarter, prefer HD, etc
|
||||
|
||||
timer.Status = RecordingStatus.Cancelled;
|
||||
_timerProvider.Update(timer);
|
||||
}
|
||||
}
|
||||
|
||||
private void SearchForDuplicateShowIds(List<TimerInfo> timers)
|
||||
private void SearchForDuplicateShowIds(IEnumerable<TimerInfo> timers)
|
||||
{
|
||||
var groups = timers.ToLookup(i => i.ShowId ?? string.Empty).ToList();
|
||||
|
||||
|
@ -2282,39 +2281,13 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||
|
||||
if (updateTimerSettings)
|
||||
{
|
||||
// Only update if not currently active - test both new timer and existing in case Id's are different
|
||||
// Id's could be different if the timer was created manually prior to series timer creation
|
||||
if (!_activeRecordings.TryGetValue(timer.Id, out _) && !_activeRecordings.TryGetValue(existingTimer.Id, out _))
|
||||
{
|
||||
UpdateExistingTimerWithNewMetadata(existingTimer, timer);
|
||||
|
||||
// Needed by ShouldCancelTimerForSeriesTimer
|
||||
timer.IsManual = existingTimer.IsManual;
|
||||
|
||||
if (ShouldCancelTimerForSeriesTimer(seriesTimer, timer))
|
||||
{
|
||||
existingTimer.Status = RecordingStatus.Cancelled;
|
||||
}
|
||||
else if (!existingTimer.IsManual)
|
||||
{
|
||||
existingTimer.Status = RecordingStatus.New;
|
||||
}
|
||||
|
||||
if (existingTimer.Status != RecordingStatus.Cancelled)
|
||||
{
|
||||
enabledTimersForSeries.Add(existingTimer);
|
||||
}
|
||||
|
||||
existingTimer.KeepUntil = seriesTimer.KeepUntil;
|
||||
existingTimer.IsPostPaddingRequired = seriesTimer.IsPostPaddingRequired;
|
||||
existingTimer.IsPrePaddingRequired = seriesTimer.IsPrePaddingRequired;
|
||||
existingTimer.PostPaddingSeconds = seriesTimer.PostPaddingSeconds;
|
||||
existingTimer.PrePaddingSeconds = seriesTimer.PrePaddingSeconds;
|
||||
existingTimer.Priority = seriesTimer.Priority;
|
||||
existingTimer.SeriesTimerId = seriesTimer.Id;
|
||||
|
||||
_timerProvider.Update(existingTimer);
|
||||
}
|
||||
existingTimer.KeepUntil = seriesTimer.KeepUntil;
|
||||
existingTimer.IsPostPaddingRequired = seriesTimer.IsPostPaddingRequired;
|
||||
existingTimer.IsPrePaddingRequired = seriesTimer.IsPrePaddingRequired;
|
||||
existingTimer.PostPaddingSeconds = seriesTimer.PostPaddingSeconds;
|
||||
existingTimer.PrePaddingSeconds = seriesTimer.PrePaddingSeconds;
|
||||
existingTimer.Priority = seriesTimer.Priority;
|
||||
existingTimer.SeriesTimerId = seriesTimer.Id;
|
||||
}
|
||||
|
||||
existingTimer.SeriesTimerId = seriesTimer.Id;
|
||||
|
|
|
@ -122,11 +122,28 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
|
|||
|
||||
if (_timers.TryAdd(item.Id, timer))
|
||||
{
|
||||
Logger.LogInformation(
|
||||
"Creating recording timer for {Id}, {Name}. Timer will fire in {Minutes} minutes",
|
||||
if (item.IsSeries)
|
||||
{
|
||||
Logger.LogInformation(
|
||||
"Creating recording timer for {Id}, {Name} {SeasonNumber}x{EpisodeNumber:D2} on channel {ChannelId}. Timer will fire in {Minutes} minutes at {StartDate}",
|
||||
item.Id,
|
||||
item.Name,
|
||||
dueTime.TotalMinutes.ToString(CultureInfo.InvariantCulture));
|
||||
item.SeasonNumber,
|
||||
item.EpisodeNumber,
|
||||
item.ChannelId,
|
||||
dueTime.TotalMinutes.ToString(CultureInfo.InvariantCulture),
|
||||
item.StartDate);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogInformation(
|
||||
"Creating recording timer for {Id}, {Name} on channel {ChannelId}. Timer will fire in {Minutes} minutes at {StartDate}",
|
||||
item.Id,
|
||||
item.Name,
|
||||
item.ChannelId,
|
||||
dueTime.TotalMinutes.ToString(CultureInfo.InvariantCulture),
|
||||
item.StartDate);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -123,5 +123,6 @@
|
|||
"TaskOptimizeDatabase": "Optimér database",
|
||||
"TaskKeyframeExtractorDescription": "Udtrækker billeder fra videofiler for at lave mere præcise HLS playlister. Denne opgave kan godt tage lang tid.",
|
||||
"TaskKeyframeExtractor": "Billedramme udtrækker",
|
||||
"External": "Ekstern"
|
||||
"External": "Ekstern",
|
||||
"HearingImpaired": "Hørehæmmet"
|
||||
}
|
||||
|
|
|
@ -5,18 +5,18 @@
|
|||
"HeaderAlbumArtists": "البم کے فنکار",
|
||||
"Movies": "فلمیں",
|
||||
"HeaderFavoriteEpisodes": "پسندیدہ اقساط",
|
||||
"Collections": "مجموعہ",
|
||||
"Collections": "مجموعے",
|
||||
"Folders": "فولڈرز",
|
||||
"HeaderLiveTV": "براہ راست ٹی وی",
|
||||
"Channels": "چینلز",
|
||||
"HeaderContinueWatching": "دیکھنا جاری رکھیں",
|
||||
"Playlists": "پلے لسٹس",
|
||||
"ValueSpecialEpisodeName": "خاص - {0}",
|
||||
"Shows": "شوز",
|
||||
"ValueSpecialEpisodeName": "خصوصی - {0}",
|
||||
"Shows": "دکھاتا ہے۔",
|
||||
"Genres": "انواع",
|
||||
"Artists": "فنکار",
|
||||
"Sync": "مطابقت",
|
||||
"Photos": "تصوریں",
|
||||
"Sync": "مطابقت پذیری",
|
||||
"Photos": "تصاویر",
|
||||
"Albums": "البمز",
|
||||
"Favorites": "پسندیدہ",
|
||||
"Songs": "گانے",
|
||||
|
|
|
@ -123,5 +123,6 @@
|
|||
"TaskCleanActivityLogDescription": "刪除早於設定時間的日誌記錄。",
|
||||
"TaskKeyframeExtractorDescription": "提取關鍵格以創建更準確的HLS播放列表。次指示可能用時很長。",
|
||||
"TaskKeyframeExtractor": "關鍵幀提取器",
|
||||
"External": "外部"
|
||||
"External": "外部",
|
||||
"HearingImpaired": "聽力障礙"
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
"MixedContent": "混合內容",
|
||||
"Movies": "電影",
|
||||
"Music": "音樂",
|
||||
"MusicVideos": "音樂錄影帶",
|
||||
"MusicVideos": "MV",
|
||||
"NameInstallFailed": "{0} 安裝失敗",
|
||||
"NameSeasonNumber": "第 {0} 季",
|
||||
"NameSeasonUnknown": "未知季數",
|
||||
|
@ -122,5 +122,6 @@
|
|||
"TaskOptimizeDatabase": "最佳化資料庫",
|
||||
"TaskKeyframeExtractorDescription": "將關鍵幀從影片檔案提取出來並建立更精準的HLS播放清單。這可能需要很長時間。",
|
||||
"TaskKeyframeExtractor": "關鍵幀提取器",
|
||||
"External": "外部"
|
||||
"External": "外部",
|
||||
"HearingImpaired": "聽力障礙"
|
||||
}
|
||||
|
|
|
@ -434,8 +434,8 @@ namespace Emby.Server.Implementations.Localization
|
|||
yield return new LocalizationOption("Українська", "uk");
|
||||
yield return new LocalizationOption("اُردُو", "ur_PK");
|
||||
yield return new LocalizationOption("Tiếng Việt", "vi");
|
||||
yield return new LocalizationOption("汉语 (简化字)", "zh-CN");
|
||||
yield return new LocalizationOption("漢語 (繁体字)", "zh-TW");
|
||||
yield return new LocalizationOption("汉语 (简体字)", "zh-CN");
|
||||
yield return new LocalizationOption("漢語 (繁體字)", "zh-TW");
|
||||
yield return new LocalizationOption("廣東話 (香港)", "zh-HK");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -715,6 +715,7 @@ namespace Emby.Server.Implementations.Plugins
|
|||
{
|
||||
// This value is memory only - so that the web will show restart required.
|
||||
plugin.Manifest.Status = PluginStatus.Restart;
|
||||
plugin.Manifest.AutoUpdate = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -729,6 +730,7 @@ namespace Emby.Server.Implementations.Plugins
|
|||
|
||||
// This value is memory only - so that the web will show restart required.
|
||||
plugin.Manifest.Status = PluginStatus.Restart;
|
||||
plugin.Manifest.AutoUpdate = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,9 +87,9 @@ namespace Jellyfin.Api.Controllers
|
|||
/// <param name="minDateLastSavedForUser">Optional. The minimum last saved date for the current user. Format = ISO.</param>
|
||||
/// <param name="maxPremiereDate">Optional. The maximum premiere date. Format = ISO.</param>
|
||||
/// <param name="hasOverview">Optional filter by items that have an overview or not.</param>
|
||||
/// <param name="hasImdbId">Optional filter by items that have an imdb id or not.</param>
|
||||
/// <param name="hasTmdbId">Optional filter by items that have a tmdb id or not.</param>
|
||||
/// <param name="hasTvdbId">Optional filter by items that have a tvdb id or not.</param>
|
||||
/// <param name="hasImdbId">Optional filter by items that have an IMDb id or not.</param>
|
||||
/// <param name="hasTmdbId">Optional filter by items that have a TMDb id or not.</param>
|
||||
/// <param name="hasTvdbId">Optional filter by items that have a TVDb id or not.</param>
|
||||
/// <param name="isMovie">Optional filter for live tv movies.</param>
|
||||
/// <param name="isSeries">Optional filter for live tv series.</param>
|
||||
/// <param name="isNews">Optional filter for live tv news.</param>
|
||||
|
@ -100,7 +100,7 @@ namespace Jellyfin.Api.Controllers
|
|||
/// <param name="limit">Optional. The maximum number of records to return.</param>
|
||||
/// <param name="recursive">When searching within folders, this determines whether or not the search will be recursive. true/false.</param>
|
||||
/// <param name="searchTerm">Optional. Filter based on a search term.</param>
|
||||
/// <param name="sortOrder">Sort Order - Ascending,Descending.</param>
|
||||
/// <param name="sortOrder">Sort Order - Ascending, Descending.</param>
|
||||
/// <param name="parentId">Specify this to localize the search to a specific item or folder. Omit to use the root.</param>
|
||||
/// <param name="fields">Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimited. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines.</param>
|
||||
/// <param name="excludeItemTypes">Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimited.</param>
|
||||
|
@ -536,9 +536,9 @@ namespace Jellyfin.Api.Controllers
|
|||
/// <param name="minDateLastSavedForUser">Optional. The minimum last saved date for the current user. Format = ISO.</param>
|
||||
/// <param name="maxPremiereDate">Optional. The maximum premiere date. Format = ISO.</param>
|
||||
/// <param name="hasOverview">Optional filter by items that have an overview or not.</param>
|
||||
/// <param name="hasImdbId">Optional filter by items that have an imdb id or not.</param>
|
||||
/// <param name="hasTmdbId">Optional filter by items that have a tmdb id or not.</param>
|
||||
/// <param name="hasTvdbId">Optional filter by items that have a tvdb id or not.</param>
|
||||
/// <param name="hasImdbId">Optional filter by items that have an IMDb id or not.</param>
|
||||
/// <param name="hasTmdbId">Optional filter by items that have a TMDb id or not.</param>
|
||||
/// <param name="hasTvdbId">Optional filter by items that have a TVDb id or not.</param>
|
||||
/// <param name="isMovie">Optional filter for live tv movies.</param>
|
||||
/// <param name="isSeries">Optional filter for live tv series.</param>
|
||||
/// <param name="isNews">Optional filter for live tv news.</param>
|
||||
|
@ -549,7 +549,7 @@ namespace Jellyfin.Api.Controllers
|
|||
/// <param name="limit">Optional. The maximum number of records to return.</param>
|
||||
/// <param name="recursive">When searching within folders, this determines whether or not the search will be recursive. true/false.</param>
|
||||
/// <param name="searchTerm">Optional. Filter based on a search term.</param>
|
||||
/// <param name="sortOrder">Sort Order - Ascending,Descending.</param>
|
||||
/// <param name="sortOrder">Sort Order - Ascending, Descending.</param>
|
||||
/// <param name="parentId">Specify this to localize the search to a specific item or folder. Omit to use the root.</param>
|
||||
/// <param name="fields">Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimited. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines.</param>
|
||||
/// <param name="excludeItemTypes">Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimited.</param>
|
||||
|
|
|
@ -193,7 +193,7 @@ namespace Jellyfin.Api.Controllers
|
|||
new InternalItemsQuery(user)
|
||||
{
|
||||
Person = name,
|
||||
// Account for duplicates by imdb id, since the database doesn't support this yet
|
||||
// Account for duplicates by IMDb id, since the database doesn't support this yet
|
||||
Limit = itemLimit + 2,
|
||||
PersonTypes = new[] { PersonType.Director },
|
||||
IncludeItemTypes = itemTypes.ToArray(),
|
||||
|
@ -232,15 +232,15 @@ namespace Jellyfin.Api.Controllers
|
|||
foreach (var name in names)
|
||||
{
|
||||
var items = _libraryManager.GetItemList(new InternalItemsQuery(user)
|
||||
{
|
||||
Person = name,
|
||||
// Account for duplicates by imdb id, since the database doesn't support this yet
|
||||
Limit = itemLimit + 2,
|
||||
IncludeItemTypes = itemTypes.ToArray(),
|
||||
IsMovie = true,
|
||||
EnableGroupByMetadataKey = true,
|
||||
DtoOptions = dtoOptions
|
||||
}).GroupBy(i => i.GetProviderId(MediaBrowser.Model.Entities.MetadataProvider.Imdb) ?? Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture))
|
||||
{
|
||||
Person = name,
|
||||
// Account for duplicates by IMDb id, since the database doesn't support this yet
|
||||
Limit = itemLimit + 2,
|
||||
IncludeItemTypes = itemTypes.ToArray(),
|
||||
IsMovie = true,
|
||||
EnableGroupByMetadataKey = true,
|
||||
DtoOptions = dtoOptions
|
||||
}).GroupBy(i => i.GetProviderId(MediaBrowser.Model.Entities.MetadataProvider.Imdb) ?? Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture))
|
||||
.Select(x => x.First())
|
||||
.Take(itemLimit)
|
||||
.ToList();
|
||||
|
|
|
@ -55,9 +55,9 @@ namespace Jellyfin.Api.Controllers
|
|||
/// <param name="minDateLastSavedForUser">Optional. The minimum last saved date for the current user. Format = ISO.</param>
|
||||
/// <param name="maxPremiereDate">Optional. The maximum premiere date. Format = ISO.</param>
|
||||
/// <param name="hasOverview">Optional filter by items that have an overview or not.</param>
|
||||
/// <param name="hasImdbId">Optional filter by items that have an imdb id or not.</param>
|
||||
/// <param name="hasTmdbId">Optional filter by items that have a tmdb id or not.</param>
|
||||
/// <param name="hasTvdbId">Optional filter by items that have a tvdb id or not.</param>
|
||||
/// <param name="hasImdbId">Optional filter by items that have an IMDb id or not.</param>
|
||||
/// <param name="hasTmdbId">Optional filter by items that have a TMDb id or not.</param>
|
||||
/// <param name="hasTvdbId">Optional filter by items that have a TVDb id or not.</param>
|
||||
/// <param name="isMovie">Optional filter for live tv movies.</param>
|
||||
/// <param name="isSeries">Optional filter for live tv series.</param>
|
||||
/// <param name="isNews">Optional filter for live tv news.</param>
|
||||
|
@ -68,7 +68,7 @@ namespace Jellyfin.Api.Controllers
|
|||
/// <param name="limit">Optional. The maximum number of records to return.</param>
|
||||
/// <param name="recursive">When searching within folders, this determines whether or not the search will be recursive. true/false.</param>
|
||||
/// <param name="searchTerm">Optional. Filter based on a search term.</param>
|
||||
/// <param name="sortOrder">Sort Order - Ascending,Descending.</param>
|
||||
/// <param name="sortOrder">Sort Order - Ascending, Descending.</param>
|
||||
/// <param name="parentId">Specify this to localize the search to a specific item or folder. Omit to use the root.</param>
|
||||
/// <param name="fields">Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimited. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines.</param>
|
||||
/// <param name="excludeItemTypes">Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimited.</param>
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="EFCoreSecondLevelCacheInterceptor" Version="3.7.3" />
|
||||
<PackageReference Include="EFCoreSecondLevelCacheInterceptor" Version="3.7.5" />
|
||||
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.11" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.11" />
|
||||
|
|
|
@ -39,8 +39,8 @@
|
|||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="6.0.11" />
|
||||
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="6.0.11" />
|
||||
<PackageReference Include="prometheus-net" Version="6.0.0" />
|
||||
<PackageReference Include="prometheus-net.AspNetCore" Version="6.0.0" />
|
||||
<PackageReference Include="prometheus-net" Version="7.0.0" />
|
||||
<PackageReference Include="prometheus-net.AspNetCore" Version="7.0.0" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace MediaBrowser.Common.Providers
|
|||
/// <returns>True if parsing was successful, false otherwise.</returns>
|
||||
public static bool TryFindImdbId(ReadOnlySpan<char> text, out ReadOnlySpan<char> imdbId)
|
||||
{
|
||||
// imdb id is at least 9 chars (tt + 7 numbers)
|
||||
// IMDb id is at least 9 chars (tt + 7 numbers)
|
||||
while (text.Length >= 2 + ImdbMinNumbers)
|
||||
{
|
||||
var ttPos = text.IndexOf(ImdbPrefix);
|
||||
|
@ -42,7 +42,7 @@ namespace MediaBrowser.Common.Providers
|
|||
}
|
||||
}
|
||||
|
||||
// skip if more than 8 digits + 2 chars for tt
|
||||
// Skip if more than 8 digits + 2 chars for tt
|
||||
if (i <= ImdbMaxNumbers + 2 && i >= ImdbMinNumbers + 2)
|
||||
{
|
||||
imdbId = text.Slice(0, i);
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace MediaBrowser.Controller.BaseItemManager
|
|||
public SemaphoreSlim MetadataRefreshThrottler { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsMetadataFetcherEnabled(BaseItem baseItem, LibraryOptions libraryOptions, string name)
|
||||
public bool IsMetadataFetcherEnabled(BaseItem baseItem, TypeOptions? libraryTypeOptions, string name)
|
||||
{
|
||||
if (baseItem is Channel)
|
||||
{
|
||||
|
@ -49,10 +49,9 @@ namespace MediaBrowser.Controller.BaseItemManager
|
|||
return !baseItem.EnableMediaSourceDisplay;
|
||||
}
|
||||
|
||||
var typeOptions = libraryOptions.GetTypeOptions(baseItem.GetType().Name);
|
||||
if (typeOptions != null)
|
||||
if (libraryTypeOptions != null)
|
||||
{
|
||||
return typeOptions.MetadataFetchers.Contains(name.AsSpan(), StringComparison.OrdinalIgnoreCase);
|
||||
return libraryTypeOptions.MetadataFetchers.Contains(name.AsSpan(), StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
var itemConfig = _serverConfigurationManager.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, baseItem.GetType().Name, StringComparison.OrdinalIgnoreCase));
|
||||
|
@ -61,7 +60,7 @@ namespace MediaBrowser.Controller.BaseItemManager
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsImageFetcherEnabled(BaseItem baseItem, LibraryOptions libraryOptions, string name)
|
||||
public bool IsImageFetcherEnabled(BaseItem baseItem, TypeOptions? libraryTypeOptions, string name)
|
||||
{
|
||||
if (baseItem is Channel)
|
||||
{
|
||||
|
@ -75,10 +74,9 @@ namespace MediaBrowser.Controller.BaseItemManager
|
|||
return !baseItem.EnableMediaSourceDisplay;
|
||||
}
|
||||
|
||||
var typeOptions = libraryOptions.GetTypeOptions(baseItem.GetType().Name);
|
||||
if (typeOptions != null)
|
||||
if (libraryTypeOptions != null)
|
||||
{
|
||||
return typeOptions.ImageFetchers.Contains(name.AsSpan(), StringComparison.OrdinalIgnoreCase);
|
||||
return libraryTypeOptions.ImageFetchers.Contains(name.AsSpan(), StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
var itemConfig = _serverConfigurationManager.Configuration.MetadataOptions.FirstOrDefault(i => string.Equals(i.ItemType, baseItem.GetType().Name, StringComparison.OrdinalIgnoreCase));
|
||||
|
|
|
@ -18,18 +18,18 @@ namespace MediaBrowser.Controller.BaseItemManager
|
|||
/// Is metadata fetcher enabled.
|
||||
/// </summary>
|
||||
/// <param name="baseItem">The base item.</param>
|
||||
/// <param name="libraryOptions">The library options.</param>
|
||||
/// <param name="libraryTypeOptions">The type options for <c>baseItem</c> from the library (if defined).</param>
|
||||
/// <param name="name">The metadata fetcher name.</param>
|
||||
/// <returns><c>true</c> if metadata fetcher is enabled, else false.</returns>
|
||||
bool IsMetadataFetcherEnabled(BaseItem baseItem, LibraryOptions libraryOptions, string name);
|
||||
bool IsMetadataFetcherEnabled(BaseItem baseItem, TypeOptions? libraryTypeOptions, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Is image fetcher enabled.
|
||||
/// </summary>
|
||||
/// <param name="baseItem">The base item.</param>
|
||||
/// <param name="libraryOptions">The library options.</param>
|
||||
/// <param name="libraryTypeOptions">The type options for <c>baseItem</c> from the library (if defined).</param>
|
||||
/// <param name="name">The image fetcher name.</param>
|
||||
/// <returns><c>true</c> if image fetcher is enabled, else false.</returns>
|
||||
bool IsImageFetcherEnabled(BaseItem baseItem, LibraryOptions libraryOptions, string name);
|
||||
bool IsImageFetcherEnabled(BaseItem baseItem, TypeOptions? libraryTypeOptions, string name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,9 +33,9 @@ namespace MediaBrowser.Controller.Entities.Movies
|
|||
.ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the TMDB collection.
|
||||
/// Gets or sets the name of the TMDb collection.
|
||||
/// </summary>
|
||||
/// <value>The name of the TMDB collection.</value>
|
||||
/// <value>The name of the TMDb collection.</value>
|
||||
public string TmdbCollectionName { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
#pragma warning disable CS1591
|
||||
|
||||
namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface IHasOrder.
|
||||
/// </summary>
|
||||
public interface IHasOrder
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the order.
|
||||
/// </summary>
|
||||
/// <value>The order.</value>
|
||||
int Order { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,11 @@ namespace MediaBrowser.Controller.Providers
|
|||
/// <returns><c>true</c> if this instance can refresh the specified item.</returns>
|
||||
bool CanRefresh(BaseItem item);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether this instance primarily targets the specified type.
|
||||
/// </summary>
|
||||
/// <param name="type">The type.</param>
|
||||
/// <returns><c>true</c> if this instance primarily targets the specified type.</returns>
|
||||
bool CanRefreshPrimary(Type type);
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -131,6 +131,24 @@ namespace MediaBrowser.Controller.Providers
|
|||
/// <returns>IEnumerable{ImageProviderInfo}.</returns>
|
||||
IEnumerable<ImageProviderInfo> GetRemoteImageProviderInfo(BaseItem item);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the image providers for the provided item.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="refreshOptions">The image refresh options.</param>
|
||||
/// <returns>The image providers for the item.</returns>
|
||||
IEnumerable<IImageProvider> GetImageProviders(BaseItem item, ImageRefreshOptions refreshOptions);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the metadata providers for the provided item.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="libraryOptions">The library options.</param>
|
||||
/// <typeparam name="T">The type of metadata provider.</typeparam>
|
||||
/// <returns>The metadata providers.</returns>
|
||||
IEnumerable<IMetadataProvider<T>> GetMetadataProviders<T>(BaseItem item, LibraryOptions libraryOptions)
|
||||
where T : BaseItem;
|
||||
|
||||
/// <summary>
|
||||
/// Gets all metadata plugins.
|
||||
/// </summary>
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#pragma warning disable CS1591
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -8,20 +6,41 @@ using MediaBrowser.Model.Providers;
|
|||
|
||||
namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface IRemoteMetadataProvider.
|
||||
/// </summary>
|
||||
public interface IRemoteMetadataProvider : IMetadataProvider
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interface IRemoteMetadataProvider.
|
||||
/// </summary>
|
||||
public interface IRemoteMetadataProvider<TItemType, in TLookupInfoType> : IMetadataProvider<TItemType>, IRemoteMetadataProvider, IRemoteSearchProvider<TLookupInfoType>
|
||||
where TItemType : BaseItem, IHasLookupInfo<TLookupInfoType>
|
||||
where TLookupInfoType : ItemLookupInfo, new()
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the metadata for a specific LookupInfoType.
|
||||
/// </summary>
|
||||
/// <param name="info">The LookupInfoType to get metadata for.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/>.</param>
|
||||
/// <returns>A task returning a MetadataResult for the specific LookupInfoType.</returns>
|
||||
Task<MetadataResult<TItemType>> GetMetadata(TLookupInfoType info, CancellationToken cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interface IRemoteMetadataProvider.
|
||||
/// </summary>
|
||||
public interface IRemoteSearchProvider<in TLookupInfoType> : IRemoteSearchProvider
|
||||
where TLookupInfoType : ItemLookupInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the list of <see cref="RemoteSearchResult"/> for a specific LookupInfoType.
|
||||
/// </summary>
|
||||
/// <param name="searchInfo">The LookupInfoType to search for.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/>.</param>
|
||||
/// <returns>A task returning RemoteSearchResults for the searchInfo.</returns>
|
||||
Task<IEnumerable<RemoteSearchResult>> GetSearchResults(TLookupInfoType searchInfo, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#pragma warning disable CS1591
|
||||
|
||||
namespace MediaBrowser.Model.Entities
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -14,38 +12,78 @@ namespace MediaBrowser.Model.Entities
|
|||
Custom = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The imdb.
|
||||
/// The IMDb provider.
|
||||
/// </summary>
|
||||
Imdb = 2,
|
||||
|
||||
/// <summary>
|
||||
/// The TMDB.
|
||||
/// The TMDb provider.
|
||||
/// </summary>
|
||||
Tmdb = 3,
|
||||
|
||||
/// <summary>
|
||||
/// The TVDB.
|
||||
/// The TVDb provider.
|
||||
/// </summary>
|
||||
Tvdb = 4,
|
||||
|
||||
/// <summary>
|
||||
/// The tvcom.
|
||||
/// The tvcom providerd.
|
||||
/// </summary>
|
||||
Tvcom = 5,
|
||||
|
||||
/// <summary>
|
||||
/// Tmdb Collection Id.
|
||||
/// TMDb collection provider.
|
||||
/// </summary>
|
||||
TmdbCollection = 7,
|
||||
|
||||
/// <summary>
|
||||
/// The MusicBrainz album provider.
|
||||
/// </summary>
|
||||
MusicBrainzAlbum = 8,
|
||||
|
||||
/// <summary>
|
||||
/// The MusicBrainz album artist provider.
|
||||
/// </summary>
|
||||
MusicBrainzAlbumArtist = 9,
|
||||
|
||||
/// <summary>
|
||||
/// The MusicBrainz artist provider.
|
||||
/// </summary>
|
||||
MusicBrainzArtist = 10,
|
||||
|
||||
/// <summary>
|
||||
/// The MusicBrainz release group provider.
|
||||
/// </summary>
|
||||
MusicBrainzReleaseGroup = 11,
|
||||
|
||||
/// <summary>
|
||||
/// The Zap2It provider.
|
||||
/// </summary>
|
||||
Zap2It = 12,
|
||||
|
||||
/// <summary>
|
||||
/// The TvRage provider.
|
||||
/// </summary>
|
||||
TvRage = 15,
|
||||
|
||||
/// <summary>
|
||||
/// The AudioDb artist provider.
|
||||
/// </summary>
|
||||
AudioDbArtist = 16,
|
||||
|
||||
/// <summary>
|
||||
/// The AudioDb collection provider.
|
||||
/// </summary>
|
||||
AudioDbAlbum = 17,
|
||||
|
||||
/// <summary>
|
||||
/// The MusicBrainz track provider.
|
||||
/// </summary>
|
||||
MusicBrainzTrack = 18,
|
||||
|
||||
/// <summary>
|
||||
/// The TvMaze provider.
|
||||
/// </summary>
|
||||
TvMaze = 19
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ namespace MediaBrowser.Model.Querying
|
|||
ProductionLocations,
|
||||
|
||||
/// <summary>
|
||||
/// Imdb, tmdb, etc.
|
||||
/// The ids from IMDb, TMDb, etc.
|
||||
/// </summary>
|
||||
ProviderIds,
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
|
||||
var localImagesFailed = false;
|
||||
|
||||
var allImageProviders = ((ProviderManager)ProviderManager).GetImageProviders(item, refreshOptions).ToList();
|
||||
var allImageProviders = ProviderManager.GetImageProviders(item, refreshOptions).ToList();
|
||||
|
||||
if (refreshOptions.RemoveOldMetadata && refreshOptions.ReplaceAllImages)
|
||||
{
|
||||
|
@ -522,7 +522,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
protected IEnumerable<IMetadataProvider> GetProviders(BaseItem item, LibraryOptions libraryOptions, MetadataRefreshOptions options, bool isFirstRefresh, bool requiresRefresh)
|
||||
{
|
||||
// Get providers to refresh
|
||||
var providers = ((ProviderManager)ProviderManager).GetMetadataProviders<TItemType>(item, libraryOptions).ToList();
|
||||
var providers = ProviderManager.GetMetadataProviders<TItemType>(item, libraryOptions).ToList();
|
||||
|
||||
var metadataRefreshMode = options.MetadataRefreshMode;
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
|
@ -48,7 +46,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
/// </summary>
|
||||
public class ProviderManager : IProviderManager, IDisposable
|
||||
{
|
||||
private readonly object _refreshQueueLock = new object();
|
||||
private readonly object _refreshQueueLock = new();
|
||||
private readonly ILogger<ProviderManager> _logger;
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly ILibraryMonitor _libraryMonitor;
|
||||
|
@ -58,11 +56,11 @@ namespace MediaBrowser.Providers.Manager
|
|||
private readonly ISubtitleManager _subtitleManager;
|
||||
private readonly IServerConfigurationManager _configurationManager;
|
||||
private readonly IBaseItemManager _baseItemManager;
|
||||
private readonly ConcurrentDictionary<Guid, double> _activeRefreshes = new ConcurrentDictionary<Guid, double>();
|
||||
private readonly CancellationTokenSource _disposeCancellationTokenSource = new CancellationTokenSource();
|
||||
private readonly SimplePriorityQueue<Tuple<Guid, MetadataRefreshOptions>> _refreshQueue =
|
||||
new SimplePriorityQueue<Tuple<Guid, MetadataRefreshOptions>>();
|
||||
private readonly ConcurrentDictionary<Guid, double> _activeRefreshes = new();
|
||||
private readonly CancellationTokenSource _disposeCancellationTokenSource = new();
|
||||
private readonly SimplePriorityQueue<Tuple<Guid, MetadataRefreshOptions>> _refreshQueue = new();
|
||||
|
||||
private IImageProvider[] _imageProviders = Array.Empty<IImageProvider>();
|
||||
private IMetadataService[] _metadataServices = Array.Empty<IMetadataService>();
|
||||
private IMetadataProvider[] _metadataProviders = Array.Empty<IMetadataProvider>();
|
||||
private IMetadataSaver[] _savers = Array.Empty<IMetadataSaver>();
|
||||
|
@ -105,15 +103,13 @@ namespace MediaBrowser.Providers.Manager
|
|||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event EventHandler<GenericEventArgs<BaseItem>> RefreshStarted;
|
||||
public event EventHandler<GenericEventArgs<BaseItem>>? RefreshStarted;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event EventHandler<GenericEventArgs<BaseItem>> RefreshCompleted;
|
||||
public event EventHandler<GenericEventArgs<BaseItem>>? RefreshCompleted;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event EventHandler<GenericEventArgs<Tuple<BaseItem, double>>> RefreshProgress;
|
||||
|
||||
private IImageProvider[] ImageProviders { get; set; }
|
||||
public event EventHandler<GenericEventArgs<Tuple<BaseItem, double>>>? RefreshProgress;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void AddParts(
|
||||
|
@ -123,8 +119,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
IEnumerable<IMetadataSaver> metadataSavers,
|
||||
IEnumerable<IExternalId> externalIds)
|
||||
{
|
||||
ImageProviders = imageProviders.ToArray();
|
||||
|
||||
_imageProviders = imageProviders.ToArray();
|
||||
_metadataServices = metadataServices.OrderBy(i => i.Order).ToArray();
|
||||
_metadataProviders = metadataProviders.ToArray();
|
||||
_externalIds = externalIds.OrderBy(i => i.ProviderName).ToArray();
|
||||
|
@ -138,26 +133,15 @@ namespace MediaBrowser.Providers.Manager
|
|||
var type = item.GetType();
|
||||
|
||||
var service = _metadataServices.FirstOrDefault(current => current.CanRefreshPrimary(type));
|
||||
service ??= _metadataServices.FirstOrDefault(current => current.CanRefresh(item));
|
||||
|
||||
if (service == null)
|
||||
{
|
||||
foreach (var current in _metadataServices)
|
||||
{
|
||||
if (current.CanRefresh(item))
|
||||
{
|
||||
service = current;
|
||||
break;
|
||||
}
|
||||
}
|
||||
_logger.LogError("Unable to find a metadata service for item of type {TypeName}", item.GetType().Name);
|
||||
return Task.FromResult(ItemUpdateType.None);
|
||||
}
|
||||
|
||||
if (service != null)
|
||||
{
|
||||
return service.RefreshMetadata(item, options, cancellationToken);
|
||||
}
|
||||
|
||||
_logger.LogError("Unable to find a metadata service for item of type {TypeName}", item.GetType().Name);
|
||||
return Task.FromResult(ItemUpdateType.None);
|
||||
return service.RefreshMetadata(item, options, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
@ -181,9 +165,13 @@ namespace MediaBrowser.Providers.Manager
|
|||
{
|
||||
contentType = "image/png";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new HttpRequestException("Invalid image received: contentType not set.", null, response.StatusCode);
|
||||
}
|
||||
}
|
||||
|
||||
// thetvdb will sometimes serve a rubbish 404 html page with a 200 OK code, because reasons...
|
||||
// TVDb will sometimes serve a rubbish 404 html page with a 200 OK code, because reasons...
|
||||
if (contentType.Equals(MediaTypeNames.Text.Html, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
throw new HttpRequestException("Invalid image received.", null, HttpStatusCode.NotFound);
|
||||
|
@ -309,53 +297,69 @@ namespace MediaBrowser.Providers.Manager
|
|||
return GetRemoteImageProviders(item, true).Select(i => new ImageProviderInfo(i.Name, i.GetSupportedImages(item).ToArray()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the image providers for the provided item.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="refreshOptions">The image refresh options.</param>
|
||||
/// <returns>The image providers for the item.</returns>
|
||||
private IEnumerable<IRemoteImageProvider> GetRemoteImageProviders(BaseItem item, bool includeDisabled)
|
||||
{
|
||||
var options = GetMetadataOptions(item);
|
||||
var libraryOptions = _libraryManager.GetLibraryOptions(item);
|
||||
|
||||
return GetImageProvidersInternal(
|
||||
item,
|
||||
libraryOptions,
|
||||
options,
|
||||
new ImageRefreshOptions(new DirectoryService(_fileSystem)),
|
||||
includeDisabled).OfType<IRemoteImageProvider>();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<IImageProvider> GetImageProviders(BaseItem item, ImageRefreshOptions refreshOptions)
|
||||
{
|
||||
return GetImageProviders(item, _libraryManager.GetLibraryOptions(item), GetMetadataOptions(item), refreshOptions, false);
|
||||
return GetImageProvidersInternal(item, _libraryManager.GetLibraryOptions(item), GetMetadataOptions(item), refreshOptions, false);
|
||||
}
|
||||
|
||||
private IEnumerable<IImageProvider> GetImageProviders(BaseItem item, LibraryOptions libraryOptions, MetadataOptions options, ImageRefreshOptions refreshOptions, bool includeDisabled)
|
||||
private IEnumerable<IImageProvider> GetImageProvidersInternal(BaseItem item, LibraryOptions libraryOptions, MetadataOptions options, ImageRefreshOptions refreshOptions, bool includeDisabled)
|
||||
{
|
||||
// Avoid implicitly captured closure
|
||||
var currentOptions = options;
|
||||
|
||||
var typeOptions = libraryOptions.GetTypeOptions(item.GetType().Name);
|
||||
var typeFetcherOrder = typeOptions?.ImageFetcherOrder;
|
||||
var fetcherOrder = typeOptions?.ImageFetcherOrder ?? options.ImageFetcherOrder;
|
||||
|
||||
return ImageProviders.Where(i => CanRefresh(i, item, libraryOptions, refreshOptions, includeDisabled))
|
||||
.OrderBy(i =>
|
||||
{
|
||||
// See if there's a user-defined order
|
||||
if (i is not ILocalImageProvider)
|
||||
{
|
||||
var fetcherOrder = typeFetcherOrder ?? currentOptions.ImageFetcherOrder;
|
||||
var index = Array.IndexOf(fetcherOrder, i.Name);
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
// Not configured. Just return some high number to put it at the end.
|
||||
return 100;
|
||||
})
|
||||
.ThenBy(GetOrder);
|
||||
return _imageProviders.Where(i => CanRefreshImages(i, item, typeOptions, refreshOptions, includeDisabled))
|
||||
.OrderBy(i => GetConfiguredOrder(fetcherOrder, i.Name))
|
||||
.ThenBy(GetDefaultOrder);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the metadata providers for the provided item.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="libraryOptions">The library options.</param>
|
||||
/// <typeparam name="T">The type of metadata provider.</typeparam>
|
||||
/// <returns>The metadata providers.</returns>
|
||||
private bool CanRefreshImages(
|
||||
IImageProvider provider,
|
||||
BaseItem item,
|
||||
TypeOptions? libraryTypeOptions,
|
||||
ImageRefreshOptions refreshOptions,
|
||||
bool includeDisabled)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!provider.Supports(item))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "{ProviderName} failed in Supports for type {ItemType} at {ItemPath}", provider.GetType().Name, item.GetType().Name, item.Path);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (includeDisabled || provider is ILocalImageProvider)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.IsLocked && refreshOptions.ImageRefreshMode != MetadataRefreshMode.FullRefresh)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return _baseItemManager.IsImageFetcherEnabled(item, libraryTypeOptions, provider.Name);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<IMetadataProvider<T>> GetMetadataProviders<T>(BaseItem item, LibraryOptions libraryOptions)
|
||||
where T : BaseItem
|
||||
{
|
||||
|
@ -367,165 +371,84 @@ namespace MediaBrowser.Providers.Manager
|
|||
private IEnumerable<IMetadataProvider<T>> GetMetadataProvidersInternal<T>(BaseItem item, LibraryOptions libraryOptions, MetadataOptions globalMetadataOptions, bool includeDisabled, bool forceEnableInternetMetadata)
|
||||
where T : BaseItem
|
||||
{
|
||||
// Avoid implicitly captured closure
|
||||
var currentOptions = globalMetadataOptions;
|
||||
var localMetadataReaderOrder = libraryOptions.LocalMetadataReaderOrder ?? globalMetadataOptions.LocalMetadataReaderOrder;
|
||||
var typeOptions = libraryOptions.GetTypeOptions(item.GetType().Name);
|
||||
var metadataFetcherOrder = typeOptions?.MetadataFetcherOrder ?? globalMetadataOptions.MetadataFetcherOrder;
|
||||
|
||||
return _metadataProviders.OfType<IMetadataProvider<T>>()
|
||||
.Where(i => CanRefresh(i, item, libraryOptions, includeDisabled, forceEnableInternetMetadata))
|
||||
.OrderBy(i => GetConfiguredOrder(item, i, libraryOptions, globalMetadataOptions))
|
||||
.Where(i => CanRefreshMetadata(i, item, typeOptions, includeDisabled, forceEnableInternetMetadata))
|
||||
.OrderBy(i =>
|
||||
// local and remote providers will be interleaved in the final order
|
||||
// only relative order within a type matters: consumers of the list filter to one or the other
|
||||
i switch
|
||||
{
|
||||
ILocalMetadataProvider => GetConfiguredOrder(localMetadataReaderOrder, i.Name),
|
||||
IRemoteMetadataProvider => GetConfiguredOrder(metadataFetcherOrder, i.Name),
|
||||
// Default to end
|
||||
_ => int.MaxValue
|
||||
})
|
||||
.ThenBy(GetDefaultOrder);
|
||||
}
|
||||
|
||||
private IEnumerable<IRemoteImageProvider> GetRemoteImageProviders(BaseItem item, bool includeDisabled)
|
||||
{
|
||||
var options = GetMetadataOptions(item);
|
||||
var libraryOptions = _libraryManager.GetLibraryOptions(item);
|
||||
|
||||
return GetImageProviders(
|
||||
item,
|
||||
libraryOptions,
|
||||
options,
|
||||
new ImageRefreshOptions(new DirectoryService(_fileSystem)),
|
||||
includeDisabled).OfType<IRemoteImageProvider>();
|
||||
}
|
||||
|
||||
private bool CanRefresh(
|
||||
private bool CanRefreshMetadata(
|
||||
IMetadataProvider provider,
|
||||
BaseItem item,
|
||||
LibraryOptions libraryOptions,
|
||||
TypeOptions? libraryTypeOptions,
|
||||
bool includeDisabled,
|
||||
bool forceEnableInternetMetadata)
|
||||
{
|
||||
if (!includeDisabled)
|
||||
{
|
||||
// If locked only allow local providers
|
||||
if (item.IsLocked && provider is not ILocalMetadataProvider && provider is not IForcedProvider)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (provider is IRemoteMetadataProvider)
|
||||
{
|
||||
if (!forceEnableInternetMetadata && !_baseItemManager.IsMetadataFetcherEnabled(item, libraryOptions, provider.Name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!item.SupportsLocalMetadata && provider is ILocalMetadataProvider)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// If this restriction is ever lifted, movie xml providers will have to be updated to prevent owned items like trailers from reading those files
|
||||
if (!item.OwnerId.Equals(default))
|
||||
// Prevent owned items from reading the same local metadata file as their owner
|
||||
if (!item.OwnerId.Equals(default) && provider is ILocalMetadataProvider)
|
||||
{
|
||||
if (provider is ILocalMetadataProvider || provider is IRemoteMetadataProvider)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool CanRefresh(
|
||||
IImageProvider provider,
|
||||
BaseItem item,
|
||||
LibraryOptions libraryOptions,
|
||||
ImageRefreshOptions refreshOptions,
|
||||
bool includeDisabled)
|
||||
{
|
||||
if (!includeDisabled)
|
||||
{
|
||||
// If locked only allow local providers
|
||||
if (item.IsLocked && provider is not ILocalImageProvider)
|
||||
{
|
||||
if (refreshOptions.ImageRefreshMode != MetadataRefreshMode.FullRefresh)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (provider is IRemoteImageProvider || provider is IDynamicImageProvider)
|
||||
{
|
||||
if (!_baseItemManager.IsImageFetcherEnabled(item, libraryOptions, provider.Name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return provider.Supports(item);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "{ProviderName} failed in Supports for type {ItemType} at {ItemPath}", provider.GetType().Name, item.GetType().Name, item.Path);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (includeDisabled)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// If locked only allow local providers
|
||||
if (item.IsLocked && provider is not ILocalMetadataProvider && provider is not IForcedProvider)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (forceEnableInternetMetadata || provider is not IRemoteMetadataProvider)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return _baseItemManager.IsMetadataFetcherEnabled(item, libraryTypeOptions, provider.Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the order.
|
||||
/// </summary>
|
||||
/// <param name="provider">The provider.</param>
|
||||
/// <returns>System.Int32.</returns>
|
||||
private int GetOrder(IImageProvider provider)
|
||||
private static int GetConfiguredOrder(string[] order, string providerName)
|
||||
{
|
||||
if (provider is not IHasOrder hasOrder)
|
||||
var index = Array.IndexOf(order, providerName);
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
return 0;
|
||||
return index;
|
||||
}
|
||||
|
||||
return hasOrder.Order;
|
||||
// default to end
|
||||
return int.MaxValue;
|
||||
}
|
||||
|
||||
private int GetConfiguredOrder(BaseItem item, IMetadataProvider provider, LibraryOptions libraryOptions, MetadataOptions globalMetadataOptions)
|
||||
{
|
||||
// See if there's a user-defined order
|
||||
if (provider is ILocalMetadataProvider)
|
||||
{
|
||||
var configuredOrder = libraryOptions.LocalMetadataReaderOrder ?? globalMetadataOptions.LocalMetadataReaderOrder;
|
||||
|
||||
var index = Array.IndexOf(configuredOrder, provider.Name);
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
// See if there's a user-defined order
|
||||
if (provider is IRemoteMetadataProvider)
|
||||
{
|
||||
var typeOptions = libraryOptions.GetTypeOptions(item.GetType().Name);
|
||||
var typeFetcherOrder = typeOptions?.MetadataFetcherOrder;
|
||||
|
||||
var fetcherOrder = typeFetcherOrder ?? globalMetadataOptions.MetadataFetcherOrder;
|
||||
|
||||
var index = Array.IndexOf(fetcherOrder, provider.Name);
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
// Not configured. Just return some high number to put it at the end.
|
||||
return 100;
|
||||
}
|
||||
|
||||
private int GetDefaultOrder(IMetadataProvider provider)
|
||||
private static int GetDefaultOrder(object provider)
|
||||
{
|
||||
if (provider is IHasOrder hasOrder)
|
||||
{
|
||||
return hasOrder.Order;
|
||||
}
|
||||
|
||||
return 0;
|
||||
// after items that want to be first (~0) but before items that want to be last (~100)
|
||||
return 50;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
@ -568,7 +491,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
|
||||
var libraryOptions = new LibraryOptions();
|
||||
|
||||
var imageProviders = GetImageProviders(
|
||||
var imageProviders = GetImageProvidersInternal(
|
||||
dummy,
|
||||
libraryOptions,
|
||||
options,
|
||||
|
@ -677,7 +600,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
|
||||
foreach (var saver in savers.Where(i => IsSaverEnabledForItem(i, item, libraryOptions, updateType, false)))
|
||||
{
|
||||
_logger.LogDebug("Saving {0} to {1}.", item.Path ?? item.Name, saver.Name);
|
||||
_logger.LogDebug("Saving {Item} to {Saver}", item.Path ?? item.Name, saver.Name);
|
||||
|
||||
if (saver is IMetadataFileSaver fileSaver)
|
||||
{
|
||||
|
@ -689,7 +612,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error in {0} GetSavePath", saver.Name);
|
||||
_logger.LogError(ex, "Error in {Saver} GetSavePath", saver.Name);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -776,7 +699,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error in {0}.IsEnabledFor", saver.Name);
|
||||
_logger.LogError(ex, "Error in {Saver}.IsEnabledFor", saver.Name);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -786,7 +709,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
where TItemType : BaseItem, new()
|
||||
where TLookupType : ItemLookupInfo
|
||||
{
|
||||
BaseItem referenceItem = null;
|
||||
BaseItem? referenceItem = null;
|
||||
|
||||
if (!searchInfo.ItemId.Equals(default))
|
||||
{
|
||||
|
@ -796,7 +719,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
return GetRemoteSearchResults<TItemType, TLookupType>(searchInfo, referenceItem, cancellationToken);
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<RemoteSearchResult>> GetRemoteSearchResults<TItemType, TLookupType>(RemoteSearchQuery<TLookupType> searchInfo, BaseItem referenceItem, CancellationToken cancellationToken)
|
||||
private async Task<IEnumerable<RemoteSearchResult>> GetRemoteSearchResults<TItemType, TLookupType>(RemoteSearchQuery<TLookupType> searchInfo, BaseItem? referenceItem, CancellationToken cancellationToken)
|
||||
where TItemType : BaseItem, new()
|
||||
where TLookupType : ItemLookupInfo
|
||||
{
|
||||
|
@ -926,7 +849,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error in {0}.Supports", i.GetType().Name);
|
||||
_logger.LogError(ex, "Error in {Type}.Supports", i.GetType().Name);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
@ -958,7 +881,8 @@ namespace MediaBrowser.Providers.Manager
|
|||
i.UrlFormatString,
|
||||
value)
|
||||
};
|
||||
}).Where(i => i != null).Concat(item.GetRelatedUrls());
|
||||
}).Where(i => i != null)
|
||||
.Concat(item.GetRelatedUrls())!; // We just filtered out all the nulls
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
@ -991,7 +915,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
/// <inheritdoc/>
|
||||
public void OnRefreshStart(BaseItem item)
|
||||
{
|
||||
_logger.LogDebug("OnRefreshStart {0}", item.Id.ToString("N", CultureInfo.InvariantCulture));
|
||||
_logger.LogDebug("OnRefreshStart {Item}", item.Id.ToString("N", CultureInfo.InvariantCulture));
|
||||
_activeRefreshes[item.Id] = 0;
|
||||
RefreshStarted?.Invoke(this, new GenericEventArgs<BaseItem>(item));
|
||||
}
|
||||
|
@ -999,7 +923,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
/// <inheritdoc/>
|
||||
public void OnRefreshComplete(BaseItem item)
|
||||
{
|
||||
_logger.LogDebug("OnRefreshComplete {0}", item.Id.ToString("N", CultureInfo.InvariantCulture));
|
||||
_logger.LogDebug("OnRefreshComplete {Item}", item.Id.ToString("N", CultureInfo.InvariantCulture));
|
||||
|
||||
_activeRefreshes.Remove(item.Id, out _);
|
||||
|
||||
|
@ -1021,7 +945,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
public void OnRefreshProgress(BaseItem item, double progress)
|
||||
{
|
||||
var id = item.Id;
|
||||
_logger.LogDebug("OnRefreshProgress {0} {1}", id.ToString("N", CultureInfo.InvariantCulture), progress);
|
||||
_logger.LogDebug("OnRefreshProgress {Id} {Progress}", id.ToString("N", CultureInfo.InvariantCulture), progress);
|
||||
|
||||
// TODO: Need to hunt down the conditions for this happening
|
||||
_activeRefreshes.AddOrUpdate(
|
||||
|
|
|
@ -175,12 +175,12 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||
return Array.Empty<ExternalPathParserResult>();
|
||||
}
|
||||
|
||||
var files = directoryService.GetFilePaths(folder, clearCache).ToList();
|
||||
var files = directoryService.GetFilePaths(folder, clearCache, true).ToList();
|
||||
files.Remove(video.Path);
|
||||
var internalMetadataPath = video.GetInternalMetadataPath();
|
||||
if (_fileSystem.DirectoryExists(internalMetadataPath))
|
||||
{
|
||||
files.AddRange(directoryService.GetFilePaths(internalMetadataPath, clearCache));
|
||||
files.AddRange(directoryService.GetFilePaths(internalMetadataPath, clearCache, true));
|
||||
}
|
||||
|
||||
if (!files.Any())
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
#pragma warning disable CS1591
|
||||
|
||||
using MediaBrowser.Model.Plugins;
|
||||
using MediaBrowser.Model.Plugins;
|
||||
|
||||
namespace MediaBrowser.Providers.Plugins.StudioImages.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// Plugin configuration class for the studio image provider.
|
||||
/// </summary>
|
||||
public class PluginConfiguration : BasePluginConfiguration
|
||||
{
|
||||
private string _repository = Plugin.DefaultServer;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the studio image repository URL.
|
||||
/// </summary>
|
||||
public string RepositoryUrl
|
||||
{
|
||||
get
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#nullable disable
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -11,27 +10,47 @@ using MediaBrowser.Providers.Plugins.StudioImages.Configuration;
|
|||
|
||||
namespace MediaBrowser.Providers.Plugins.StudioImages
|
||||
{
|
||||
/// <summary>
|
||||
/// Artwork Plugin class.
|
||||
/// </summary>
|
||||
public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
||||
{
|
||||
/// <summary>
|
||||
/// Artwork repository URL.
|
||||
/// </summary>
|
||||
public const string DefaultServer = "https://raw.github.com/jellyfin/emby-artwork/master/studios";
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Plugin"/> class.
|
||||
/// </summary>
|
||||
/// <param name="applicationPaths">application paths.</param>
|
||||
/// <param name="xmlSerializer">xml serializer.</param>
|
||||
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)
|
||||
: base(applicationPaths, xmlSerializer)
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance of Artwork plugin.
|
||||
/// </summary>
|
||||
public static Plugin Instance { get; private set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override Guid Id => new Guid("872a7849-1171-458d-a6fb-3de3d442ad30");
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string Name => "Studio Images";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string Description => "Get artwork for studios from any Jellyfin-compatible repository.";
|
||||
|
||||
// TODO remove when plugin removed from server.
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string ConfigurationFileName => "Jellyfin.Plugin.StudioImages.xml";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<PluginPageInfo> GetPages()
|
||||
{
|
||||
yield return new PluginPageInfo
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#nullable disable
|
||||
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
@ -21,12 +19,21 @@ using MediaBrowser.Model.Providers;
|
|||
|
||||
namespace MediaBrowser.Providers.Plugins.StudioImages
|
||||
{
|
||||
/// <summary>
|
||||
/// Studio image provider.
|
||||
/// </summary>
|
||||
public class StudiosImageProvider : IRemoteImageProvider
|
||||
{
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="StudiosImageProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="config">The <see cref="IServerConfigurationManager"/>.</param>
|
||||
/// <param name="httpClientFactory">The <see cref="IHttpClientFactory"/>.</param>
|
||||
/// <param name="fileSystem">The <see cref="IFileSystem"/>.</param>
|
||||
public StudiosImageProvider(IServerConfigurationManager config, IHttpClientFactory httpClientFactory, IFileSystem fileSystem)
|
||||
{
|
||||
_config = config;
|
||||
|
@ -34,13 +41,16 @@ namespace MediaBrowser.Providers.Plugins.StudioImages
|
|||
_fileSystem = fileSystem;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name => "Artwork Repository";
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Supports(BaseItem item)
|
||||
{
|
||||
return item is Studio;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<ImageType> GetSupportedImages(BaseItem item)
|
||||
{
|
||||
return new List<ImageType>
|
||||
|
@ -49,6 +59,7 @@ namespace MediaBrowser.Providers.Plugins.StudioImages
|
|||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, CancellationToken cancellationToken)
|
||||
{
|
||||
var thumbsPath = Path.Combine(_config.ApplicationPaths.CachePath, "imagesbyname", "remotestudiothumbs.txt");
|
||||
|
@ -103,6 +114,7 @@ namespace MediaBrowser.Providers.Plugins.StudioImages
|
|||
return EnsureList(url, file, _fileSystem, cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
var httpClient = _httpClientFactory.CreateClient(NamedClient.Default);
|
||||
|
@ -110,13 +122,13 @@ namespace MediaBrowser.Providers.Plugins.StudioImages
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures the list.
|
||||
/// Ensures the existence of a file listing.
|
||||
/// </summary>
|
||||
/// <param name="url">The URL.</param>
|
||||
/// <param name="file">The file.</param>
|
||||
/// <param name="fileSystem">The file system.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
/// <returns>A Task to ensure existence of a file listing.</returns>
|
||||
public async Task<string> EnsureList(string url, string file, IFileSystem fileSystem, CancellationToken cancellationToken)
|
||||
{
|
||||
var fileInfo = fileSystem.GetFileInfo(file);
|
||||
|
@ -134,6 +146,12 @@ namespace MediaBrowser.Providers.Plugins.StudioImages
|
|||
return file;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get matching image for an item.
|
||||
/// </summary>
|
||||
/// <param name="item">The <see cref="BaseItem"/>.</param>
|
||||
/// <param name="images">The enumerable of image strings.</param>
|
||||
/// <returns>The matching image string.</returns>
|
||||
public string FindMatch(BaseItem item, IEnumerable<string> images)
|
||||
{
|
||||
var name = GetComparableName(item.Name);
|
||||
|
@ -151,6 +169,11 @@ namespace MediaBrowser.Providers.Plugins.StudioImages
|
|||
.Replace("/", string.Empty, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get available image strings for a file.
|
||||
/// </summary>
|
||||
/// <param name="file">The file.</param>
|
||||
/// <returns>All images strings of a file.</returns>
|
||||
public IEnumerable<string> GetAvailableImages(string file)
|
||||
{
|
||||
using var fileStream = File.OpenRead(file);
|
||||
|
|
|
@ -8,7 +8,7 @@ using TMDbLib.Objects.General;
|
|||
namespace MediaBrowser.Providers.Plugins.Tmdb.Api
|
||||
{
|
||||
/// <summary>
|
||||
/// The TMDb api controller.
|
||||
/// The TMDb API controller.
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Authorize(Policy = "DefaultAuthorization")]
|
||||
|
|
|
@ -7,7 +7,7 @@ using MediaBrowser.Model.Providers;
|
|||
namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets
|
||||
{
|
||||
/// <summary>
|
||||
/// External ID for a TMDB box set.
|
||||
/// External id for a TMDb box set.
|
||||
/// </summary>
|
||||
public class TmdbBoxSetExternalId : IExternalId
|
||||
{
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#nullable disable
|
||||
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
@ -18,26 +16,38 @@ using MediaBrowser.Model.Providers;
|
|||
|
||||
namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets
|
||||
{
|
||||
/// <summary>
|
||||
/// BoxSet image provider powered by TMDb.
|
||||
/// </summary>
|
||||
public class TmdbBoxSetImageProvider : IRemoteImageProvider, IHasOrder
|
||||
{
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly TmdbClientManager _tmdbClientManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TmdbBoxSetImageProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="httpClientFactory">The <see cref="IHttpClientFactory"/>.</param>
|
||||
/// <param name="tmdbClientManager">The <see cref="TmdbClientManager"/>.</param>
|
||||
public TmdbBoxSetImageProvider(IHttpClientFactory httpClientFactory, TmdbClientManager tmdbClientManager)
|
||||
{
|
||||
_httpClientFactory = httpClientFactory;
|
||||
_tmdbClientManager = tmdbClientManager;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name => TmdbUtils.ProviderName;
|
||||
|
||||
/// <inheritdoc />
|
||||
public int Order => 0;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Supports(BaseItem item)
|
||||
{
|
||||
return item is BoxSet;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<ImageType> GetSupportedImages(BaseItem item)
|
||||
{
|
||||
return new List<ImageType>
|
||||
|
@ -47,6 +57,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets
|
|||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, CancellationToken cancellationToken)
|
||||
{
|
||||
var tmdbId = Convert.ToInt32(item.GetProviderId(MetadataProvider.Tmdb), CultureInfo.InvariantCulture);
|
||||
|
@ -76,6 +87,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets
|
|||
return remoteImages;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
return _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(url, cancellationToken);
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#nullable disable
|
||||
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
@ -18,12 +16,21 @@ using MediaBrowser.Model.Providers;
|
|||
|
||||
namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets
|
||||
{
|
||||
/// <summary>
|
||||
/// BoxSet provider powered by TMDb.
|
||||
/// </summary>
|
||||
public class TmdbBoxSetProvider : IRemoteMetadataProvider<BoxSet, BoxSetInfo>
|
||||
{
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly TmdbClientManager _tmdbClientManager;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TmdbBoxSetProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="libraryManager">The <see cref="ILibraryManager"/>.</param>
|
||||
/// <param name="httpClientFactory">The <see cref="IHttpClientFactory"/>.</param>
|
||||
/// <param name="tmdbClientManager">The <see cref="TmdbClientManager"/>.</param>
|
||||
public TmdbBoxSetProvider(IHttpClientFactory httpClientFactory, TmdbClientManager tmdbClientManager, ILibraryManager libraryManager)
|
||||
{
|
||||
_httpClientFactory = httpClientFactory;
|
||||
|
@ -31,8 +38,10 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets
|
|||
_libraryManager = libraryManager;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name => TmdbUtils.ProviderName;
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(BoxSetInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
var tmdbId = Convert.ToInt32(searchInfo.GetProviderId(MetadataProvider.Tmdb), CultureInfo.InvariantCulture);
|
||||
|
@ -81,6 +90,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets
|
|||
return collections;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<MetadataResult<BoxSet>> GetMetadata(BoxSetInfo info, CancellationToken cancellationToken)
|
||||
{
|
||||
var tmdbId = Convert.ToInt32(info.GetProviderId(MetadataProvider.Tmdb), CultureInfo.InvariantCulture);
|
||||
|
@ -124,6 +134,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.BoxSets
|
|||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
return _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(url, cancellationToken);
|
||||
|
|
|
@ -7,7 +7,7 @@ using MediaBrowser.Model.Providers;
|
|||
namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
||||
{
|
||||
/// <summary>
|
||||
/// External ID for a TMBD movie.
|
||||
/// External id for a TMDb movie.
|
||||
/// </summary>
|
||||
public class TmdbMovieExternalId : IExternalId
|
||||
{
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#nullable disable
|
||||
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
@ -19,26 +17,38 @@ using TMDbLib.Objects.Find;
|
|||
|
||||
namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
||||
{
|
||||
/// <summary>
|
||||
/// Movie image provider powered by TMDb.
|
||||
/// </summary>
|
||||
public class TmdbMovieImageProvider : IRemoteImageProvider, IHasOrder
|
||||
{
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly TmdbClientManager _tmdbClientManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TmdbMovieImageProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="httpClientFactory">The <see cref="IHttpClientFactory"/>.</param>
|
||||
/// <param name="tmdbClientManager">The <see cref="TmdbClientManager"/>.</param>
|
||||
public TmdbMovieImageProvider(IHttpClientFactory httpClientFactory, TmdbClientManager tmdbClientManager)
|
||||
{
|
||||
_httpClientFactory = httpClientFactory;
|
||||
_tmdbClientManager = tmdbClientManager;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public int Order => 0;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name => TmdbUtils.ProviderName;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Supports(BaseItem item)
|
||||
{
|
||||
return item is Movie || item is Trailer;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<ImageType> GetSupportedImages(BaseItem item)
|
||||
{
|
||||
return new List<ImageType>
|
||||
|
@ -49,6 +59,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
|||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, CancellationToken cancellationToken)
|
||||
{
|
||||
var language = item.GetPreferredMetadataLanguage();
|
||||
|
@ -96,6 +107,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
|||
return remoteImages;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
return _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(url, cancellationToken);
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#nullable disable
|
||||
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
@ -23,7 +21,7 @@ using TMDbLib.Objects.Search;
|
|||
namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
||||
{
|
||||
/// <summary>
|
||||
/// Class MovieDbProvider.
|
||||
/// Movie provider powered by TMDb.
|
||||
/// </summary>
|
||||
public class TmdbMovieProvider : IRemoteMetadataProvider<Movie, MovieInfo>, IHasOrder
|
||||
{
|
||||
|
@ -31,6 +29,12 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
|||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly TmdbClientManager _tmdbClientManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TmdbMovieProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="libraryManager">The <see cref="ILibraryManager"/>.</param>
|
||||
/// <param name="httpClientFactory">The <see cref="IHttpClientFactory"/>.</param>
|
||||
/// <param name="tmdbClientManager">The <see cref="TmdbClientManager"/>.</param>
|
||||
public TmdbMovieProvider(
|
||||
ILibraryManager libraryManager,
|
||||
TmdbClientManager tmdbClientManager,
|
||||
|
@ -41,11 +45,13 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
|||
_httpClientFactory = httpClientFactory;
|
||||
}
|
||||
|
||||
public string Name => TmdbUtils.ProviderName;
|
||||
|
||||
/// <inheritdoc />
|
||||
public int Order => 1;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name => TmdbUtils.ProviderName;
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(MovieInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
if (searchInfo.TryGetProviderId(MetadataProvider.Tmdb, out var id))
|
||||
|
@ -133,6 +139,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
|||
return remoteSearchResults;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<MetadataResult<Movie>> GetMetadata(MovieInfo info, CancellationToken cancellationToken)
|
||||
{
|
||||
var tmdbId = info.GetProviderId(MetadataProvider.Tmdb);
|
||||
|
@ -144,7 +151,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.Movies
|
|||
// Caller provides the filename with extension stripped and NOT the parsed filename
|
||||
var parsedName = _libraryManager.ParseName(info.Name);
|
||||
var cleanedName = TmdbUtils.CleanName(parsedName.Name);
|
||||
var searchResults = await _tmdbClientManager.SearchMovieAsync(cleanedName, info.Year ?? parsedName.Year ?? 0, info.MetadataLanguage, cancellationToken).ConfigureAwait(false);
|
||||
var searchResults = await _tmdbClientManager.SearchMovieAsync(cleanedName, info.Year ?? parsedName.Year ?? 0, info.MetadataLanguage, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (searchResults.Count > 0)
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ using MediaBrowser.Model.Providers;
|
|||
namespace MediaBrowser.Providers.Plugins.Tmdb.People
|
||||
{
|
||||
/// <summary>
|
||||
/// External ID for a TMDB person.
|
||||
/// External id for a TMDb person.
|
||||
/// </summary>
|
||||
public class TmdbPersonExternalId : IExternalId
|
||||
{
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#pragma warning disable CS1591
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
@ -14,11 +12,19 @@ using MediaBrowser.Model.Providers;
|
|||
|
||||
namespace MediaBrowser.Providers.Plugins.Tmdb.People
|
||||
{
|
||||
/// <summary>
|
||||
/// Person image provider powered by TMDb.
|
||||
/// </summary>
|
||||
public class TmdbPersonImageProvider : IRemoteImageProvider, IHasOrder
|
||||
{
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly TmdbClientManager _tmdbClientManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TmdbPersonImageProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="httpClientFactory">The <see cref="IHttpClientFactory"/>.</param>
|
||||
/// <param name="tmdbClientManager">The <see cref="TmdbClientManager"/>.</param>
|
||||
public TmdbPersonImageProvider(IHttpClientFactory httpClientFactory, TmdbClientManager tmdbClientManager)
|
||||
{
|
||||
_httpClientFactory = httpClientFactory;
|
||||
|
@ -31,11 +37,13 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
|
|||
/// <inheritdoc />
|
||||
public int Order => 0;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Supports(BaseItem item)
|
||||
{
|
||||
return item is Person;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<ImageType> GetSupportedImages(BaseItem item)
|
||||
{
|
||||
return new List<ImageType>
|
||||
|
@ -44,6 +52,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
|
|||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, CancellationToken cancellationToken)
|
||||
{
|
||||
var person = (Person)item;
|
||||
|
@ -68,6 +77,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
|
|||
return remoteImages;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
return _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(url, cancellationToken);
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#nullable disable
|
||||
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
@ -16,19 +14,29 @@ using MediaBrowser.Model.Providers;
|
|||
|
||||
namespace MediaBrowser.Providers.Plugins.Tmdb.People
|
||||
{
|
||||
/// <summary>
|
||||
/// Person image provider powered by TMDb.
|
||||
/// </summary>
|
||||
public class TmdbPersonProvider : IRemoteMetadataProvider<Person, PersonLookupInfo>
|
||||
{
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly TmdbClientManager _tmdbClientManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TmdbPersonProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="httpClientFactory">The <see cref="IHttpClientFactory"/>.</param>
|
||||
/// <param name="tmdbClientManager">The <see cref="TmdbClientManager"/>.</param>
|
||||
public TmdbPersonProvider(IHttpClientFactory httpClientFactory, TmdbClientManager tmdbClientManager)
|
||||
{
|
||||
_httpClientFactory = httpClientFactory;
|
||||
_tmdbClientManager = tmdbClientManager;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name => TmdbUtils.ProviderName;
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(PersonLookupInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
if (searchInfo.TryGetProviderId(MetadataProvider.Tmdb, out var personTmdbId))
|
||||
|
@ -79,6 +87,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
|
|||
return remoteSearchResults;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<MetadataResult<Person>> GetMetadata(PersonLookupInfo info, CancellationToken cancellationToken)
|
||||
{
|
||||
var personTmdbId = Convert.ToInt32(info.GetProviderId(MetadataProvider.Tmdb), CultureInfo.InvariantCulture);
|
||||
|
@ -131,6 +140,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.People
|
|||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
return _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(url, cancellationToken);
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#nullable disable
|
||||
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
@ -17,22 +15,38 @@ using MediaBrowser.Model.Providers;
|
|||
|
||||
namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||
{
|
||||
/// <summary>
|
||||
/// TV episode image provider powered by TheMovieDb.
|
||||
/// </summary>
|
||||
public class TmdbEpisodeImageProvider : IRemoteImageProvider, IHasOrder
|
||||
{
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly TmdbClientManager _tmdbClientManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TmdbEpisodeImageProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="httpClientFactory">The <see cref="IHttpClientFactory"/>.</param>
|
||||
/// <param name="tmdbClientManager">The <see cref="TmdbClientManager"/>.</param>
|
||||
public TmdbEpisodeImageProvider(IHttpClientFactory httpClientFactory, TmdbClientManager tmdbClientManager)
|
||||
{
|
||||
_httpClientFactory = httpClientFactory;
|
||||
_tmdbClientManager = tmdbClientManager;
|
||||
}
|
||||
|
||||
// After TheTvDb
|
||||
/// <inheritdoc />
|
||||
public int Order => 1;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name => TmdbUtils.ProviderName;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Supports(BaseItem item)
|
||||
{
|
||||
return item is Controller.Entities.TV.Episode;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<ImageType> GetSupportedImages(BaseItem item)
|
||||
{
|
||||
return new List<ImageType>
|
||||
|
@ -41,6 +55,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, CancellationToken cancellationToken)
|
||||
{
|
||||
var episode = (Controller.Entities.TV.Episode)item;
|
||||
|
@ -81,14 +96,10 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
return remoteImages;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
return _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(url, cancellationToken);
|
||||
}
|
||||
|
||||
public bool Supports(BaseItem item)
|
||||
{
|
||||
return item is Controller.Entities.TV.Episode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#nullable disable
|
||||
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
@ -19,22 +17,32 @@ using MediaBrowser.Model.Providers;
|
|||
|
||||
namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||
{
|
||||
/// <summary>
|
||||
/// TV episode provider powered by TheMovieDb.
|
||||
/// </summary>
|
||||
public class TmdbEpisodeProvider : IRemoteMetadataProvider<Episode, EpisodeInfo>, IHasOrder
|
||||
{
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly TmdbClientManager _tmdbClientManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TmdbEpisodeProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="httpClientFactory">The <see cref="IHttpClientFactory"/>.</param>
|
||||
/// <param name="tmdbClientManager">The <see cref="TmdbClientManager"/>.</param>
|
||||
public TmdbEpisodeProvider(IHttpClientFactory httpClientFactory, TmdbClientManager tmdbClientManager)
|
||||
{
|
||||
_httpClientFactory = httpClientFactory;
|
||||
_tmdbClientManager = tmdbClientManager;
|
||||
}
|
||||
|
||||
// After TheTvDb
|
||||
/// <inheritdoc />
|
||||
public int Order => 1;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name => TmdbUtils.ProviderName;
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(EpisodeInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
// The search query must either provide an episode number or date
|
||||
|
@ -68,6 +76,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<MetadataResult<Episode>> GetMetadata(EpisodeInfo info, CancellationToken cancellationToken)
|
||||
{
|
||||
var metadataResult = new MetadataResult<Episode>();
|
||||
|
@ -209,6 +218,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
return metadataResult;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
return _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(url, cancellationToken);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
@ -16,26 +14,47 @@ using MediaBrowser.Model.Providers;
|
|||
|
||||
namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||
{
|
||||
/// <summary>
|
||||
/// TV season image provider powered by TheMovieDb.
|
||||
/// </summary>
|
||||
public class TmdbSeasonImageProvider : IRemoteImageProvider, IHasOrder
|
||||
{
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly TmdbClientManager _tmdbClientManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TmdbSeasonImageProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="httpClientFactory">The <see cref="IHttpClientFactory"/>.</param>
|
||||
/// <param name="tmdbClientManager">The <see cref="TmdbClientManager"/>.</param>
|
||||
public TmdbSeasonImageProvider(IHttpClientFactory httpClientFactory, TmdbClientManager tmdbClientManager)
|
||||
{
|
||||
_httpClientFactory = httpClientFactory;
|
||||
_tmdbClientManager = tmdbClientManager;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int Order => 1;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string Name => TmdbUtils.ProviderName;
|
||||
|
||||
public Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
/// <inheritdoc />
|
||||
public bool Supports(BaseItem item)
|
||||
{
|
||||
return _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(url, cancellationToken);
|
||||
return item is Season;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<ImageType> GetSupportedImages(BaseItem item)
|
||||
{
|
||||
return new List<ImageType>
|
||||
{
|
||||
ImageType.Primary
|
||||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, CancellationToken cancellationToken)
|
||||
{
|
||||
var season = (Season)item;
|
||||
|
@ -68,17 +87,10 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
return remoteImages;
|
||||
}
|
||||
|
||||
public IEnumerable<ImageType> GetSupportedImages(BaseItem item)
|
||||
/// <inheritdoc />
|
||||
public Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
return new List<ImageType>
|
||||
{
|
||||
ImageType.Primary
|
||||
};
|
||||
}
|
||||
|
||||
public bool Supports(BaseItem item)
|
||||
{
|
||||
return item is Season;
|
||||
return _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(url, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
@ -17,19 +15,29 @@ using MediaBrowser.Model.Providers;
|
|||
|
||||
namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||
{
|
||||
/// <summary>
|
||||
/// TV season provider powered by TheMovieDb.
|
||||
/// </summary>
|
||||
public class TmdbSeasonProvider : IRemoteMetadataProvider<Season, SeasonInfo>
|
||||
{
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly TmdbClientManager _tmdbClientManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TmdbSeasonProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="httpClientFactory">The <see cref="IHttpClientFactory"/>.</param>
|
||||
/// <param name="tmdbClientManager">The <see cref="TmdbClientManager"/>.</param>
|
||||
public TmdbSeasonProvider(IHttpClientFactory httpClientFactory, TmdbClientManager tmdbClientManager)
|
||||
{
|
||||
_httpClientFactory = httpClientFactory;
|
||||
_tmdbClientManager = tmdbClientManager;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name => TmdbUtils.ProviderName;
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<MetadataResult<Season>> GetMetadata(SeasonInfo info, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = new MetadataResult<Season>();
|
||||
|
@ -114,11 +122,13 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<IEnumerable<RemoteSearchResult>> GetSearchResults(SeasonInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult(Enumerable.Empty<RemoteSearchResult>());
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
return _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(url, cancellationToken);
|
||||
|
|
|
@ -6,7 +6,7 @@ using MediaBrowser.Model.Providers;
|
|||
namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||
{
|
||||
/// <summary>
|
||||
/// External ID for a TMDB series.
|
||||
/// External id for a TMDb series.
|
||||
/// </summary>
|
||||
public class TmdbSeriesExternalId : IExternalId
|
||||
{
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
@ -16,27 +14,38 @@ using MediaBrowser.Model.Providers;
|
|||
|
||||
namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||
{
|
||||
/// <summary>
|
||||
/// TV series image provider powered by TheMovieDb.
|
||||
/// </summary>
|
||||
public class TmdbSeriesImageProvider : IRemoteImageProvider, IHasOrder
|
||||
{
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly TmdbClientManager _tmdbClientManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TmdbSeriesImageProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="httpClientFactory">The <see cref="IHttpClientFactory"/>.</param>
|
||||
/// <param name="tmdbClientManager">The <see cref="TmdbClientManager"/>.</param>
|
||||
public TmdbSeriesImageProvider(IHttpClientFactory httpClientFactory, TmdbClientManager tmdbClientManager)
|
||||
{
|
||||
_httpClientFactory = httpClientFactory;
|
||||
_tmdbClientManager = tmdbClientManager;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name => TmdbUtils.ProviderName;
|
||||
|
||||
// After tvdb and fanart
|
||||
/// <inheritdoc />
|
||||
public int Order => 2;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Supports(BaseItem item)
|
||||
{
|
||||
return item is Series;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<ImageType> GetSupportedImages(BaseItem item)
|
||||
{
|
||||
return new List<ImageType>
|
||||
|
@ -47,6 +56,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, CancellationToken cancellationToken)
|
||||
{
|
||||
var tmdbId = item.GetProviderId(MetadataProvider.Tmdb);
|
||||
|
@ -80,6 +90,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
return remoteImages;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
return _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(url, cancellationToken);
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#nullable disable
|
||||
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
@ -23,12 +21,21 @@ using TMDbLib.Objects.TvShows;
|
|||
|
||||
namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
||||
{
|
||||
/// <summary>
|
||||
/// TV series provider powered by TheMovieDb.
|
||||
/// </summary>
|
||||
public class TmdbSeriesProvider : IRemoteMetadataProvider<Series, SeriesInfo>, IHasOrder
|
||||
{
|
||||
private readonly IHttpClientFactory _httpClientFactory;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly TmdbClientManager _tmdbClientManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TmdbSeriesProvider"/> class.
|
||||
/// </summary>
|
||||
/// <param name="libraryManager">The <see cref="ILibraryManager"/>.</param>
|
||||
/// <param name="httpClientFactory">The <see cref="IHttpClientFactory"/>.</param>
|
||||
/// <param name="tmdbClientManager">The <see cref="TmdbClientManager"/>.</param>
|
||||
public TmdbSeriesProvider(
|
||||
ILibraryManager libraryManager,
|
||||
IHttpClientFactory httpClientFactory,
|
||||
|
@ -39,11 +46,13 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
_tmdbClientManager = tmdbClientManager;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Name => TmdbUtils.ProviderName;
|
||||
|
||||
// After TheTVDB
|
||||
/// <inheritdoc />
|
||||
public int Order => 1;
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(SeriesInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
if (searchInfo.TryGetProviderId(MetadataProvider.Tmdb, out var tmdbId))
|
||||
|
@ -159,6 +168,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
return remoteResult;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<MetadataResult<Series>> GetMetadata(SeriesInfo info, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = new MetadataResult<Series>
|
||||
|
@ -383,6 +393,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb.TV
|
|||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
return _httpClientFactory.CreateClient(NamedClient.Default).GetAsync(url, cancellationToken);
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
|||
private static readonly Regex _nonWords = new(@"[\W_]+", RegexOptions.Compiled);
|
||||
|
||||
/// <summary>
|
||||
/// URL of the TMDB instance to use.
|
||||
/// URL of the TMDb instance to use.
|
||||
/// </summary>
|
||||
public const string BaseTmdbUrl = "https://www.themoviedb.org/";
|
||||
|
||||
|
@ -50,7 +50,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maps the TMDB provided roles for crew members to Jellyfin roles.
|
||||
/// Maps the TMDb provided roles for crew members to Jellyfin roles.
|
||||
/// </summary>
|
||||
/// <param name="crew">Crew member to map against the Jellyfin person types.</param>
|
||||
/// <returns>The Jellyfin person type.</returns>
|
||||
|
@ -103,9 +103,9 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
|||
|
||||
languages.Add(preferredLanguage);
|
||||
|
||||
if (preferredLanguage.Length == 5) // like en-US
|
||||
if (preferredLanguage.Length == 5) // Like en-US
|
||||
{
|
||||
// Currently, TMDB supports 2-letter language codes only
|
||||
// Currently, TMDb supports 2-letter language codes only.
|
||||
// They are planning to change this in the future, thus we're
|
||||
// supplying both codes if we're having a 5-letter code.
|
||||
languages.Add(preferredLanguage.Substring(0, 2));
|
||||
|
@ -114,6 +114,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
|||
|
||||
languages.Add("null");
|
||||
|
||||
// Always add English as fallback language
|
||||
if (!string.Equals(preferredLanguage, "en", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
languages.Add("en");
|
||||
|
@ -134,14 +135,14 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
|||
return language;
|
||||
}
|
||||
|
||||
// They require this to be uppercase
|
||||
// Everything after the hyphen must be written in uppercase due to a way TMDB wrote their api.
|
||||
// TMDb requires this to be uppercase
|
||||
// Everything after the hyphen must be written in uppercase due to a way TMDb wrote their API.
|
||||
// See here: https://www.themoviedb.org/talk/5119221d760ee36c642af4ad?page=3#56e372a0c3a3685a9e0019ab
|
||||
var parts = language.Split('-');
|
||||
|
||||
if (parts.Length == 2)
|
||||
{
|
||||
// TMDB doesn't support Switzerland (de-CH, it-CH or fr-CH) so use the language (de, it or fr) without country code
|
||||
// TMDb doesn't support Switzerland (de-CH, it-CH or fr-CH) so use the language (de, it or fr) without country code
|
||||
if (string.Equals(parts[1], "CH", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return parts[0];
|
||||
|
@ -174,14 +175,14 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Combines the metadata country code and the parental rating from the Api into the value we store in our database.
|
||||
/// Combines the metadata country code and the parental rating from the API into the value we store in our database.
|
||||
/// </summary>
|
||||
/// <param name="countryCode">The Iso 3166-1 country code of the rating country.</param>
|
||||
/// <param name="ratingValue">The rating value returned by the Tmdb Api.</param>
|
||||
/// <param name="countryCode">The ISO 3166-1 country code of the rating country.</param>
|
||||
/// <param name="ratingValue">The rating value returned by the TMDb API.</param>
|
||||
/// <returns>The combined parental rating of country code+rating value.</returns>
|
||||
public static string BuildParentalRating(string countryCode, string ratingValue)
|
||||
{
|
||||
// exclude US because we store us values as TV-14 without the country code.
|
||||
// Exclude US because we store US values as TV-14 without the country code.
|
||||
var ratingPrefix = string.Equals(countryCode, "US", StringComparison.OrdinalIgnoreCase) ? string.Empty : countryCode + "-";
|
||||
var newRating = ratingPrefix + ratingValue;
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
@ -23,6 +21,10 @@ using Microsoft.Extensions.Logging;
|
|||
|
||||
namespace MediaBrowser.XbmcMetadata.Parsers
|
||||
{
|
||||
/// <summary>
|
||||
/// The BaseNfoParser class.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type.</typeparam>
|
||||
public class BaseNfoParser<T>
|
||||
where T : BaseItem
|
||||
{
|
||||
|
@ -63,16 +65,22 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
/// </summary>
|
||||
protected ILogger Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the provider manager.
|
||||
/// </summary>
|
||||
protected IProviderManager ProviderManager { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether URLs after a closing XML tag are supporrted.
|
||||
/// </summary>
|
||||
protected virtual bool SupportsUrlAfterClosingXmlTag => false;
|
||||
|
||||
/// <summary>
|
||||
/// Fetches metadata for an item from one xml file.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="item">The <see cref="MetadataResult{T}"/>.</param>
|
||||
/// <param name="metadataFile">The metadata file.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/>.</param>
|
||||
/// <exception cref="ArgumentNullException"><c>item</c> is <c>null</c>.</exception>
|
||||
/// <exception cref="ArgumentException"><c>metadataFile</c> is <c>null</c> or empty.</exception>
|
||||
public void Fetch(MetadataResult<T> item, string metadataFile, CancellationToken cancellationToken)
|
||||
|
@ -111,10 +119,10 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
/// <summary>
|
||||
/// Fetches the specified item.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="item">The <see cref="MetadataResult{T}"/>.</param>
|
||||
/// <param name="metadataFile">The metadata file.</param>
|
||||
/// <param name="settings">The settings.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="settings">The <see cref="XmlReaderSettings"/>.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/>.</param>
|
||||
protected virtual void Fetch(MetadataResult<T> item, string metadataFile, XmlReaderSettings settings, CancellationToken cancellationToken)
|
||||
{
|
||||
if (!SupportsUrlAfterClosingXmlTag)
|
||||
|
@ -170,7 +178,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
|
||||
ParseProviderLinks(item.Item, endingXml);
|
||||
|
||||
// If the file is just an imdb url, don't go any further
|
||||
// If the file is just an IMDb url, don't go any further
|
||||
if (index == 0)
|
||||
{
|
||||
return;
|
||||
|
@ -216,6 +224,11 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses a XML tag to a provider id.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="xml">The xml tag.</param>
|
||||
protected void ParseProviderLinks(T item, ReadOnlySpan<char> xml)
|
||||
{
|
||||
if (ProviderIdParsers.TryFindImdbId(xml, out var imdbId))
|
||||
|
@ -245,6 +258,11 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches metadata from an XML node.
|
||||
/// </summary>
|
||||
/// <param name="reader">The <see cref="XmlReader"/>.</param>
|
||||
/// <param name="itemResult">The <see cref="MetadataResult{T}"/>.</param>
|
||||
protected virtual void FetchDataFromXmlNode(XmlReader reader, MetadataResult<T> itemResult)
|
||||
{
|
||||
var item = itemResult.Item;
|
||||
|
@ -1100,17 +1118,14 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
switch (reader.Name)
|
||||
{
|
||||
case "language":
|
||||
_ = reader.ReadElementContentAsString();
|
||||
if (item is Video video)
|
||||
{
|
||||
_ = reader.ReadElementContentAsString();
|
||||
|
||||
if (item is Video video)
|
||||
{
|
||||
video.HasSubtitles = true;
|
||||
}
|
||||
|
||||
break;
|
||||
video.HasSubtitles = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
reader.Skip();
|
||||
break;
|
||||
|
@ -1136,21 +1151,21 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
switch (reader.Name)
|
||||
{
|
||||
case "rating":
|
||||
{
|
||||
if (reader.IsEmptyElement)
|
||||
{
|
||||
reader.Read();
|
||||
continue;
|
||||
if (reader.IsEmptyElement)
|
||||
{
|
||||
reader.Read();
|
||||
continue;
|
||||
}
|
||||
|
||||
var ratingName = reader.GetAttribute("name");
|
||||
|
||||
using var subtree = reader.ReadSubtree();
|
||||
FetchFromRatingNode(subtree, item, ratingName);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
var ratingName = reader.GetAttribute("name");
|
||||
|
||||
using var subtree = reader.ReadSubtree();
|
||||
FetchFromRatingNode(subtree, item, ratingName);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
reader.Skip();
|
||||
break;
|
||||
|
@ -1210,9 +1225,9 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the persons from XML node.
|
||||
/// Gets the persons from a XML node.
|
||||
/// </summary>
|
||||
/// <param name="reader">The reader.</param>
|
||||
/// <param name="reader">The <see cref="XmlReader"/>.</param>
|
||||
/// <returns>IEnumerable{PersonInfo}.</returns>
|
||||
private PersonInfo GetPersonFromXmlNode(XmlReader reader)
|
||||
{
|
||||
|
@ -1348,10 +1363,10 @@ namespace MediaBrowser.XbmcMetadata.Parsers
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses the ImageType from the nfo aspect property.
|
||||
/// Parses the <see cref="ImageType"/> from the NFO aspect property.
|
||||
/// </summary>
|
||||
/// <param name="aspect">The nfo aspect property.</param>
|
||||
/// <returns>The image type.</returns>
|
||||
/// <param name="aspect">The NFO aspect property.</param>
|
||||
/// <returns>The <see cref="ImageType"/>.</returns>
|
||||
private static ImageType GetImageType(string aspect)
|
||||
{
|
||||
return aspect switch
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<PackageReference Include="AutoFixture" Version="4.17.0" />
|
||||
<PackageReference Include="AutoFixture.AutoMoq" Version="4.17.0" />
|
||||
<PackageReference Include="Moq" Version="4.18.2" />
|
||||
<PackageReference Include="SharpFuzz" Version="1.6.2" />
|
||||
<PackageReference Include="SharpFuzz" Version="2.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SharpFuzz" Version="1.6.2" />
|
||||
<PackageReference Include="SharpFuzz" Version="2.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -20,17 +20,13 @@ namespace Jellyfin.Controller.Tests
|
|||
{
|
||||
BaseItem item = (BaseItem)Activator.CreateInstance(itemType)!;
|
||||
|
||||
var libraryOptions = new LibraryOptions
|
||||
{
|
||||
TypeOptions = new[]
|
||||
var libraryTypeOptions = itemType == typeof(Book)
|
||||
? new TypeOptions
|
||||
{
|
||||
new TypeOptions
|
||||
{
|
||||
Type = "Book",
|
||||
MetadataFetchers = new[] { "LibraryEnabled" }
|
||||
}
|
||||
Type = "Book",
|
||||
MetadataFetchers = new[] { "LibraryEnabled" }
|
||||
}
|
||||
};
|
||||
: null;
|
||||
|
||||
var serverConfiguration = new ServerConfiguration();
|
||||
foreach (var typeConfig in serverConfiguration.MetadataOptions)
|
||||
|
@ -43,7 +39,7 @@ namespace Jellyfin.Controller.Tests
|
|||
.Returns(serverConfiguration);
|
||||
|
||||
var baseItemManager = new BaseItemManager(serverConfigurationManager.Object);
|
||||
var actual = baseItemManager.IsMetadataFetcherEnabled(item, libraryOptions, fetcherName);
|
||||
var actual = baseItemManager.IsMetadataFetcherEnabled(item, libraryTypeOptions, fetcherName);
|
||||
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
@ -57,17 +53,13 @@ namespace Jellyfin.Controller.Tests
|
|||
{
|
||||
BaseItem item = (BaseItem)Activator.CreateInstance(itemType)!;
|
||||
|
||||
var libraryOptions = new LibraryOptions
|
||||
{
|
||||
TypeOptions = new[]
|
||||
var libraryTypeOptions = itemType == typeof(Book)
|
||||
? new TypeOptions
|
||||
{
|
||||
new TypeOptions
|
||||
{
|
||||
Type = "Book",
|
||||
ImageFetchers = new[] { "LibraryEnabled" }
|
||||
}
|
||||
Type = "Book",
|
||||
ImageFetchers = new[] { "LibraryEnabled" }
|
||||
}
|
||||
};
|
||||
: null;
|
||||
|
||||
var serverConfiguration = new ServerConfiguration();
|
||||
foreach (var typeConfig in serverConfiguration.MetadataOptions)
|
||||
|
@ -80,7 +72,7 @@ namespace Jellyfin.Controller.Tests
|
|||
.Returns(serverConfiguration);
|
||||
|
||||
var baseItemManager = new BaseItemManager(serverConfigurationManager.Object);
|
||||
var actual = baseItemManager.IsImageFetcherEnabled(item, libraryOptions, fetcherName);
|
||||
var actual = baseItemManager.IsImageFetcherEnabled(item, libraryTypeOptions, fetcherName);
|
||||
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
|
614
tests/Jellyfin.Providers.Tests/Manager/ProviderManagerTests.cs
Normal file
614
tests/Jellyfin.Providers.Tests/Manager/ProviderManagerTests.cs
Normal file
|
@ -0,0 +1,614 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.BaseItemManager;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Controller.Subtitles;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Providers.Manager;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
// Allow Moq to see internal class
|
||||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
|
||||
|
||||
namespace Jellyfin.Providers.Tests.Manager
|
||||
{
|
||||
public class ProviderManagerTests
|
||||
{
|
||||
private static readonly ILogger<ProviderManager> _logger = new NullLogger<ProviderManager>();
|
||||
|
||||
public static TheoryData<Mock<IMetadataService>[], int> RefreshSingleItemOrderData()
|
||||
=> new()
|
||||
{
|
||||
// no order set, uses provided order
|
||||
{
|
||||
new[]
|
||||
{
|
||||
MockIMetadataService(true, true),
|
||||
MockIMetadataService(true, true)
|
||||
},
|
||||
0
|
||||
},
|
||||
// sort order sets priority when all match
|
||||
{
|
||||
new[]
|
||||
{
|
||||
MockIMetadataService(true, true, 1),
|
||||
MockIMetadataService(true, true, 0),
|
||||
MockIMetadataService(true, true, 2)
|
||||
},
|
||||
1
|
||||
},
|
||||
// CanRefreshPrimary prioritized
|
||||
{
|
||||
new[]
|
||||
{
|
||||
MockIMetadataService(false, true),
|
||||
MockIMetadataService(true, true),
|
||||
},
|
||||
1
|
||||
},
|
||||
// falls back to CanRefresh
|
||||
{
|
||||
new[]
|
||||
{
|
||||
MockIMetadataService(false, false),
|
||||
MockIMetadataService(false, true)
|
||||
},
|
||||
1
|
||||
},
|
||||
};
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(RefreshSingleItemOrderData))]
|
||||
public async Task RefreshSingleItem_ServiceOrdering_FollowsPriority(Mock<IMetadataService>[] servicesList, int expectedIndex)
|
||||
{
|
||||
var item = new Movie();
|
||||
|
||||
using var providerManager = GetProviderManager();
|
||||
AddParts(providerManager, metadataServices: servicesList.Select(s => s.Object).ToArray());
|
||||
|
||||
var refreshOptions = new MetadataRefreshOptions(Mock.Of<IDirectoryService>(MockBehavior.Strict));
|
||||
var actual = await providerManager.RefreshSingleItem(item, refreshOptions, CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
Assert.Equal(ItemUpdateType.MetadataDownload, actual);
|
||||
for (var i = 0; i < servicesList.Length; i++)
|
||||
{
|
||||
var times = i == expectedIndex ? Times.Once() : Times.Never();
|
||||
servicesList[i].Verify(mock => mock.RefreshMetadata(It.IsAny<BaseItem>(), It.IsAny<MetadataRefreshOptions>(), It.IsAny<CancellationToken>()), times);
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
public async Task RefreshSingleItem_RefreshMetadata_WhenServiceFound(bool serviceFound)
|
||||
{
|
||||
var item = new Movie();
|
||||
|
||||
var servicesList = new[] { MockIMetadataService(false, serviceFound) };
|
||||
|
||||
using var providerManager = GetProviderManager();
|
||||
AddParts(providerManager, metadataServices: servicesList.Select(s => s.Object).ToArray());
|
||||
|
||||
var refreshOptions = new MetadataRefreshOptions(Mock.Of<IDirectoryService>(MockBehavior.Strict));
|
||||
var actual = await providerManager.RefreshSingleItem(item, refreshOptions, CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
var expectedResult = serviceFound ? ItemUpdateType.MetadataDownload : ItemUpdateType.None;
|
||||
Assert.Equal(expectedResult, actual);
|
||||
}
|
||||
|
||||
public static TheoryData<int, int[]?, int[]?, int?[]?, int[]> GetImageProvidersOrderData()
|
||||
=> new()
|
||||
{
|
||||
{ 3, null, null, null, new[] { 0, 1, 2 } }, // no order options set
|
||||
|
||||
// library options ordering
|
||||
{ 3, Array.Empty<int>(), null, null, new[] { 0, 1, 2 } }, // no order provided
|
||||
{ 3, new[] { 1 }, null, null, new[] { 1, 0, 2 } }, // one item in order
|
||||
{ 3, new[] { 2, 1, 0 }, null, null, new[] { 2, 1, 0 } }, // full reverse order
|
||||
|
||||
// server options ordering
|
||||
{ 3, null, Array.Empty<int>(), null, new[] { 0, 1, 2 } }, // no order provided
|
||||
{ 3, null, new[] { 1 }, null, new[] { 1, 0, 2 } }, // one item in order
|
||||
{ 3, null, new[] { 2, 1, 0 }, null, new[] { 2, 1, 0 } }, // full reverse order
|
||||
|
||||
// IHasOrder ordering
|
||||
{ 3, null, null, new int?[] { null, 1, null }, new[] { 1, 0, 2 } }, // one item with defined order
|
||||
{ 3, null, null, new int?[] { 2, 1, 0 }, new[] { 2, 1, 0 } }, // full reverse order
|
||||
|
||||
// multiple orders set
|
||||
{ 3, new[] { 1 }, new[] { 2, 0, 1 }, null, new[] { 1, 0, 2 } }, // partial library order first, server order ignored
|
||||
{ 3, new[] { 1 }, null, new int?[] { 2, 0, 1 }, new[] { 1, 2, 0 } }, // library order first, then orderby
|
||||
{ 3, new[] { 2, 1, 0 }, new[] { 1, 2, 0 }, new int?[] { 2, 0, 1 }, new[] { 2, 1, 0 } }, // library order wins
|
||||
};
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(GetImageProvidersOrderData))]
|
||||
public void GetImageProviders_ProviderOrder_MatchesExpected(int providerCount, int[]? libraryOrder, int[]? serverOrder, int?[]? hasOrderOrder, int[] expectedOrder)
|
||||
{
|
||||
var item = new Movie();
|
||||
|
||||
var nameProvider = new Func<int, string>(i => "Provider" + i);
|
||||
|
||||
var providerList = new List<IImageProvider>();
|
||||
for (var i = 0; i < providerCount; i++)
|
||||
{
|
||||
var order = hasOrderOrder?[i];
|
||||
providerList.Add(MockIImageProvider<ILocalImageProvider>(nameProvider(i), item, order: order));
|
||||
}
|
||||
|
||||
var libraryOptions = CreateLibraryOptions(item.GetType().Name, imageFetcherOrder: libraryOrder?.Select(nameProvider).ToArray());
|
||||
var serverConfiguration = CreateServerConfiguration(item.GetType().Name, imageFetcherOrder: serverOrder?.Select(nameProvider).ToArray());
|
||||
|
||||
using var providerManager = GetProviderManager(serverConfiguration: serverConfiguration, libraryOptions: libraryOptions);
|
||||
AddParts(providerManager, imageProviders: providerList);
|
||||
|
||||
var refreshOptions = new ImageRefreshOptions(Mock.Of<IDirectoryService>(MockBehavior.Strict));
|
||||
var actualProviders = providerManager.GetImageProviders(item, refreshOptions).ToList();
|
||||
|
||||
Assert.Equal(providerList.Count, actualProviders.Count);
|
||||
var actualOrder = actualProviders.Select(i => providerList.IndexOf(i)).ToArray();
|
||||
Assert.Equal(expectedOrder, actualOrder);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(true, false, true)]
|
||||
[InlineData(false, false, false)]
|
||||
[InlineData(true, true, false)]
|
||||
public void GetImageProviders_CanRefreshImagesBasic_WhenSupportsWithoutError(bool supports, bool errorOnSupported, bool expected)
|
||||
{
|
||||
GetImageProviders_CanRefreshImages_Tester(nameof(IImageProvider), supports, expected, errorOnSupported: errorOnSupported);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(nameof(ILocalImageProvider), false, true)]
|
||||
[InlineData(nameof(ILocalImageProvider), true, true)]
|
||||
[InlineData(nameof(IImageProvider), false, false)]
|
||||
[InlineData(nameof(IImageProvider), true, true)]
|
||||
public void GetImageProviders_CanRefreshImagesLocked_WhenLocalOrFullRefresh(string providerType, bool fullRefresh, bool expected)
|
||||
{
|
||||
GetImageProviders_CanRefreshImages_Tester(providerType, true, expected, itemLocked: true, fullRefresh: fullRefresh);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(nameof(ILocalImageProvider), false, true)]
|
||||
[InlineData(nameof(IRemoteImageProvider), true, true)]
|
||||
[InlineData(nameof(IDynamicImageProvider), true, true)]
|
||||
[InlineData(nameof(IRemoteImageProvider), false, false)]
|
||||
[InlineData(nameof(IDynamicImageProvider), false, false)]
|
||||
public void GetImageProviders_CanRefreshImagesBaseItemEnabled_WhenLocalOrEnabled(string providerType, bool enabled, bool expected)
|
||||
{
|
||||
GetImageProviders_CanRefreshImages_Tester(providerType, true, expected, baseItemEnabled: enabled);
|
||||
}
|
||||
|
||||
private static void GetImageProviders_CanRefreshImages_Tester(
|
||||
string providerType,
|
||||
bool supports,
|
||||
bool expected,
|
||||
bool errorOnSupported = false,
|
||||
bool itemLocked = false,
|
||||
bool fullRefresh = false,
|
||||
bool baseItemEnabled = true)
|
||||
{
|
||||
var item = new Movie
|
||||
{
|
||||
IsLocked = itemLocked
|
||||
};
|
||||
|
||||
var providerName = "provider";
|
||||
IImageProvider provider = providerType switch
|
||||
{
|
||||
"IImageProvider" => MockIImageProvider<IImageProvider>(providerName, item, supports: supports, errorOnSupported: errorOnSupported),
|
||||
"ILocalImageProvider" => MockIImageProvider<ILocalImageProvider>(providerName, item, supports: supports, errorOnSupported: errorOnSupported),
|
||||
"IRemoteImageProvider" => MockIImageProvider<IRemoteImageProvider>(providerName, item, supports: supports, errorOnSupported: errorOnSupported),
|
||||
"IDynamicImageProvider" => MockIImageProvider<IDynamicImageProvider>(providerName, item, supports: supports, errorOnSupported: errorOnSupported),
|
||||
_ => throw new ArgumentException("Unexpected provider type")
|
||||
};
|
||||
|
||||
var refreshOptions = new ImageRefreshOptions(Mock.Of<IDirectoryService>(MockBehavior.Strict))
|
||||
{
|
||||
ImageRefreshMode = fullRefresh ? MetadataRefreshMode.FullRefresh : MetadataRefreshMode.Default
|
||||
};
|
||||
|
||||
var baseItemManager = new Mock<IBaseItemManager>(MockBehavior.Strict);
|
||||
baseItemManager.Setup(i => i.IsImageFetcherEnabled(item, It.IsAny<TypeOptions>(), providerName))
|
||||
.Returns(baseItemEnabled);
|
||||
|
||||
using var providerManager = GetProviderManager(baseItemManager: baseItemManager.Object);
|
||||
AddParts(providerManager, imageProviders: new[] { provider });
|
||||
|
||||
var actualProviders = providerManager.GetImageProviders(item, refreshOptions).ToArray();
|
||||
|
||||
Assert.Equal(expected ? 1 : 0, actualProviders.Length);
|
||||
}
|
||||
|
||||
public static TheoryData<string[], int[]?, int[]?, int[]?, int[]?, int?[]?, int[]> GetMetadataProvidersOrderData()
|
||||
{
|
||||
var l = nameof(ILocalMetadataProvider);
|
||||
var r = nameof(IRemoteMetadataProvider);
|
||||
return new()
|
||||
{
|
||||
{ new[] { l, l, r, r }, null, null, null, null, null, new[] { 0, 1, 2, 3 } }, // no order options set
|
||||
|
||||
// library options ordering
|
||||
{ new[] { l, l, r, r }, Array.Empty<int>(), Array.Empty<int>(), null, null, null, new[] { 0, 1, 2, 3 } }, // no order provided
|
||||
// local only
|
||||
{ new[] { r, l, l, l }, new[] { 2 }, null, null, null, null, new[] { 2, 0, 1, 3 } }, // one item in order
|
||||
{ new[] { r, l, l, l }, new[] { 3, 2, 1 }, null, null, null, null, new[] { 3, 2, 1, 0 } }, // full reverse order
|
||||
// remote only
|
||||
{ new[] { l, r, r, r }, null, new[] { 2 }, null, null, null, new[] { 2, 0, 1, 3 } }, // one item in order
|
||||
{ new[] { l, r, r, r }, null, new[] { 3, 2, 1 }, null, null, null, new[] { 3, 2, 1, 0 } }, // full reverse order
|
||||
// local and remote, note that results will be interleaved (odd but expected)
|
||||
{ new[] { l, l, r, r }, new[] { 1 }, new[] { 3 }, null, null, null, new[] { 1, 3, 0, 2 } }, // one item in each order
|
||||
{ new[] { l, l, l, r, r, r }, new[] { 2, 1, 0 }, new[] { 5, 4, 3 }, null, null, null, new[] { 2, 5, 1, 4, 0, 3 } }, // full reverse order
|
||||
|
||||
// // server options ordering
|
||||
{ new[] { l, l, r, r }, null, null, Array.Empty<int>(), Array.Empty<int>(), null, new[] { 0, 1, 2, 3 } }, // no order provided
|
||||
// local only
|
||||
{ new[] { r, l, l, l }, null, null, new[] { 2 }, null, null, new[] { 2, 0, 1, 3 } }, // one item in order
|
||||
{ new[] { r, l, l, l }, null, null, new[] { 3, 2, 1 }, null, null, new[] { 3, 2, 1, 0 } }, // full reverse order
|
||||
// remote only
|
||||
{ new[] { l, r, r, r }, null, null, null, new[] { 2 }, null, new[] { 2, 0, 1, 3 } }, // one item in order
|
||||
{ new[] { l, r, r, r }, null, null, null, new[] { 3, 2, 1 }, null, new[] { 3, 2, 1, 0 } }, // full reverse order
|
||||
// local and remote, note that results will be interleaved (odd but expected)
|
||||
{ new[] { l, l, r, r }, null, null, new[] { 1 }, new[] { 3 }, null, new[] { 1, 3, 0, 2 } }, // one item in each order
|
||||
{ new[] { l, l, l, r, r, r }, null, null, new[] { 2, 1, 0 }, new[] { 5, 4, 3 }, null, new[] { 2, 5, 1, 4, 0, 3 } }, // full reverse order
|
||||
|
||||
// IHasOrder ordering (not interleaved, doesn't care about types)
|
||||
{ new[] { l, l, r, r }, null, null, null, null, new int?[] { 2, null, 1, null }, new[] { 2, 0, 1, 3 } }, // partially defined
|
||||
{ new[] { l, l, r, r }, null, null, null, null, new int?[] { 3, 2, 1, 0 }, new[] { 3, 2, 1, 0 } }, // full reverse order
|
||||
|
||||
// multiple orders set
|
||||
{ new[] { l, l, l, r, r, r }, new[] { 1 }, new[] { 4 }, new[] { 2, 1, 0 }, new[] { 5, 4, 3 }, null, new[] { 1, 4, 0, 2, 3, 5 } }, // partial library order first, server order ignored
|
||||
{ new[] { l, l, l }, new[] { 1 }, null, null, null, new int?[] { 2, 0, 1 }, new[] { 1, 2, 0 } }, // library order first, then orderby
|
||||
{ new[] { l, l, l, r, r, r }, new[] { 2, 1, 0 }, new[] { 5, 4, 3 }, new[] { 1, 2, 0 }, new[] { 4, 5, 3 }, new int?[] { 5, 4, 1, 6, 3, 2 }, new[] { 2, 5, 4, 1, 0, 3 } }, // library order wins (with orderby between local/remote)
|
||||
};
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(GetMetadataProvidersOrderData))]
|
||||
public void GetMetadataProviders_ProviderOrder_MatchesExpected(
|
||||
string[] providers,
|
||||
int[]? libraryLocalOrder,
|
||||
int[]? libraryRemoteOrder,
|
||||
int[]? serverLocalOrder,
|
||||
int[]? serverRemoteOrder,
|
||||
int?[]? hasOrderOrder,
|
||||
int[] expectedOrder)
|
||||
{
|
||||
var item = new MetadataTestItem();
|
||||
|
||||
var nameProvider = new Func<int, string>(i => "Provider" + i);
|
||||
|
||||
var providerList = new List<IMetadataProvider<MetadataTestItem>>();
|
||||
for (var i = 0; i < providers.Length; i++)
|
||||
{
|
||||
var order = hasOrderOrder?[i];
|
||||
providerList.Add(MockIMetadataProviderMapper<MetadataTestItem, MetadataTestItemInfo>(providers[i], nameProvider(i), order: order));
|
||||
}
|
||||
|
||||
var libraryOptions = CreateLibraryOptions(
|
||||
item.GetType().Name,
|
||||
localMetadataReaderOrder: libraryLocalOrder?.Select(nameProvider).ToArray(),
|
||||
metadataFetcherOrder: libraryRemoteOrder?.Select(nameProvider).ToArray());
|
||||
var serverConfiguration = CreateServerConfiguration(
|
||||
item.GetType().Name,
|
||||
localMetadataReaderOrder: serverLocalOrder?.Select(nameProvider).ToArray(),
|
||||
metadataFetcherOrder: serverRemoteOrder?.Select(nameProvider).ToArray());
|
||||
|
||||
var baseItemManager = new Mock<IBaseItemManager>(MockBehavior.Strict);
|
||||
baseItemManager.Setup(i => i.IsMetadataFetcherEnabled(item, It.IsAny<TypeOptions>(), It.IsAny<string>()))
|
||||
.Returns(true);
|
||||
|
||||
using var providerManager = GetProviderManager(serverConfiguration: serverConfiguration, baseItemManager: baseItemManager.Object);
|
||||
AddParts(providerManager, metadataProviders: providerList);
|
||||
|
||||
var actualProviders = providerManager.GetMetadataProviders<MetadataTestItem>(item, libraryOptions).ToList();
|
||||
|
||||
Assert.Equal(providerList.Count, actualProviders.Count);
|
||||
var actualOrder = actualProviders.Select(i => providerList.IndexOf(i)).ToArray();
|
||||
Assert.Equal(expectedOrder, actualOrder);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(nameof(IMetadataProvider))]
|
||||
[InlineData(nameof(ILocalMetadataProvider))]
|
||||
[InlineData(nameof(IRemoteMetadataProvider))]
|
||||
[InlineData(nameof(ICustomMetadataProvider))]
|
||||
public void GetMetadataProviders_CanRefreshMetadataBasic_ReturnsTrue(string providerType)
|
||||
{
|
||||
GetMetadataProviders_CanRefreshMetadata_Tester(providerType, true);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(nameof(ILocalMetadataProvider), false, true)]
|
||||
[InlineData(nameof(IRemoteMetadataProvider), false, false)]
|
||||
[InlineData(nameof(ICustomMetadataProvider), false, false)]
|
||||
[InlineData(nameof(ILocalMetadataProvider), true, true)]
|
||||
[InlineData(nameof(ICustomMetadataProvider), true, false)]
|
||||
public void GetMetadataProviders_CanRefreshMetadataLocked_WhenLocalOrForced(string providerType, bool forced, bool expected)
|
||||
{
|
||||
GetMetadataProviders_CanRefreshMetadata_Tester(providerType, expected, itemLocked: true, providerForced: forced);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(nameof(ILocalMetadataProvider), false, true)]
|
||||
[InlineData(nameof(ICustomMetadataProvider), false, true)]
|
||||
[InlineData(nameof(IRemoteMetadataProvider), false, false)]
|
||||
[InlineData(nameof(IRemoteMetadataProvider), true, true)]
|
||||
public void GetMetadataProviders_CanRefreshMetadataBaseItemEnabled_WhenEnabledOrNotRemote(string providerType, bool baseItemEnabled, bool expected)
|
||||
{
|
||||
GetMetadataProviders_CanRefreshMetadata_Tester(providerType, expected, baseItemEnabled: baseItemEnabled);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(nameof(IRemoteMetadataProvider), false, true)]
|
||||
[InlineData(nameof(ICustomMetadataProvider), false, true)]
|
||||
[InlineData(nameof(ILocalMetadataProvider), false, false)]
|
||||
[InlineData(nameof(ILocalMetadataProvider), true, true)]
|
||||
public void GetMetadataProviders_CanRefreshMetadataSupportsLocal_WhenSupportsOrNotLocal(string providerType, bool supportsLocalMetadata, bool expected)
|
||||
{
|
||||
GetMetadataProviders_CanRefreshMetadata_Tester(providerType, expected, supportsLocalMetadata: supportsLocalMetadata);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(nameof(ICustomMetadataProvider), true)]
|
||||
[InlineData(nameof(IRemoteMetadataProvider), true)]
|
||||
[InlineData(nameof(ILocalMetadataProvider), false)]
|
||||
public void GetMetadataProviders_CanRefreshMetadataOwned_WhenNotLocal(string providerType, bool expected)
|
||||
{
|
||||
GetMetadataProviders_CanRefreshMetadata_Tester(providerType, expected, ownedItem: true);
|
||||
}
|
||||
|
||||
private static void GetMetadataProviders_CanRefreshMetadata_Tester(
|
||||
string providerType,
|
||||
bool expected,
|
||||
bool itemLocked = false,
|
||||
bool baseItemEnabled = true,
|
||||
bool providerForced = false,
|
||||
bool supportsLocalMetadata = true,
|
||||
bool ownedItem = false)
|
||||
{
|
||||
var item = new MetadataTestItem
|
||||
{
|
||||
IsLocked = itemLocked,
|
||||
OwnerId = ownedItem ? Guid.NewGuid() : Guid.Empty,
|
||||
EnableLocalMetadata = supportsLocalMetadata
|
||||
};
|
||||
|
||||
var providerName = "provider";
|
||||
var provider = MockIMetadataProviderMapper<MetadataTestItem, MetadataTestItemInfo>(providerType, providerName, forced: providerForced);
|
||||
|
||||
var baseItemManager = new Mock<IBaseItemManager>(MockBehavior.Strict);
|
||||
baseItemManager.Setup(i => i.IsMetadataFetcherEnabled(item, It.IsAny<TypeOptions>(), providerName))
|
||||
.Returns(baseItemEnabled);
|
||||
|
||||
using var providerManager = GetProviderManager(baseItemManager: baseItemManager.Object);
|
||||
AddParts(providerManager, metadataProviders: new[] { provider });
|
||||
|
||||
var actualProviders = providerManager.GetMetadataProviders<MetadataTestItem>(item, new LibraryOptions()).ToArray();
|
||||
|
||||
Assert.Equal(expected ? 1 : 0, actualProviders.Length);
|
||||
}
|
||||
|
||||
private static Mock<IMetadataService> MockIMetadataService(bool refreshPrimary, bool canRefresh, int order = 0)
|
||||
{
|
||||
var service = new Mock<IMetadataService>(MockBehavior.Strict);
|
||||
service.Setup(s => s.Order)
|
||||
.Returns(order);
|
||||
service.Setup(s => s.CanRefreshPrimary(It.IsAny<Type>()))
|
||||
.Returns(refreshPrimary);
|
||||
service.Setup(s => s.CanRefresh(It.IsAny<BaseItem>()))
|
||||
.Returns(canRefresh);
|
||||
service.Setup(s => s.RefreshMetadata(It.IsAny<BaseItem>(), It.IsAny<MetadataRefreshOptions>(), It.IsAny<CancellationToken>()))
|
||||
.Returns(Task.FromResult(ItemUpdateType.MetadataDownload));
|
||||
return service;
|
||||
}
|
||||
|
||||
private static IImageProvider MockIImageProvider<TProviderType>(string name, BaseItem expectedType, bool supports = true, int? order = null, bool errorOnSupported = false)
|
||||
where TProviderType : class, IImageProvider
|
||||
{
|
||||
Mock<IHasOrder>? hasOrder = null;
|
||||
if (order != null)
|
||||
{
|
||||
hasOrder = new Mock<IHasOrder>(MockBehavior.Strict);
|
||||
hasOrder.Setup(i => i.Order)
|
||||
.Returns((int)order);
|
||||
}
|
||||
|
||||
var provider = hasOrder == null
|
||||
? new Mock<TProviderType>(MockBehavior.Strict)
|
||||
: hasOrder.As<TProviderType>();
|
||||
provider.Setup(p => p.Name)
|
||||
.Returns(name);
|
||||
if (errorOnSupported)
|
||||
{
|
||||
provider.Setup(p => p.Supports(It.IsAny<BaseItem>()))
|
||||
.Throws(new ArgumentException("Provider threw exception on Supports(item)"));
|
||||
}
|
||||
else
|
||||
{
|
||||
provider.Setup(p => p.Supports(expectedType))
|
||||
.Returns(supports);
|
||||
}
|
||||
|
||||
return provider.Object;
|
||||
}
|
||||
|
||||
private static IMetadataProvider<TItemType> MockIMetadataProviderMapper<TItemType, TLookupInfoType>(string typeName, string providerName, int? order = null, bool forced = false)
|
||||
where TItemType : BaseItem, IHasLookupInfo<TLookupInfoType>
|
||||
where TLookupInfoType : ItemLookupInfo, new()
|
||||
=> typeName switch
|
||||
{
|
||||
"ILocalMetadataProvider" => MockIMetadataProvider<ILocalMetadataProvider<TItemType>, TItemType>(providerName, order, forced),
|
||||
"IRemoteMetadataProvider" => MockIMetadataProvider<IRemoteMetadataProvider<TItemType, TLookupInfoType>, TItemType>(providerName, order, forced),
|
||||
"ICustomMetadataProvider" => MockIMetadataProvider<ICustomMetadataProvider<TItemType>, TItemType>(providerName, order, forced),
|
||||
_ => MockIMetadataProvider<IMetadataProvider<TItemType>, TItemType>(providerName, order, forced)
|
||||
};
|
||||
|
||||
private static IMetadataProvider<TItemType> MockIMetadataProvider<TProviderType, TItemType>(string name, int? order = null, bool forced = false)
|
||||
where TProviderType : class, IMetadataProvider<TItemType>
|
||||
where TItemType : BaseItem
|
||||
{
|
||||
Mock<IForcedProvider>? forcedProvider = null;
|
||||
if (forced)
|
||||
{
|
||||
forcedProvider = new Mock<IForcedProvider>();
|
||||
}
|
||||
|
||||
Mock<IHasOrder>? hasOrder = null;
|
||||
if (order != null)
|
||||
{
|
||||
hasOrder = forcedProvider == null ? new Mock<IHasOrder>() : forcedProvider.As<IHasOrder>();
|
||||
hasOrder.Setup(i => i.Order)
|
||||
.Returns((int)order);
|
||||
}
|
||||
|
||||
var provider = hasOrder == null
|
||||
? new Mock<TProviderType>(MockBehavior.Strict)
|
||||
: hasOrder.As<TProviderType>();
|
||||
provider.Setup(p => p.Name)
|
||||
.Returns(name);
|
||||
|
||||
return provider.Object;
|
||||
}
|
||||
|
||||
private static LibraryOptions CreateLibraryOptions(
|
||||
string typeName,
|
||||
string[]? imageFetcherOrder = null,
|
||||
string[]? localMetadataReaderOrder = null,
|
||||
string[]? metadataFetcherOrder = null)
|
||||
{
|
||||
var libraryOptions = new LibraryOptions
|
||||
{
|
||||
LocalMetadataReaderOrder = localMetadataReaderOrder
|
||||
};
|
||||
|
||||
// only create type options if populating it with something
|
||||
if (imageFetcherOrder != null || metadataFetcherOrder != null)
|
||||
{
|
||||
imageFetcherOrder ??= Array.Empty<string>();
|
||||
metadataFetcherOrder ??= Array.Empty<string>();
|
||||
|
||||
libraryOptions.TypeOptions = new[]
|
||||
{
|
||||
new TypeOptions
|
||||
{
|
||||
Type = typeName,
|
||||
ImageFetcherOrder = imageFetcherOrder,
|
||||
MetadataFetcherOrder = metadataFetcherOrder
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return libraryOptions;
|
||||
}
|
||||
|
||||
private static ServerConfiguration CreateServerConfiguration(
|
||||
string typeName,
|
||||
string[]? imageFetcherOrder = null,
|
||||
string[]? localMetadataReaderOrder = null,
|
||||
string[]? metadataFetcherOrder = null)
|
||||
{
|
||||
var serverConfiguration = new ServerConfiguration();
|
||||
|
||||
// only create type options if populating it with something
|
||||
if (imageFetcherOrder != null || localMetadataReaderOrder != null || metadataFetcherOrder != null)
|
||||
{
|
||||
imageFetcherOrder ??= Array.Empty<string>();
|
||||
localMetadataReaderOrder ??= Array.Empty<string>();
|
||||
metadataFetcherOrder ??= Array.Empty<string>();
|
||||
|
||||
serverConfiguration.MetadataOptions = new[]
|
||||
{
|
||||
new MetadataOptions
|
||||
{
|
||||
ItemType = typeName,
|
||||
ImageFetcherOrder = imageFetcherOrder,
|
||||
LocalMetadataReaderOrder = localMetadataReaderOrder,
|
||||
MetadataFetcherOrder = metadataFetcherOrder
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return serverConfiguration;
|
||||
}
|
||||
|
||||
private static ProviderManager GetProviderManager(
|
||||
ServerConfiguration? serverConfiguration = null,
|
||||
LibraryOptions? libraryOptions = null,
|
||||
IBaseItemManager? baseItemManager = null)
|
||||
{
|
||||
var serverConfigurationManager = new Mock<IServerConfigurationManager>(MockBehavior.Strict);
|
||||
serverConfigurationManager.Setup(i => i.Configuration)
|
||||
.Returns(serverConfiguration ?? new ServerConfiguration());
|
||||
|
||||
var libraryManager = new Mock<ILibraryManager>(MockBehavior.Strict);
|
||||
libraryManager.Setup(i => i.GetLibraryOptions(It.IsAny<BaseItem>()))
|
||||
.Returns(libraryOptions ?? new LibraryOptions());
|
||||
|
||||
var providerManager = new ProviderManager(
|
||||
Mock.Of<IHttpClientFactory>(),
|
||||
Mock.Of<ISubtitleManager>(),
|
||||
serverConfigurationManager.Object,
|
||||
Mock.Of<ILibraryMonitor>(),
|
||||
_logger,
|
||||
Mock.Of<IFileSystem>(),
|
||||
Mock.Of<IServerApplicationPaths>(),
|
||||
libraryManager.Object,
|
||||
baseItemManager!);
|
||||
|
||||
return providerManager;
|
||||
}
|
||||
|
||||
private static void AddParts(
|
||||
ProviderManager providerManager,
|
||||
IEnumerable<IImageProvider>? imageProviders = null,
|
||||
IEnumerable<IMetadataService>? metadataServices = null,
|
||||
IEnumerable<IMetadataProvider>? metadataProviders = null,
|
||||
IEnumerable<IMetadataSaver>? metadataSavers = null,
|
||||
IEnumerable<IExternalId>? externalIds = null)
|
||||
{
|
||||
imageProviders ??= Array.Empty<IImageProvider>();
|
||||
metadataServices ??= Array.Empty<IMetadataService>();
|
||||
metadataProviders ??= Array.Empty<IMetadataProvider>();
|
||||
metadataSavers ??= Array.Empty<IMetadataSaver>();
|
||||
externalIds ??= Array.Empty<IExternalId>();
|
||||
|
||||
providerManager.AddParts(imageProviders, metadataServices, metadataProviders, metadataSavers, externalIds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Simple <see cref="BaseItem"/> extension to make SupportsLocalMetadata directly settable.
|
||||
/// </summary>
|
||||
internal class MetadataTestItem : BaseItem, IHasLookupInfo<MetadataTestItemInfo>
|
||||
{
|
||||
public bool EnableLocalMetadata { get; set; } = true;
|
||||
|
||||
public override bool SupportsLocalMetadata => EnableLocalMetadata;
|
||||
|
||||
public MetadataTestItemInfo GetLookupInfo()
|
||||
{
|
||||
return GetItemLookupInfo<MetadataTestItemInfo>();
|
||||
}
|
||||
}
|
||||
|
||||
internal class MetadataTestItemInfo : ItemLookupInfo
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user