support mcm episodes

This commit is contained in:
Luke Pulverenti 2014-02-08 23:52:52 -05:00
parent f29469c905
commit 60e2fd4d44
31 changed files with 132 additions and 64 deletions

View File

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Providers;
using System.Linq;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration;
using System.Collections.Generic;
@ -42,7 +43,18 @@ namespace MediaBrowser.Controller.Entities
public BookInfo GetLookupInfo()
{
return GetItemLookupInfo<BookInfo>();
var info = GetItemLookupInfo<BookInfo>();
if (string.IsNullOrEmpty(SeriesName))
{
info.SeriesName = Parents.Select(i => i.Name).FirstOrDefault();
}
else
{
info.SeriesName = SeriesName;
}
return info;
}
}
}

View File

@ -1,6 +1,9 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.LiveTv;
using System;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.LiveTv
{
@ -184,5 +187,12 @@ namespace MediaBrowser.Controller.LiveTv
{
return "Program";
}
public override Task UpdateToRepository(ItemUpdateType updateReason, CancellationToken cancellationToken)
{
// Avoid library manager and keep out of in-memory cache
// Not great that this class has to know about that, but we'll improve that later.
return ItemRepository.SaveItem(this, cancellationToken);
}
}
}

View File

@ -1,6 +1,7 @@
using System.Threading;
using MediaBrowser.Controller.Entities;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Controller.Entities;
namespace MediaBrowser.Controller.Providers
{
@ -17,7 +18,7 @@ namespace MediaBrowser.Controller.Providers
/// <param name="info">The information.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task{MetadataResult{`0}}.</returns>
Task<MetadataResult<TItemType>> GetMetadata(ItemInfo info, CancellationToken cancellationToken);
Task<LocalMetadataResult<TItemType>> GetMetadata(ItemInfo info, CancellationToken cancellationToken);
}
public class ItemInfo
@ -26,4 +27,18 @@ namespace MediaBrowser.Controller.Providers
public bool IsInMixedFolder { get; set; }
}
public class LocalMetadataResult<T>
where T : IHasMetadata
{
public bool HasMetadata { get; set; }
public T Item { get; set; }
public List<LocalImageInfo> Images { get; set; }
public LocalMetadataResult()
{
Images = new List<LocalImageInfo>();
}
}
}

View File

@ -147,7 +147,7 @@ namespace MediaBrowser.Controller.Providers
public class BookInfo : ItemLookupInfo
{
public string SeriesName { get; set; }
}
public class SeasonInfo : ItemLookupInfo

View File

@ -18,9 +18,9 @@ namespace MediaBrowser.Providers.AdultVideos
_logger = logger;
}
protected override void Fetch(AdultVideo item, string path, CancellationToken cancellationToken)
protected override void Fetch(LocalMetadataResult<AdultVideo> result, string path, CancellationToken cancellationToken)
{
new MovieXmlParser(_logger).Fetch(item, path, cancellationToken);
new MovieXmlParser(_logger).Fetch(result.Item, path, cancellationToken);
}
protected override FileInfo GetXmlFile(ItemInfo info)

View File

@ -1,5 +1,6 @@
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using System.Collections.Generic;
@ -28,6 +29,12 @@ namespace MediaBrowser.Providers.All
return true;
}
// Extracted images will be saved in here
if (item is Audio)
{
return true;
}
var locationType = item.LocationType;
if (locationType == LocationType.FileSystem ||

View File

@ -13,9 +13,9 @@ namespace MediaBrowser.Providers
{
protected IFileSystem FileSystem;
public async Task<MetadataResult<T>> GetMetadata(ItemInfo info, CancellationToken cancellationToken)
public async Task<LocalMetadataResult<T>> GetMetadata(ItemInfo info, CancellationToken cancellationToken)
{
var result = new MetadataResult<T>();
var result = new LocalMetadataResult<T>();
var file = GetXmlFile(info);
@ -32,7 +32,7 @@ namespace MediaBrowser.Providers
{
result.Item = new T();
Fetch(result.Item, path, cancellationToken);
Fetch(result, path, cancellationToken);
result.HasMetadata = true;
}
catch (FileNotFoundException)
@ -47,7 +47,7 @@ namespace MediaBrowser.Providers
return result;
}
protected abstract void Fetch(T item, string path, CancellationToken cancellationToken);
protected abstract void Fetch(LocalMetadataResult<T> result, string path, CancellationToken cancellationToken);
protected BaseXmlProvider(IFileSystem fileSystem)
{

View File

@ -20,9 +20,9 @@ namespace MediaBrowser.Providers.BoxSets
_logger = logger;
}
protected override void Fetch(BoxSet item, string path, CancellationToken cancellationToken)
protected override void Fetch(LocalMetadataResult<BoxSet> result, string path, CancellationToken cancellationToken)
{
new BaseItemXmlParser<BoxSet>(_logger).Fetch(item, path, cancellationToken);
new BaseItemXmlParser<BoxSet>(_logger).Fetch(result.Item, path, cancellationToken);
}
protected override FileInfo GetXmlFile(ItemInfo info)

View File

@ -20,9 +20,9 @@ namespace MediaBrowser.Providers.Folders
_logger = logger;
}
protected override void Fetch(Folder item, string path, CancellationToken cancellationToken)
protected override void Fetch(LocalMetadataResult<Folder> result, string path, CancellationToken cancellationToken)
{
new BaseItemXmlParser<Folder>(_logger).Fetch(item, path, cancellationToken);
new BaseItemXmlParser<Folder>(_logger).Fetch(result.Item, path, cancellationToken);
}
protected override FileInfo GetXmlFile(ItemInfo info)

View File

@ -17,9 +17,9 @@ namespace MediaBrowser.Providers.Games
_logger = logger;
}
protected override void Fetch(GameSystem item, string path, CancellationToken cancellationToken)
protected override void Fetch(LocalMetadataResult<GameSystem> result, string path, CancellationToken cancellationToken)
{
new GameSystemXmlParser(_logger).Fetch(item, path, cancellationToken);
new GameSystemXmlParser(_logger).Fetch(result.Item, path, cancellationToken);
}
protected override FileInfo GetXmlFile(ItemInfo info)

