diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index ab1c012a8f..30174982f9 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -150,6 +150,7 @@ + diff --git a/MediaBrowser.Controller/Providers/IExternalId.cs b/MediaBrowser.Controller/Providers/IExternalId.cs new file mode 100644 index 0000000000..946f281992 --- /dev/null +++ b/MediaBrowser.Controller/Providers/IExternalId.cs @@ -0,0 +1,15 @@ +using MediaBrowser.Model.Entities; + +namespace MediaBrowser.Controller.Providers +{ + public interface IExternalId + { + string Name { get; } + + string Key { get; } + + string UrlFormatString { get; } + + bool Supports(IHasProviderIds item); + } +} diff --git a/MediaBrowser.Controller/Providers/IProviderManager.cs b/MediaBrowser.Controller/Providers/IProviderManager.cs index ab3bf96cfd..bbe6f1be9a 100644 --- a/MediaBrowser.Controller/Providers/IProviderManager.cs +++ b/MediaBrowser.Controller/Providers/IProviderManager.cs @@ -56,9 +56,11 @@ namespace MediaBrowser.Controller.Providers /// The metadata providers. /// The savers. /// The image savers. + /// The external ids. void AddParts(IEnumerable imageProviders, IEnumerable metadataServices, IEnumerable metadataProviders, IEnumerable savers, - IEnumerable imageSavers); + IEnumerable imageSavers, + IEnumerable externalIds); /// /// Gets the available remote images. @@ -82,6 +84,13 @@ namespace MediaBrowser.Controller.Providers /// IEnumerable{MetadataPlugin}. IEnumerable GetAllMetadataPlugins(); + /// + /// Gets the external urls. + /// + /// The item. + /// IEnumerable{ExternalUrl}. + IEnumerable GetExternalUrls(IHasProviderIds item); + /// /// Saves the metadata. /// diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj index 556a59138a..e9ac46e50a 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -332,6 +332,9 @@ Plugins\PluginInfo.cs + + Providers\ExternalIdInfo.cs + Providers\ImageProviderInfo.cs diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj index b5ac60d52f..16e3f27674 100644 --- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj +++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj @@ -319,6 +319,9 @@ Plugins\PluginInfo.cs + + Providers\ExternalIdInfo.cs + Providers\ImageProviderInfo.cs diff --git a/MediaBrowser.Model/Dto/BaseItemDto.cs b/MediaBrowser.Model/Dto/BaseItemDto.cs index 0d2c4c34ed..7ba3939a29 100644 --- a/MediaBrowser.Model/Dto/BaseItemDto.cs +++ b/MediaBrowser.Model/Dto/BaseItemDto.cs @@ -1,10 +1,11 @@ using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Library; using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Runtime.Serialization; -using MediaBrowser.Model.Library; +using MediaBrowser.Model.Providers; namespace MediaBrowser.Model.Dto { @@ -77,6 +78,12 @@ namespace MediaBrowser.Model.Dto /// The premiere date. public DateTime? PremiereDate { get; set; } + /// + /// Gets or sets the external urls. + /// + /// The external urls. + public ExternalUrl[] ExternalUrls { get; set; } + /// /// Gets or sets the critic rating. /// diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index b2d1303585..d9c7cbffe3 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -88,6 +88,7 @@ + diff --git a/MediaBrowser.Model/Providers/ExternalIdInfo.cs b/MediaBrowser.Model/Providers/ExternalIdInfo.cs new file mode 100644 index 0000000000..9a79aec93a --- /dev/null +++ b/MediaBrowser.Model/Providers/ExternalIdInfo.cs @@ -0,0 +1,45 @@ + +namespace MediaBrowser.Model.Providers +{ + public class ExternalIdInfo + { + /// + /// Gets or sets the name. + /// + /// The name. + public string Name { get; set; } + + /// + /// Gets or sets the key. + /// + /// The key. + public string Key { get; set; } + + /// + /// Gets or sets the type of the item. + /// + /// The type of the item. + public string ItemType { get; set; } + + /// + /// Gets or sets the format string. + /// + /// The format string. + public string FormatString { get; set; } + } + + public class ExternalUrl + { + /// + /// Gets or sets the name. + /// + /// The name. + public string Name { get; set; } + + /// + /// Gets or sets the type of the item. + /// + /// The type of the item. + public string Url { get; set; } + } +} diff --git a/MediaBrowser.Model/Querying/ItemFields.cs b/MediaBrowser.Model/Querying/ItemFields.cs index f5640227e9..85f49ce3eb 100644 --- a/MediaBrowser.Model/Querying/ItemFields.cs +++ b/MediaBrowser.Model/Querying/ItemFields.cs @@ -51,6 +51,11 @@ namespace MediaBrowser.Model.Querying /// DisplayPreferencesId, + /// + /// The external urls + /// + ExternalUrls, + /// /// Genres /// diff --git a/MediaBrowser.Providers/Manager/ProviderManager.cs b/MediaBrowser.Providers/Manager/ProviderManager.cs index f584c40fa7..2acc3ed8ae 100644 --- a/MediaBrowser.Providers/Manager/ProviderManager.cs +++ b/MediaBrowser.Providers/Manager/ProviderManager.cs @@ -57,6 +57,8 @@ namespace MediaBrowser.Providers.Manager private IEnumerable _savers; private IImageSaver[] _imageSavers; + private IExternalId[] _externalIds; + /// /// Initializes a new instance of the class. /// @@ -82,8 +84,10 @@ namespace MediaBrowser.Providers.Manager /// The metadata providers. /// The metadata savers. /// The image savers. + /// The external ids. public void AddParts(IEnumerable imageProviders, IEnumerable metadataServices, IEnumerable metadataProviders, IEnumerable metadataSavers, - IEnumerable imageSavers) + IEnumerable imageSavers, + IEnumerable externalIds) { ImageProviders = imageProviders.ToArray(); @@ -91,6 +95,7 @@ namespace MediaBrowser.Providers.Manager _metadataProviders = metadataProviders.ToArray(); _savers = metadataSavers.ToArray(); _imageSavers = imageSavers.ToArray(); + _externalIds = externalIds.OrderBy(i => i.Name).ToArray(); } public Task RefreshMetadata(IHasMetadata item, MetadataRefreshOptions options, CancellationToken cancellationToken) @@ -625,5 +630,47 @@ namespace MediaBrowser.Providers.Manager // Nothing found return new List(); } + + public IEnumerable GetExternalIds(IHasProviderIds item) + { + return _externalIds.Where(i => + { + try + { + return i.Supports(item); + } + catch (Exception ex) + { + _logger.ErrorException("Error in {0}.Suports", ex, i.GetType().Name); + return false; + } + }); + } + + public IEnumerable GetExternalUrls(IHasProviderIds item) + { + return GetExternalIds(item) + .Select(i => + { + if (string.IsNullOrEmpty(i.UrlFormatString)) + { + return null; + } + + var value = item.GetProviderId(i.Key); + + if (string.IsNullOrEmpty(value)) + { + return null; + } + + return new ExternalUrl + { + Name = i.Name, + Url = string.Format(i.UrlFormatString, value) + }; + + }).Where(i => i != null); + } } } \ No newline at end of file diff --git a/MediaBrowser.Providers/MediaBrowser.Providers.csproj b/MediaBrowser.Providers/MediaBrowser.Providers.csproj index 724a60b97c..f0c97eb76f 100644 --- a/MediaBrowser.Providers/MediaBrowser.Providers.csproj +++ b/MediaBrowser.Providers/MediaBrowser.Providers.csproj @@ -99,6 +99,7 @@ + @@ -123,11 +124,13 @@ + + @@ -196,6 +199,7 @@ + diff --git a/MediaBrowser.Providers/Movies/MovieExternalIds.cs b/MediaBrowser.Providers/Movies/MovieExternalIds.cs new file mode 100644 index 0000000000..b4610688cb --- /dev/null +++ b/MediaBrowser.Providers/Movies/MovieExternalIds.cs @@ -0,0 +1,147 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities.Movies; +using MediaBrowser.Controller.Entities.TV; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Entities; + +namespace MediaBrowser.Providers.Movies +{ + public class MovieDbMovieExternalId : IExternalId + { + public string Name + { + get { return "TheMovieDb"; } + } + + public string Key + { + get { return MetadataProviders.Tmdb.ToString(); } + } + + public string UrlFormatString + { + get { return "http://www.themoviedb.org/movie/{0}"; } + } + + public bool Supports(IHasProviderIds item) + { + return item is Movie || item is Trailer || item is MusicVideo; + } + } + + public class MovieDbSeriesExternalId : IExternalId + { + public string Name + { + get { return "TheMovieDb"; } + } + + public string Key + { + get { return MetadataProviders.Tmdb.ToString(); } + } + + public string UrlFormatString + { + get { return "http://www.themoviedb.org/tv/{0}"; } + } + + public bool Supports(IHasProviderIds item) + { + return item is Series; + } + } + + public class MovieDbPersonExternalId : IExternalId + { + public string Name + { + get { return "TheMovieDb"; } + } + + public string Key + { + get { return MetadataProviders.Tmdb.ToString(); } + } + + public string UrlFormatString + { + get { return "http://www.themoviedb.org/person/{0}"; } + } + + public bool Supports(IHasProviderIds item) + { + return item is Person; + } + } + + public class MovieDbCollectionExternalId : IExternalId + { + public string Name + { + get { return "TheMovieDb"; } + } + + public string Key + { + get { return MetadataProviders.Tmdb.ToString(); } + } + + public string UrlFormatString + { + get { return "http://www.themoviedb.org/collection/{0}"; } + } + + public bool Supports(IHasProviderIds item) + { + return item is BoxSet; + } + } + + public class ImdbExternalId : IExternalId + { + public string Name + { + get { return "IMDb"; } + } + + public string Key + { + get { return MetadataProviders.Imdb.ToString(); } + } + + public string UrlFormatString + { + get { return "http://www.imdb.com/title/{0}"; } + } + + public bool Supports(IHasProviderIds item) + { + return !(item is Person); + } + } + + + public class ImdbPersonExternalId : IExternalId + { + public string Name + { + get { return "IMDb"; } + } + + public string Key + { + get { return MetadataProviders.Imdb.ToString(); } + } + + public string UrlFormatString + { + get { return "http://www.imdb.com/name/{0}"; } + } + + public bool Supports(IHasProviderIds item) + { + return item is Person; + } + } +} diff --git a/MediaBrowser.Providers/Music/AudioDbExternalIds.cs b/MediaBrowser.Providers/Music/AudioDbExternalIds.cs new file mode 100644 index 0000000000..8aebd0e25e --- /dev/null +++ b/MediaBrowser.Providers/Music/AudioDbExternalIds.cs @@ -0,0 +1,99 @@ +using MediaBrowser.Controller.Entities.Audio; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Entities; + +namespace MediaBrowser.Providers.Music +{ + public class AudioDbAlbumExternalId : IExternalId + { + public string Name + { + get { return "TheAudioDb"; } + } + + public string Key + { + get { return MetadataProviders.AudioDbAlbum.ToString(); } + } + + public string UrlFormatString + { + get { return "http://www.theaudiodb.com/album/{0}"; } + } + + public bool Supports(IHasProviderIds item) + { + return item is MusicAlbum; + } + } + + public class AudioDbOtherAlbumExternalId : IExternalId + { + public string Name + { + get { return "TheAudioDb Album"; } + } + + public string Key + { + get { return MetadataProviders.AudioDbAlbum.ToString(); } + } + + public string UrlFormatString + { + get { return "http://www.theaudiodb.com/album/{0}"; } + } + + public bool Supports(IHasProviderIds item) + { + return item is Audio; + } + } + + public class AudioDbArtistExternalId : IExternalId + { + public string Name + { + get { return "TheAudioDb"; } + } + + public string Key + { + get { return MetadataProviders.AudioDbArtist.ToString(); } + } + + public string UrlFormatString + { + get { return "http://www.theaudiodb.com/artist/{0}"; } + } + + public bool Supports(IHasProviderIds item) + { + return item is MusicArtist; + } + } + + public class AudioDbOtherArtistExternalId : IExternalId + { + public string Name + { + get { return "TheAudioDb"; } + } + + public string Key + { + get { return MetadataProviders.AudioDbArtist.ToString(); } + } + + public string UrlFormatString + { + get { return "http://www.theaudiodb.com/artist/{0}"; } + } + + public bool Supports(IHasProviderIds item) + { + return item is Audio || item is MusicAlbum; + } + } + +} diff --git a/MediaBrowser.Providers/Music/MusicExternalIds.cs b/MediaBrowser.Providers/Music/MusicExternalIds.cs new file mode 100644 index 0000000000..e7340d0183 --- /dev/null +++ b/MediaBrowser.Providers/Music/MusicExternalIds.cs @@ -0,0 +1,121 @@ +using MediaBrowser.Controller.Entities.Audio; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Entities; + +namespace MediaBrowser.Providers.Music +{ + public class MusicBrainzReleaseGroupExternalId : IExternalId + { + public string Name + { + get { return "MusicBrainz Release Group"; } + } + + public string Key + { + get { return MetadataProviders.MusicBrainzReleaseGroup.ToString(); } + } + + public string UrlFormatString + { + get { return "http://musicbrainz.org/release-group/{0}"; } + } + + public bool Supports(IHasProviderIds item) + { + return item is Audio || item is MusicAlbum || item is MusicArtist; + } + } + + public class MusicBrainzAlbumArtistExternalId : IExternalId + { + public string Name + { + get { return "MusicBrainz Album Artist"; } + } + + public string Key + { + get { return MetadataProviders.MusicBrainzAlbumArtist.ToString(); } + } + + public string UrlFormatString + { + get { return "http://musicbrainz.org/artist/{0}"; } + } + + public bool Supports(IHasProviderIds item) + { + return item is Audio || item is MusicAlbum; + } + } + + public class MusicBrainzAlbumExternalId : IExternalId + { + public string Name + { + get { return "MusicBrainz Album"; } + } + + public string Key + { + get { return MetadataProviders.MusicBrainzAlbum.ToString(); } + } + + public string UrlFormatString + { + get { return "http://musicbrainz.org/release/{0}"; } + } + + public bool Supports(IHasProviderIds item) + { + return item is Audio || item is MusicAlbum; + } + } + + public class MusicBrainzArtistExternalId : IExternalId + { + public string Name + { + get { return "MusicBrainz"; } + } + + public string Key + { + get { return MetadataProviders.MusicBrainzArtist.ToString(); } + } + + public string UrlFormatString + { + get { return "http://musicbrainz.org/artist/{0}"; } + } + + public bool Supports(IHasProviderIds item) + { + return item is MusicArtist; + } + } + + public class MusicBrainzOtherArtistExternalId : IExternalId + { + public string Name + { + get { return "MusicBrainz Artist"; } + } + + public string Key + { + get { return MetadataProviders.MusicBrainzArtist.ToString(); } + } + + public string UrlFormatString + { + get { return "http://musicbrainz.org/artist/{0}"; } + } + + public bool Supports(IHasProviderIds item) + { + return item is Audio || item is MusicAlbum; + } + } +} diff --git a/MediaBrowser.Providers/TV/TvExternalIds.cs b/MediaBrowser.Providers/TV/TvExternalIds.cs new file mode 100644 index 0000000000..b10acd2b75 --- /dev/null +++ b/MediaBrowser.Providers/TV/TvExternalIds.cs @@ -0,0 +1,100 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities.TV; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Entities; + +namespace MediaBrowser.Providers.TV +{ + public class Zap2ItExternalId : IExternalId + { + public string Name + { + get { return "Zap2It"; } + } + + public string Key + { + get { return MetadataProviders.Zap2It.ToString(); } + } + + public string UrlFormatString + { + get { return "http://tvlistings.zap2it.com/tv/dexter/{0}?aid=zap2it"; } + } + + public bool Supports(IHasProviderIds item) + { + return item is Series; + } + } + + public class TvdbExternalId : IExternalId + { + public string Name + { + get { return "TheTVDB"; } + } + + public string Key + { + get { return MetadataProviders.Tvdb.ToString(); } + } + + public string UrlFormatString + { + get { return "http://thetvdb.com/index.php?tab=series&id={0}"; } + } + + public bool Supports(IHasProviderIds item) + { + return item is Series; + } + } + + public class TvComSeriesExternalId : IExternalId + { + public string Name + { + get { return "TV.com"; } + } + + public string Key + { + get { return MetadataProviders.Tvcom.ToString(); } + } + + public string UrlFormatString + { + get { return null; } + } + + public bool Supports(IHasProviderIds item) + { + return item is Series; + } + } + + public class TvComPersonExternalId : IExternalId + { + public string Name + { + get { return "TV.com"; } + } + + public string Key + { + get { return MetadataProviders.Tvcom.ToString(); } + } + + public string UrlFormatString + { + get { return null; } + } + + public bool Supports(IHasProviderIds item) + { + return item is Person; + } + } + +} diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 321923dbaf..fee80c3177 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -9,6 +9,7 @@ using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Persistence; +using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Session; using MediaBrowser.Model.Drawing; using MediaBrowser.Model.Dto; @@ -35,8 +36,9 @@ namespace MediaBrowser.Server.Implementations.Dto private readonly IImageProcessor _imageProcessor; private readonly IServerConfigurationManager _config; private readonly IFileSystem _fileSystem; + private readonly IProviderManager _providerManager; - public DtoService(ILogger logger, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataRepository, IItemRepository itemRepo, IImageProcessor imageProcessor, IServerConfigurationManager config, IFileSystem fileSystem) + public DtoService(ILogger logger, ILibraryManager libraryManager, IUserManager userManager, IUserDataManager userDataRepository, IItemRepository itemRepo, IImageProcessor imageProcessor, IServerConfigurationManager config, IFileSystem fileSystem, IProviderManager providerManager) { _logger = logger; _libraryManager = libraryManager; @@ -46,6 +48,7 @@ namespace MediaBrowser.Server.Implementations.Dto _imageProcessor = imageProcessor; _config = config; _fileSystem = fileSystem; + _providerManager = providerManager; } /// @@ -689,6 +692,11 @@ namespace MediaBrowser.Server.Implementations.Dto dto.HomePageUrl = item.HomePageUrl; } + if (fields.Contains(ItemFields.ExternalUrls)) + { + dto.ExternalUrls = _providerManager.GetExternalUrls(item).ToArray(); + } + if (fields.Contains(ItemFields.Tags)) { var hasTags = item as IHasTags; diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 110e6377a6..ad939f721a 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -284,6 +284,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv if (!fileInfo.Exists) { + _logger.Debug("Creating directory {0}", path); + Directory.CreateDirectory(path); fileInfo = new DirectoryInfo(path); diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index 895a8d9b92..07af1f2e99 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -423,7 +423,7 @@ namespace MediaBrowser.ServerApplication ImageProcessor = new ImageProcessor(Logger, ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer); RegisterSingleInstance(ImageProcessor); - DtoService = new DtoService(Logger, LibraryManager, UserManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager); + DtoService = new DtoService(Logger, LibraryManager, UserManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager); RegisterSingleInstance(DtoService); var newsService = new Server.Implementations.News.NewsService(ApplicationPaths, JsonSerializer); @@ -617,7 +617,8 @@ namespace MediaBrowser.ServerApplication ProviderManager.AddParts(GetExports(), GetExports(), GetExports(), GetExports(), - GetExports()); + GetExports(), + GetExports()); ImageProcessor.AddParts(GetExports()); diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index c6c5b07830..df527920a1 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.331 + 3.0.332 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 76b583d94e..21ade2ca43 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.331 + 3.0.332 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 16565602c4..c327329e92 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.331 + 3.0.332 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - +