mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-30 03:13:17 +01:00
add search methods to remote metadata providers
This commit is contained in:
@@ -7,6 +7,7 @@ using MediaBrowser.Controller.Localization;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Providers;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Providers.Movies;
|
||||
using System;
|
||||
@@ -42,6 +43,11 @@ namespace MediaBrowser.Providers.BoxSets
|
||||
Current = this;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(BoxSetInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
return new List<RemoteSearchResult>();
|
||||
}
|
||||
|
||||
public async Task<MetadataResult<BoxSet>> GetMetadata(BoxSetInfo id, CancellationToken cancellationToken)
|
||||
{
|
||||
var tmdbId = id.GetProviderId(MetadataProviders.Tmdb);
|
||||
@@ -282,5 +288,10 @@ namespace MediaBrowser.Providers.BoxSets
|
||||
public List<Part> parts { get; set; }
|
||||
public Images images { get; set; }
|
||||
}
|
||||
|
||||
public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,7 +586,7 @@ namespace MediaBrowser.Providers.Manager
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<SearchResult<TLookupType>>> GetRemoteSearchResults<TItemType, TLookupType>(RemoteSearchQuery<TLookupType> searchInfo,
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetRemoteSearchResults<TItemType, TLookupType>(RemoteSearchQuery<TLookupType> searchInfo,
|
||||
CancellationToken cancellationToken)
|
||||
where TItemType : BaseItem, new()
|
||||
where TLookupType : ItemLookupInfo
|
||||
@@ -623,7 +623,7 @@ namespace MediaBrowser.Providers.Manager
|
||||
}
|
||||
|
||||
// Nothing found
|
||||
return new List<SearchResult<TLookupType>>();
|
||||
return new List<RemoteSearchResult>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Linq;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
@@ -9,10 +8,12 @@ using MediaBrowser.Controller.Localization;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Providers;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -45,6 +46,11 @@ namespace MediaBrowser.Providers.Movies
|
||||
Current = this;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(MovieInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
return new List<RemoteSearchResult>();
|
||||
}
|
||||
|
||||
public Task<MetadataResult<Movie>> GetMetadata(MovieInfo info, CancellationToken cancellationToken)
|
||||
{
|
||||
return GetItemMetadata<Movie>(info, cancellationToken);
|
||||
@@ -549,5 +555,10 @@ namespace MediaBrowser.Providers.Movies
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Providers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -13,6 +16,11 @@ namespace MediaBrowser.Providers.Movies
|
||||
return MovieDbProvider.Current.GetItemMetadata<Trailer>(info, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(TrailerInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
return new List<RemoteSearchResult>();
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return MovieDbProvider.Current.Name; }
|
||||
@@ -31,5 +39,10 @@ namespace MediaBrowser.Providers.Movies
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Providers;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -15,7 +16,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Providers.Music
|
||||
{
|
||||
public class AudioDbAlbumProvider : IRemoteMetadataProvider<MusicAlbum,AlbumInfo>, IHasOrder
|
||||
public class AudioDbAlbumProvider : IRemoteMetadataProvider<MusicAlbum, AlbumInfo>, IHasOrder
|
||||
{
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
@@ -36,6 +37,11 @@ namespace MediaBrowser.Providers.Music
|
||||
Current = this;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(AlbumInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
return new List<RemoteSearchResult>();
|
||||
}
|
||||
|
||||
public async Task<MetadataResult<MusicAlbum>> GetMetadata(AlbumInfo info, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = new MetadataResult<MusicAlbum>();
|
||||
@@ -81,7 +87,7 @@ namespace MediaBrowser.Providers.Music
|
||||
item.SetProviderId(MetadataProviders.MusicBrainzAlbumArtist, result.strMusicBrainzArtistID);
|
||||
item.SetProviderId(MetadataProviders.MusicBrainzReleaseGroup, result.strMusicBrainzID);
|
||||
}
|
||||
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "TheAudioDB"; }
|
||||
@@ -112,7 +118,7 @@ namespace MediaBrowser.Providers.Music
|
||||
var url = AudioDbArtistProvider.BaseUrl + "/album-mb.php?i=" + musicBrainzReleaseGroupId;
|
||||
|
||||
var path = GetAlbumInfoPath(_config.ApplicationPaths, musicBrainzReleaseGroupId);
|
||||
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
|
||||
using (var response = await _httpClient.Get(new HttpRequestOptions
|
||||
@@ -206,5 +212,10 @@ namespace MediaBrowser.Providers.Music
|
||||
{
|
||||
public List<Album> album { get; set; }
|
||||
}
|
||||
|
||||
public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Providers;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -36,6 +37,11 @@ namespace MediaBrowser.Providers.Music
|
||||
Current = this;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(ArtistInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
return new List<RemoteSearchResult>();
|
||||
}
|
||||
|
||||
public async Task<MetadataResult<MusicArtist>> GetMetadata(ArtistInfo info, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = new MetadataResult<MusicArtist>();
|
||||
@@ -213,5 +219,10 @@ namespace MediaBrowser.Providers.Music
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Providers;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MoreLinq;
|
||||
using System;
|
||||
@@ -32,6 +33,11 @@ namespace MediaBrowser.Providers.Music
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(AlbumInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
return new List<RemoteSearchResult>();
|
||||
}
|
||||
|
||||
public async Task<MetadataResult<MusicAlbum>> GetMetadata(AlbumInfo id, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = new MetadataResult<MusicAlbum>();
|
||||
@@ -204,6 +210,11 @@ namespace MediaBrowser.Providers.Music
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
#region Result Objects
|
||||
|
||||
@@ -5,8 +5,10 @@ using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Providers;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -38,6 +40,11 @@ namespace MediaBrowser.Providers.Music
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(ArtistInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
return new List<RemoteSearchResult>();
|
||||
}
|
||||
|
||||
public async Task<MetadataResult<MusicArtist>> GetMetadata(ArtistInfo id, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = new MetadataResult<MusicArtist>();
|
||||
@@ -170,5 +177,10 @@ namespace MediaBrowser.Providers.Music
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Providers;
|
||||
using MediaBrowser.Providers.Movies;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -15,6 +17,11 @@ namespace MediaBrowser.Providers.Music
|
||||
return MovieDbProvider.Current.GetItemMetadata<MusicVideo>(info, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(MusicVideoInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
return new List<RemoteSearchResult>();
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return MovieDbProvider.Current.Name; }
|
||||
@@ -24,5 +31,10 @@ namespace MediaBrowser.Providers.Music
|
||||
{
|
||||
return MovieDbProvider.Current.HasChanged(item, date);
|
||||
}
|
||||
|
||||
public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@ using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Providers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
@@ -27,6 +29,11 @@ namespace MediaBrowser.Providers.Music
|
||||
Current = this;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(AlbumInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
return new List<RemoteSearchResult>();
|
||||
}
|
||||
|
||||
public async Task<MetadataResult<MusicAlbum>> GetMetadata(AlbumInfo id, CancellationToken cancellationToken)
|
||||
{
|
||||
var releaseId = id.GetReleaseId();
|
||||
@@ -232,5 +239,10 @@ namespace MediaBrowser.Providers.Music
|
||||
{
|
||||
get { return 0; }
|
||||
}
|
||||
|
||||
public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Providers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
@@ -14,6 +17,11 @@ namespace MediaBrowser.Providers.Music
|
||||
{
|
||||
public class MusicBrainzArtistProvider : IRemoteMetadataProvider<MusicArtist, ArtistInfo>
|
||||
{
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(ArtistInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
return new List<RemoteSearchResult>();
|
||||
}
|
||||
|
||||
public async Task<MetadataResult<MusicArtist>> GetMetadata(ArtistInfo id, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = new MetadataResult<MusicArtist>();
|
||||
@@ -115,5 +123,10 @@ namespace MediaBrowser.Providers.Music
|
||||
{
|
||||
get { return "MusicBrainz"; }
|
||||
}
|
||||
|
||||
public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,12 @@ using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Providers;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Providers.Movies;
|
||||
using MediaBrowser.Providers.TV;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -29,6 +30,21 @@ namespace MediaBrowser.Providers.Omdb
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(SeriesInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
return new List<RemoteSearchResult>();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(TrailerInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
return new List<RemoteSearchResult>();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(MovieInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
return new List<RemoteSearchResult>();
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "IMDb via The Open Movie Database"; }
|
||||
@@ -139,5 +155,10 @@ namespace MediaBrowser.Providers.Omdb
|
||||
|
||||
return new Tuple<string, string>(imdb, tvdb);
|
||||
}
|
||||
|
||||
public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Providers;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Providers.Movies;
|
||||
using System;
|
||||
@@ -42,7 +43,7 @@ namespace MediaBrowser.Providers.People
|
||||
get { return "TheMovieDb"; }
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<SearchResult<PersonLookupInfo>>> GetSearchResults(PersonLookupInfo searchInfo, CancellationToken cancellationToken)
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(PersonLookupInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
var tmdbId = searchInfo.GetProviderId(MetadataProviders.Tmdb);
|
||||
|
||||
@@ -59,18 +60,15 @@ namespace MediaBrowser.Providers.People
|
||||
|
||||
var images = (info.images ?? new Images()).profiles ?? new List<Profile>();
|
||||
|
||||
var result = new SearchResult<PersonLookupInfo>
|
||||
var result = new RemoteSearchResult
|
||||
{
|
||||
Item = new PersonLookupInfo
|
||||
{
|
||||
Name = info.name
|
||||
},
|
||||
Name = info.name,
|
||||
|
||||
ImageUrl = images.Count == 0 ? null : (tmdbImageUrl + images[0].file_path)
|
||||
};
|
||||
|
||||
result.Item.SetProviderId(MetadataProviders.Tmdb, info.id.ToString(_usCulture));
|
||||
result.Item.SetProviderId(MetadataProviders.Imdb, info.imdb_id.ToString(_usCulture));
|
||||
result.SetProviderId(MetadataProviders.Tmdb, info.id.ToString(_usCulture));
|
||||
result.SetProviderId(MetadataProviders.Imdb, info.imdb_id.ToString(_usCulture));
|
||||
|
||||
return new[] { result };
|
||||
}
|
||||
@@ -92,19 +90,16 @@ namespace MediaBrowser.Providers.People
|
||||
}
|
||||
}
|
||||
|
||||
private SearchResult<PersonLookupInfo> GetSearchResult(PersonSearchResult i, string baseImageUrl)
|
||||
private RemoteSearchResult GetSearchResult(PersonSearchResult i, string baseImageUrl)
|
||||
{
|
||||
var result = new SearchResult<PersonLookupInfo>
|
||||
var result = new RemoteSearchResult
|
||||
{
|
||||
Item = new PersonLookupInfo
|
||||
{
|
||||
Name = i.Name
|
||||
},
|
||||
Name = i.Name,
|
||||
|
||||
ImageUrl = string.IsNullOrEmpty(i.Profile_Path) ? null : (baseImageUrl + i.Profile_Path)
|
||||
};
|
||||
|
||||
result.Item.SetProviderId(MetadataProviders.Tmdb, i.Id.ToString(_usCulture));
|
||||
result.SetProviderId(MetadataProviders.Tmdb, i.Id.ToString(_usCulture));
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -175,7 +170,7 @@ namespace MediaBrowser.Providers.People
|
||||
{
|
||||
var results = await GetSearchResults(info, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return results.Select(i => i.Item.GetProviderId(MetadataProviders.Tmdb)).FirstOrDefault();
|
||||
return results.Select(i => i.GetProviderId(MetadataProviders.Tmdb)).FirstOrDefault();
|
||||
}
|
||||
|
||||
internal async Task EnsurePersonInfo(string id, CancellationToken cancellationToken)
|
||||
@@ -351,5 +346,10 @@ namespace MediaBrowser.Providers.People
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,22 +367,32 @@ namespace MediaBrowser.Providers.TV
|
||||
return Path.Combine(dataPath, "fanart.xml");
|
||||
}
|
||||
|
||||
private readonly Task _cachedTask = Task.FromResult(true);
|
||||
internal Task EnsureSeriesXml(string tvdbId, CancellationToken cancellationToken)
|
||||
private readonly SemaphoreSlim _ensureSemaphore = new SemaphoreSlim(1, 1);
|
||||
internal async Task EnsureSeriesXml(string tvdbId, CancellationToken cancellationToken)
|
||||
{
|
||||
var xmlPath = GetSeriesDataPath(_config.ApplicationPaths, tvdbId);
|
||||
var xmlPath = GetFanartXmlPath(tvdbId);
|
||||
|
||||
var fileInfo = _fileSystem.GetFileSystemInfo(xmlPath);
|
||||
// Only allow one thread in here at a time since every season will be calling this method, possibly concurrently
|
||||
await _ensureSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (fileInfo.Exists)
|
||||
try
|
||||
{
|
||||
if ((DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(fileInfo)).TotalDays <= 7)
|
||||
{
|
||||
return _cachedTask;
|
||||
}
|
||||
}
|
||||
var fileInfo = _fileSystem.GetFileSystemInfo(xmlPath);
|
||||
|
||||
return DownloadSeriesXml(tvdbId, cancellationToken);
|
||||
if (fileInfo.Exists)
|
||||
{
|
||||
if ((DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(fileInfo)).TotalDays <= 7)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
await DownloadSeriesXml(tvdbId, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_ensureSemaphore.Release();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
@@ -20,13 +21,15 @@ namespace MediaBrowser.Providers.TV
|
||||
{
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly ILogger _logger;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
|
||||
|
||||
public MissingEpisodeProvider(ILogger logger, IServerConfigurationManager config)
|
||||
public MissingEpisodeProvider(ILogger logger, IServerConfigurationManager config, ILibraryManager libraryManager)
|
||||
{
|
||||
_logger = logger;
|
||||
_config = config;
|
||||
_libraryManager = libraryManager;
|
||||
}
|
||||
|
||||
public async Task Run(IEnumerable<IGrouping<string, Series>> series, CancellationToken cancellationToken)
|
||||
@@ -268,7 +271,7 @@ namespace MediaBrowser.Providers.TV
|
||||
{
|
||||
_logger.Info("Removing missing/unaired episode {0} {1}x{2}", episodeToRemove.Series.Name, episodeToRemove.ParentIndexNumber, episodeToRemove.IndexNumber);
|
||||
|
||||
await episodeToRemove.Parent.RemoveChild(episodeToRemove, cancellationToken).ConfigureAwait(false);
|
||||
await _libraryManager.DeleteItem(episodeToRemove).ConfigureAwait(false);
|
||||
|
||||
hasChanges = true;
|
||||
}
|
||||
@@ -327,7 +330,7 @@ namespace MediaBrowser.Providers.TV
|
||||
{
|
||||
_logger.Info("Removing virtual season {0} {1}", seasonToRemove.Series.Name, seasonToRemove.IndexNumber);
|
||||
|
||||
await seasonToRemove.Parent.RemoveChild(seasonToRemove, cancellationToken).ConfigureAwait(false);
|
||||
await _libraryManager.DeleteItem(seasonToRemove).ConfigureAwait(false);
|
||||
|
||||
hasChanges = true;
|
||||
}
|
||||
|
||||
@@ -8,15 +8,16 @@ using MediaBrowser.Controller.Localization;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Providers;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Providers.Movies;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
|
||||
namespace MediaBrowser.Providers.TV
|
||||
{
|
||||
@@ -48,6 +49,11 @@ namespace MediaBrowser.Providers.TV
|
||||
get { return "TheMovieDb"; }
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(SeriesInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
return new List<RemoteSearchResult>();
|
||||
}
|
||||
|
||||
public async Task<MetadataResult<Series>> GetMetadata(SeriesInfo info, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = new MetadataResult<Series>();
|
||||
@@ -453,5 +459,10 @@ namespace MediaBrowser.Providers.TV
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace MediaBrowser.Providers.TV
|
||||
group series by tvdbId into g
|
||||
select g;
|
||||
|
||||
await new MissingEpisodeProvider(_logger, _config).Run(seriesGroups, cancellationToken).ConfigureAwait(false);
|
||||
await new MissingEpisodeProvider(_logger, _config, _libraryManager).Run(seriesGroups, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var numComplete = 0;
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Providers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
@@ -34,17 +36,54 @@ namespace MediaBrowser.Providers.TV
|
||||
Current = this;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(EpisodeInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
var list = new List<RemoteSearchResult>();
|
||||
|
||||
string seriesTvdbId;
|
||||
searchInfo.SeriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out seriesTvdbId);
|
||||
|
||||
if (!string.IsNullOrEmpty(seriesTvdbId))
|
||||
{
|
||||
var seriesDataPath = TvdbSeriesProvider.GetSeriesDataPath(_config.ApplicationPaths, seriesTvdbId);
|
||||
|
||||
try
|
||||
{
|
||||
var item = FetchEpisodeData(searchInfo, seriesDataPath, cancellationToken);
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
list.Add(new RemoteSearchResult
|
||||
{
|
||||
IndexNumber = item.IndexNumber,
|
||||
Name = item.Name,
|
||||
ParentIndexNumber = item.ParentIndexNumber,
|
||||
PremiereDate = item.PremiereDate,
|
||||
ProductionYear = item.ProductionYear,
|
||||
ProviderIds = item.ProviderIds,
|
||||
SearchProviderName = Name,
|
||||
IndexNumberEnd = item.IndexNumberEnd
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
// Don't fail the provider because this will just keep on going and going.
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "TheTVDB"; }
|
||||
}
|
||||
|
||||
public Task<MetadataResult<Episode>> GetMetadata(EpisodeInfo id, CancellationToken cancellationToken)
|
||||
public Task<MetadataResult<Episode>> GetMetadata(EpisodeInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
var episodeId = id;
|
||||
|
||||
string seriesTvdbId;
|
||||
episodeId.SeriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out seriesTvdbId);
|
||||
searchInfo.SeriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out seriesTvdbId);
|
||||
|
||||
var result = new MetadataResult<Episode>();
|
||||
|
||||
@@ -54,7 +93,7 @@ namespace MediaBrowser.Providers.TV
|
||||
|
||||
try
|
||||
{
|
||||
result.Item = FetchEpisodeData(episodeId, seriesDataPath, cancellationToken);
|
||||
result.Item = FetchEpisodeData(searchInfo, seriesDataPath, cancellationToken);
|
||||
result.HasMetadata = result.Item != null;
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
@@ -192,9 +231,9 @@ namespace MediaBrowser.Providers.TV
|
||||
|
||||
var episode = new Episode
|
||||
{
|
||||
IndexNumber = id.IndexNumber,
|
||||
ParentIndexNumber = id.ParentIndexNumber,
|
||||
IndexNumberEnd = id.IndexNumberEnd
|
||||
IndexNumber = id.IndexNumber,
|
||||
ParentIndexNumber = id.ParentIndexNumber,
|
||||
IndexNumberEnd = id.IndexNumberEnd
|
||||
};
|
||||
|
||||
try
|
||||
@@ -674,5 +713,10 @@ namespace MediaBrowser.Providers.TV
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Providers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
@@ -47,6 +48,11 @@ namespace MediaBrowser.Providers.TV
|
||||
private const string SeriesQuery = "GetSeries.php?seriesname={0}";
|
||||
private const string SeriesGetZip = "http://www.thetvdb.com/api/{0}/series/{1}/all/{2}.zip";
|
||||
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(SeriesInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
return new List<RemoteSearchResult>();
|
||||
}
|
||||
|
||||
public async Task<MetadataResult<Series>> GetMetadata(SeriesInfo itemId, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = new MetadataResult<Series>();
|
||||
@@ -1081,5 +1087,10 @@ namespace MediaBrowser.Providers.TV
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user