View File

@ -17,9 +17,9 @@ namespace MediaBrowser.Providers.Games
_logger = logger;
}
protected override void Fetch(Game item, string path, CancellationToken cancellationToken)
protected override void Fetch(LocalMetadataResult<Game> result, string path, CancellationToken cancellationToken)
{
new GameXmlParser(_logger).Fetch(item, path, cancellationToken);
new GameXmlParser(_logger).Fetch(result.Item, path, cancellationToken);
}
protected override FileInfo GetXmlFile(ItemInfo info)

View File

@ -17,9 +17,9 @@ namespace MediaBrowser.Providers.LiveTv
_logger = logger;
}
protected override void Fetch(LiveTvChannel item, string path, CancellationToken cancellationToken)
protected override void Fetch(LocalMetadataResult<LiveTvChannel> result, string path, CancellationToken cancellationToken)
{
new BaseItemXmlParser<LiveTvChannel>(_logger).Fetch(item, path, cancellationToken);
new BaseItemXmlParser<LiveTvChannel>(_logger).Fetch(result.Item, path, cancellationToken);
}
protected override FileInfo GetXmlFile(ItemInfo info)

View File

@ -345,6 +345,10 @@ namespace MediaBrowser.Providers.Manager
// None of the save local conditions passed, so store it in our internal folders
if (string.IsNullOrEmpty(path))
{
if (string.IsNullOrEmpty(filename))
{
filename = "folder";
}
path = Path.Combine(_config.ApplicationPaths.GetInternalMetadataPath(item.Id), filename + extension);
}

View File

