Skip to content

Commit

Permalink
adaptions for 10.9
Browse files Browse the repository at this point in the history
  • Loading branch information
BobSilent committed Feb 27, 2024
1 parent 60b3018 commit a5c58d1
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 57 deletions.
6 changes: 4 additions & 2 deletions Jellyfin.Plugin.Tvdb/Jellyfin.Plugin.Tvdb.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Nullable>enable</Nullable>
Expand All @@ -24,7 +24,9 @@
<PackageReference Include="Jellyfin.Controller" Version="10.*-*" />
<PackageReference Include="Jellyfin.Common" Version="10.*-*" />
<PackageReference Include="Jellyfin.Model" Version="10.*-*" />
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Tvdb.Sdk" Version="4.7.9" />
</ItemGroup>

Expand Down
13 changes: 9 additions & 4 deletions Jellyfin.Plugin.Tvdb/Providers/TvdbEpisodeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;

using Jellyfin.Data.Enums;
using Jellyfin.Extensions;

using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Providers;

using Microsoft.Extensions.Logging;

using Tvdb.Sdk;

namespace Jellyfin.Plugin.Tvdb.Providers
Expand Down Expand Up @@ -271,7 +276,7 @@ private static MetadataResult<Episode> MapEpisodeToResult(EpisodeInfo id, Episod
{
result.AddPerson(new PersonInfo
{
Type = PersonType.Actor,
Type = PersonKind.Actor,
Name = currentActor.PersonName,
Role = currentActor.Name
});
Expand All @@ -280,23 +285,23 @@ private static MetadataResult<Episode> MapEpisodeToResult(EpisodeInfo id, Episod
{
result.AddPerson(new PersonInfo
{
Type = PersonType.Director,
Type = PersonKind.Director,
Name = currentActor.PersonName
});
}
else if (string.Equals(currentActor.PeopleType, "Writer", StringComparison.OrdinalIgnoreCase))
{
result.AddPerson(new PersonInfo
{
Type = PersonType.Writer,
Type = PersonKind.Writer,
Name = currentActor.PersonName
});
}
else if (string.Equals(currentActor.PeopleType, "Guest Star", StringComparison.OrdinalIgnoreCase))
{
result.AddPerson(new PersonInfo
{
Type = PersonType.GuestStar,
Type = PersonKind.GuestStar,
Name = currentActor.PersonName,
Role = currentActor.Name
});
Expand Down
47 changes: 19 additions & 28 deletions Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,29 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

using Jellyfin.Data.Events;

using MediaBrowser.Controller.BaseItemManager;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Globalization;

using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

using Tvdb.Sdk;
using Episode = MediaBrowser.Controller.Entities.TV.Episode;
using MetadataProvider = MediaBrowser.Model.Entities.MetadataProvider;
using Season = MediaBrowser.Controller.Entities.TV.Season;
using Series = MediaBrowser.Controller.Entities.TV.Series;

namespace Jellyfin.Plugin.Tvdb.Providers
{
/// <summary>
/// Tvdb Missing Episode provider.
/// </summary>
public class TvdbMissingEpisodeProvider : IServerEntryPoint
public class TvdbMissingEpisodeProvider : IHostedService
{
/// <summary>
/// The provider name.
Expand Down Expand Up @@ -65,7 +66,7 @@ public TvdbMissingEpisodeProvider(
}

/// <inheritdoc />
public Task RunAsync()
public Task StartAsync(CancellationToken cancellationToken)
{
_providerManager.RefreshCompleted += OnProviderManagerRefreshComplete;
_libraryManager.ItemUpdated += OnLibraryManagerItemUpdated;
Expand All @@ -75,24 +76,13 @@ public Task RunAsync()
}

/// <inheritdoc />
public void Dispose()
public Task StopAsync(CancellationToken cancellationToken)
{
Dispose(true);
GC.SuppressFinalize(this);
}
_providerManager.RefreshCompleted -= OnProviderManagerRefreshComplete;
_libraryManager.ItemUpdated -= OnLibraryManagerItemUpdated;
_libraryManager.ItemRemoved -= OnLibraryManagerItemRemoved;

/// <summary>
/// Disposes managed resources.
/// </summary>
/// <param name="disposing">A value indicating whether managed resources should be disposed.</param>
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
_providerManager.RefreshCompleted -= OnProviderManagerRefreshComplete;
_libraryManager.ItemUpdated -= OnLibraryManagerItemUpdated;
_libraryManager.ItemRemoved -= OnLibraryManagerItemRemoved;
}
return Task.CompletedTask;
}

private static bool EpisodeExists(EpisodeBaseRecord episodeRecord, IReadOnlyList<Episode> existingEpisodes)
Expand Down Expand Up @@ -127,7 +117,7 @@ private bool IsEnabledForLibrary(BaseItem item)
}

var libraryOptions = _libraryManager.GetLibraryOptions(series);
return _baseItemManager.IsMetadataFetcherEnabled(series, libraryOptions, ProviderName);
return _baseItemManager.IsMetadataFetcherEnabled(series, libraryOptions.GetTypeOptions(item.GetType().Name), ProviderName);
}

// TODO use the new async events when provider manager is updated
Expand Down Expand Up @@ -179,12 +169,13 @@ private async Task HandleSeries(Series series)
break;
case Episode episode:
var seasonNumber = episode.ParentIndexNumber ?? 1;
if (!existingEpisodes.ContainsKey(seasonNumber))
if (!existingEpisodes.TryGetValue(seasonNumber, out var value))
{
existingEpisodes[seasonNumber] = new List<Episode>();
value = new List<Episode>();
existingEpisodes[seasonNumber] = value;
}

existingEpisodes[seasonNumber].Add(episode);
value.Add(episode);
break;
}
}
Expand Down Expand Up @@ -219,7 +210,7 @@ private async Task HandleSeason(Season season)
foreach (var episodeRecord in seasonEpisodes)
{
var foundEpisodes = existingEpisodes.Where(episode => EpisodeEquals(episode, episodeRecord)).ToList();
if (foundEpisodes.Any())
if (foundEpisodes.Count != 0)
{
// So we have at least one existing episode for our episodeRecord
var physicalEpisodes = foundEpisodes.Where(e => !e.IsVirtualItem);
Expand Down
9 changes: 5 additions & 4 deletions Jellyfin.Plugin.Tvdb/Providers/TvdbSeasonImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Providers;

using Microsoft.Extensions.Logging;
using Tvdb.Sdk;
using RatingType = MediaBrowser.Model.Dto.RatingType;

namespace Jellyfin.Plugin.Tvdb.Providers
{
Expand Down Expand Up @@ -76,8 +77,8 @@ public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, Cancell

var seasonInfo = await _tvdbClientManager.GetSeasonByIdAsync(Convert.ToInt32(seasonTvdbId, CultureInfo.InvariantCulture), language, cancellationToken).ConfigureAwait(false);
var seasonImages = seasonInfo.Artwork;
var languages = _tvdbClientManager.GetLanguagesAsync(CancellationToken.None).Result;
var artworkTypes = _tvdbClientManager.GetArtworkTypeAsync(CancellationToken.None).Result;
var languages = await _tvdbClientManager.GetLanguagesAsync(cancellationToken).ConfigureAwait(false);
var artworkTypes = await _tvdbClientManager.GetArtworkTypeAsync(cancellationToken).ConfigureAwait(false);

foreach (var image in seasonImages)
{
Expand Down
11 changes: 6 additions & 5 deletions Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesImageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Providers;

using Microsoft.Extensions.Logging;
using Tvdb.Sdk;
using RatingType = MediaBrowser.Model.Dto.RatingType;
using Series = MediaBrowser.Controller.Entities.TV.Series;

namespace Jellyfin.Plugin.Tvdb.Providers
{
Expand Down Expand Up @@ -69,8 +70,8 @@ public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, Cancell
var tvdbId = Convert.ToInt32(item.GetProviderId(TvdbPlugin.ProviderId), CultureInfo.InvariantCulture);
var seriesInfo = await _tvdbClientManager.GetSeriesImagesAsync(tvdbId, language, cancellationToken).ConfigureAwait(false);
var seriesImages = seriesInfo.Artworks;
var languages = _tvdbClientManager.GetLanguagesAsync(CancellationToken.None).Result;
var artworkTypes = _tvdbClientManager.GetArtworkTypeAsync(CancellationToken.None).Result;
var languages = await _tvdbClientManager.GetLanguagesAsync(cancellationToken).ConfigureAwait(false);
var artworkTypes = await _tvdbClientManager.GetArtworkTypeAsync(cancellationToken).ConfigureAwait(false);
foreach (var image in seriesImages)
{
ImageType type;
Expand Down
9 changes: 7 additions & 2 deletions Jellyfin.Plugin.Tvdb/Providers/TvdbSeriesProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;

using Jellyfin.Data.Enums;

using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Providers;

using Microsoft.Extensions.Logging;

using Tvdb.Sdk;
using Series = MediaBrowser.Controller.Entities.TV.Series;

namespace Jellyfin.Plugin.Tvdb.Providers
{
Expand Down Expand Up @@ -422,7 +427,7 @@ private static void MapActorsToResult(MetadataResult<Series> result, IEnumerable
{
var personInfo = new PersonInfo
{
Type = PersonType.Actor,
Type = PersonKind.Actor,
Name = (actor.PersonName ?? string.Empty).Trim(),
Role = actor.Name
};
Expand Down
25 changes: 13 additions & 12 deletions Jellyfin.Plugin.Tvdb/TvdbPluginServiceRegistrator.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
using MediaBrowser.Common.Plugins;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Plugins;

using Microsoft.Extensions.DependencyInjection;

namespace Jellyfin.Plugin.Tvdb
namespace Jellyfin.Plugin.Tvdb;

/// <summary>
/// Register tvdb services.
/// </summary>
public class TvdbPluginServiceRegistrator : IPluginServiceRegistrator

Check failure on line 11 in Jellyfin.Plugin.Tvdb/TvdbPluginServiceRegistrator.cs

View workflow job for this annotation

GitHub Actions / call / test

The type or namespace name 'IPluginServiceRegistrator' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 11 in Jellyfin.Plugin.Tvdb/TvdbPluginServiceRegistrator.cs

View workflow job for this annotation

GitHub Actions / call / test

The type or namespace name 'IPluginServiceRegistrator' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 11 in Jellyfin.Plugin.Tvdb/TvdbPluginServiceRegistrator.cs

View workflow job for this annotation

GitHub Actions / call / build

The type or namespace name 'IPluginServiceRegistrator' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 11 in Jellyfin.Plugin.Tvdb/TvdbPluginServiceRegistrator.cs

View workflow job for this annotation

GitHub Actions / call / Analyze (csharp)

The type or namespace name 'IPluginServiceRegistrator' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 11 in Jellyfin.Plugin.Tvdb/TvdbPluginServiceRegistrator.cs

View workflow job for this annotation

GitHub Actions / call / Analyze (csharp)

The type or namespace name 'IPluginServiceRegistrator' could not be found (are you missing a using directive or an assembly reference?)
{
/// <summary>
/// Register tvdb services.
/// </summary>
public class TvdbPluginServiceRegistrator : IPluginServiceRegistrator
/// <inheritdoc />
public void RegisterServices(IServiceCollection serviceCollection, IServerApplicationHost applicationHost)
{
/// <inheritdoc />
public void RegisterServices(IServiceCollection serviceCollection)
{
serviceCollection.AddSingleton<TvdbClientManager>();
}
serviceCollection.AddSingleton<TvdbClientManager>();
}
}
}

0 comments on commit a5c58d1

Please sign in to comment.