@ -262,7 +262,7 @@ namespace MediaBrowser.Providers.Manager
return providers;
}
private bool MergeImages(IHasImages item, List<LocalImageInfo> images)
public bool MergeImages(IHasImages item, List<LocalImageInfo> images)
{
var changed = false;

View File

@ -111,7 +111,7 @@ namespace MediaBrowser.Providers.Manager
if (providers.Count > 0)
{
var result = await RefreshWithProviders(itemOfType, refreshOptions, providers, cancellationToken).ConfigureAwait(false);
var result = await RefreshWithProviders(itemOfType, refreshOptions, providers, itemImageProvider, cancellationToken).ConfigureAwait(false);
updateType = updateType | result.UpdateType;
refreshResult.AddStatus(result.Status, result.ErrorMessage);
@ -254,7 +254,7 @@ namespace MediaBrowser.Providers.Manager
return item is TItemType;
}
protected virtual async Task<RefreshResult> RefreshWithProviders(TItemType item, MetadataRefreshOptions options, List<IMetadataProvider> providers, CancellationToken cancellationToken)
protected virtual async Task<RefreshResult> RefreshWithProviders(TItemType item, MetadataRefreshOptions options, List<IMetadataProvider> providers, ItemImageProvider imageService, CancellationToken cancellationToken)
{
var refreshResult = new RefreshResult
{
@ -285,6 +285,11 @@ namespace MediaBrowser.Providers.Manager
if (localItem.HasMetadata)
{
if (imageService.MergeImages(item, localItem.Images))
{
refreshResult.UpdateType = refreshResult.UpdateType | ItemUpdateType.MetadataImport;
}
if (!string.IsNullOrEmpty(localItem.Item.Name))
{
MergeData(localItem.Item, temp, new List<MetadataFields>(), !options.ReplaceAllMetadata, true);

View File

@ -215,11 +215,12 @@ namespace MediaBrowser.Providers.MediaInfo
foreach (var whitelistArtist in GetSplitWhitelist())
{
if (val.IndexOf(whitelistArtist, StringComparison.OrdinalIgnoreCase) != -1)
{
val = val.Replace(whitelistArtist, "|", StringComparison.OrdinalIgnoreCase);
var originalVal = val;
val = val.Replace(whitelistArtist, "|", StringComparison.OrdinalIgnoreCase);
// TODO: Preserve casing from original tag
if (!string.Equals(originalVal, val, StringComparison.OrdinalIgnoreCase))
{
// TODO: Preserve casing from original value
artistsFound.Add(whitelistArtist);
}
}

View File

@ -71,6 +71,10 @@ namespace MediaBrowser.Providers.Movies
name = name.Replace(".", " ");
name = name.Replace("_", " ");
name = name.Replace("-", " ");
name = name.Replace("!", " ");
name = name.Replace("?", " ");
name = name.Trim();
// Search again if the new name is different
if (!string.Equals(name, originalName))

View File

@ -17,9 +17,9 @@ namespace MediaBrowser.Providers.Movies
_logger = logger;
}
protected override void Fetch(Movie item, string path, CancellationToken cancellationToken)
protected override void Fetch(LocalMetadataResult<Movie> result, string path, CancellationToken cancellationToken)
{
new MovieXmlParser(_logger).Fetch(item, path, cancellationToken);
new MovieXmlParser(_logger).Fetch(result.Item, path, cancellationToken);
}
protected override FileInfo GetXmlFile(ItemInfo info)

View File

@ -17,9 +17,9 @@ namespace MediaBrowser.Providers.Movies
_logger = logger;
}
protected override void Fetch(Trailer item, string path, CancellationToken cancellationToken)
protected override void Fetch(LocalMetadataResult<Trailer> result, string path, CancellationToken cancellationToken)
{
new MovieXmlParser(_logger).Fetch(item, path, cancellationToken);
new MovieXmlParser(_logger).Fetch(result.Item, path, cancellationToken);
}
protected override FileInfo GetXmlFile(ItemInfo info)

View File

@ -17,9 +17,9 @@ namespace MediaBrowser.Providers.Music
_logger = logger;
}
protected override void Fetch(MusicAlbum item, string path, CancellationToken cancellationToken)
protected override void Fetch(LocalMetadataResult<MusicAlbum> result, string path, CancellationToken cancellationToken)
{
new BaseItemXmlParser<MusicAlbum>(_logger).Fetch(item, path, cancellationToken);
new BaseItemXmlParser<MusicAlbum>(_logger).Fetch(result.Item, path, cancellationToken);
}
protected override FileInfo GetXmlFile(ItemInfo info)

View File

@ -17,9 +17,9 @@ namespace MediaBrowser.Providers.Music
_logger = logger;
}
protected override void Fetch(MusicArtist item, string path, CancellationToken cancellationToken)
protected override void Fetch(LocalMetadataResult<MusicArtist> result, string path, CancellationToken cancellationToken)
{
new BaseItemXmlParser<MusicArtist>(_logger).Fetch(item, path, cancellationToken);
new BaseItemXmlParser<MusicArtist>(_logger).Fetch(result.Item, path, cancellationToken);
}
protected override FileInfo GetXmlFile(ItemInfo info)

View File

@ -19,9 +19,9 @@ namespace MediaBrowser.Providers.Music
_logger = logger;
}
protected override void Fetch(MusicVideo item, string path, CancellationToken cancellationToken)
protected override void Fetch(LocalMetadataResult<MusicVideo> result, string path, CancellationToken cancellationToken)
{
new MusicVideoXmlParser(_logger).Fetch(item, path, cancellationToken);
new MusicVideoXmlParser(_logger).Fetch(result.Item, path, cancellationToken);
}
protected override FileInfo GetXmlFile(ItemInfo info)

View File

@ -24,7 +24,7 @@ namespace MediaBrowser.Providers.Omdb
public string Name
{
get { return "OMDb"; }
get { return "IMDb via The Open Movie Database"; }
}
public Task<ItemUpdateType> FetchAsync(Series item, CancellationToken cancellationToken)

View File

@ -17,9 +17,9 @@ namespace MediaBrowser.Providers.People
_logger = logger;
}
protected override void Fetch(Person item, string path, CancellationToken cancellationToken)
protected override void Fetch(LocalMetadataResult<Person> result, string path, CancellationToken cancellationToken)
{
new BaseItemXmlParser<Person>(_logger).Fetch(item, path, cancellationToken);
new BaseItemXmlParser<Person>(_logger).Fetch(result.Item, path, cancellationToken);
}
protected override FileInfo GetXmlFile(ItemInfo info)

View File

@ -3,6 +3,7 @@ using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Threading;
@ -15,14 +16,18 @@ namespace MediaBrowser.Providers.TV
/// </summary>
public class EpisodeXmlParser : BaseItemXmlParser<Episode>
{
private List<LocalImageInfo> _imagesFound;
public EpisodeXmlParser(ILogger logger)
: base(logger)
{
}
public void FetchAsync(Episode item, string metadataFile, CancellationToken cancellationToken)
public void Fetch(Episode item, List<LocalImageInfo> images, string metadataFile, CancellationToken cancellationToken)
{
Fetch(item, metadataFile, cancellationToken);
_imagesFound = images;
Fetch(item, metadataFile, cancellationToken);
}
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
@ -66,17 +71,22 @@ namespace MediaBrowser.Providers.TV
if (!string.IsNullOrWhiteSpace(filename))
{
//// Strip off everything but the filename. Some metadata tools like MetaBrowser v1.0 will have an 'episodes' prefix
//// even though it's actually using the metadata folder.
//filename = Path.GetFileName(filename);
// Strip off everything but the filename. Some metadata tools like MetaBrowser v1.0 will have an 'episodes' prefix
// even though it's actually using the metadata folder.
filename = Path.GetFileName(filename);
//var seasonFolder = Path.GetDirectoryName(item.Path);
//filename = Path.Combine(seasonFolder, "metadata", filename);
var parentFolder = Path.GetDirectoryName(item.Path);
filename = Path.Combine(parentFolder, "metadata", filename);
var file = new FileInfo(filename);
//if (File.Exists(filename))
//{
// item.SetImagePath(ImageType.Primary, 0, filename);
//}
if (file.Exists)
{
_imagesFound.Add(new LocalImageInfo
{
Type = ImageType.Primary,
FileInfo = file
});
}
}
break;
}

View File

@ -17,9 +17,9 @@ namespace MediaBrowser.Providers.TV
_logger = logger;
}
protected override void Fetch(Episode item, string path, CancellationToken cancellationToken)
protected override void Fetch(LocalMetadataResult<Episode> result, string path, CancellationToken cancellationToken)
{
new EpisodeXmlParser(_logger).Fetch(item, path, cancellationToken);
new EpisodeXmlParser(_logger).Fetch(result.Item, path, cancellationToken);
}
protected override FileInfo GetXmlFile(ItemInfo info)

View File

@ -20,9 +20,9 @@ namespace MediaBrowser.Providers.TV
_logger = logger;
}
protected override void Fetch(Season item, string path, CancellationToken cancellationToken)
protected override void Fetch(LocalMetadataResult<Season> result, string path, CancellationToken cancellationToken)
{
new BaseItemXmlParser<Season>(_logger).Fetch(item, path, cancellationToken);
new BaseItemXmlParser<Season>(_logger).Fetch(result.Item, path, cancellationToken);
}
protected override FileInfo GetXmlFile(ItemInfo info)

View File

@ -20,9 +20,9 @@ namespace MediaBrowser.Providers.TV
_logger = logger;
}
protected override void Fetch(Series item, string path, CancellationToken cancellationToken)
protected override void Fetch(LocalMetadataResult<Series> result, string path, CancellationToken cancellationToken)
{
new SeriesXmlParser(_logger).Fetch(item, path, cancellationToken);
new SeriesXmlParser(_logger).Fetch(result.Item, path, cancellationToken);
}
protected override FileInfo GetXmlFile(ItemInfo info)

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common.Internal</id>
<version>3.0.322</version>
<version>3.0.324</version>
<title>MediaBrowser.Common.Internal</title>
<authors>Luke</authors>
<owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
<copyright>Copyright © Media Browser 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.322" />
<dependency id="MediaBrowser.Common" version="3.0.324" />
<dependency id="NLog" version="2.1.0" />
<dependency id="SimpleInjector" version="2.4.1" />
<dependency id="sharpcompress" version="0.10.2" />

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common</id>
<version>3.0.322</version>
<version>3.0.324</version>
<title>MediaBrowser.Common</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MediaBrowser.Server.Core</id>
<version>3.0.322</version>
<version>3.0.324</version>
<title>Media Browser.Server.Core</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains core components required to build plugins for Media Browser Server.</description>
<copyright>Copyright © Media Browser 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.322" />
<dependency id="MediaBrowser.Common" version="3.0.324" />
</dependencies>
</metadata>
<files>