Added Movie, Series and Episode providers
This commit is contained in:
parent
d794eecec4
commit
c658ea7feb
|
@ -83,12 +83,12 @@ namespace MediaBrowser.Controller.IO
|
|||
List<string> paths = affectedPaths;
|
||||
affectedPaths = new List<string>();
|
||||
|
||||
ProcessPathChanges(paths);
|
||||
//ProcessPathChanges(paths);
|
||||
}
|
||||
|
||||
private void ProcessPathChanges(IEnumerable<string> paths)
|
||||
private async Task ProcessPathChanges(IEnumerable<string> paths)
|
||||
{
|
||||
/*List<BaseItem> itemsToRefresh = new List<BaseItem>();
|
||||
List<BaseItem> itemsToRefresh = new List<BaseItem>();
|
||||
|
||||
foreach (BaseItem item in paths.Select(p => GetAffectedBaseItem(p)))
|
||||
{
|
||||
|
@ -105,15 +105,15 @@ namespace MediaBrowser.Controller.IO
|
|||
return folder != null && folder.IsRoot;
|
||||
}))
|
||||
{
|
||||
Kernel.Instance.ReloadRoot();
|
||||
await Kernel.Instance.ReloadRoot();
|
||||
}
|
||||
else
|
||||
{
|
||||
Parallel.For(0, itemsToRefresh.Count, i =>
|
||||
/*Parallel.For(0, itemsToRefresh.Count, i =>
|
||||
{
|
||||
Kernel.Instance.ReloadItem(itemsToRefresh[i]);
|
||||
});
|
||||
}*/
|
||||
});*/
|
||||
}
|
||||
}
|
||||
|
||||
private BaseItem GetAffectedBaseItem(string path)
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Entities\BoxSet.cs" />
|
||||
<Compile Include="Providers\MovieProviderFromXml.cs" />
|
||||
<Compile Include="Resolvers\BoxSetResolver.cs" />
|
||||
<Compile Include="Entities\Movie.cs" />
|
||||
<Compile Include="Resolvers\MovieResolver.cs" />
|
||||
|
|
32
MediaBrowser.Movies/Providers/MovieProviderFromXml.cs
Normal file
32
MediaBrowser.Movies/Providers/MovieProviderFromXml.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using System.ComponentModel.Composition;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Events;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Controller.Xml;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Movies.Entities;
|
||||
|
||||
namespace MediaBrowser.Movies.Providers
|
||||
{
|
||||
[Export(typeof(BaseMetadataProvider))]
|
||||
public class MovieProviderFromXml : BaseMetadataProvider
|
||||
{
|
||||
public override bool Supports(BaseItem item)
|
||||
{
|
||||
return item is Movie;
|
||||
}
|
||||
|
||||
public override Task Fetch(BaseItem item, ItemResolveEventArgs args)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
var metadataFile = args.GetFileByName("movie.xml");
|
||||
|
||||
if (metadataFile.HasValue)
|
||||
{
|
||||
new BaseItemXmlParser<Movie>().Fetch(item as Movie, metadataFile.Value.Key);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@ using System.Linq;
|
|||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Events;
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
using MediaBrowser.Controller.Xml;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Movies.Entities;
|
||||
|
||||
|
@ -93,13 +92,6 @@ namespace MediaBrowser.Movies.Resolvers
|
|||
{
|
||||
base.SetItemValues(item, args);
|
||||
|
||||
var metadataFile = args.GetFileByName("movie.xml");
|
||||
|
||||
if (metadataFile.HasValue)
|
||||
{
|
||||
new BaseItemXmlParser<Movie>().Fetch(item, metadataFile.Value.Key);
|
||||
}
|
||||
|
||||
PopulateBonusFeatures(item, args);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,9 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Entities\Episode.cs" />
|
||||
<Compile Include="Providers\EpisodeImageFromMediaLocationProvider.cs" />
|
||||
<Compile Include="Providers\EpisodeProviderFromXml.cs" />
|
||||
<Compile Include="Providers\SeriesProviderFromXml.cs" />
|
||||
<Compile Include="Resolvers\EpisodeResolver.cs" />
|
||||
<Compile Include="Metadata\EpisodeXmlParser.cs" />
|
||||
<Compile Include="Plugin.cs" />
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Events;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.TV.Entities;
|
||||
|
||||
namespace MediaBrowser.TV.Providers
|
||||
{
|
||||
[Export(typeof(BaseMetadataProvider))]
|
||||
public class EpisodeImageFromMediaLocationProvider : BaseMetadataProvider
|
||||
{
|
||||
public override bool Supports(BaseItem item)
|
||||
{
|
||||
return item is Episode;
|
||||
}
|
||||
|
||||
public override Task Fetch(BaseItem item, ItemResolveEventArgs args)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
string metadataFolder = Path.Combine(args.Parent.Path, "metadata");
|
||||
|
||||
string episodeFileName = Path.GetFileName(item.Path);
|
||||
|
||||
Season season = args.Parent as Season;
|
||||
|
||||
SetPrimaryImagePath(item as Episode, season, metadataFolder, episodeFileName);
|
||||
});
|
||||
}
|
||||
|
||||
private void SetPrimaryImagePath(Episode item, Season season, string metadataFolder, string episodeFileName)
|
||||
{
|
||||
string[] imageFiles = new string[] {
|
||||
Path.Combine(metadataFolder, Path.ChangeExtension(episodeFileName, ".jpg")),
|
||||
Path.Combine(metadataFolder, Path.ChangeExtension(episodeFileName, ".png"))
|
||||
};
|
||||
|
||||
if (season == null)
|
||||
{
|
||||
// Gotta do this the slow way
|
||||
item.PrimaryImagePath = imageFiles.FirstOrDefault(f => File.Exists(f));
|
||||
}
|
||||
else
|
||||
{
|
||||
item.PrimaryImagePath = imageFiles.FirstOrDefault(f => season.MetadataFiles.Any(s => s.Equals(f, StringComparison.OrdinalIgnoreCase)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
58
MediaBrowser.TV/Providers/EpisodeProviderFromXml.cs
Normal file
58
MediaBrowser.TV/Providers/EpisodeProviderFromXml.cs
Normal file
|
@ -0,0 +1,58 @@
|
|||
using System;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Events;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.TV.Entities;
|
||||
using MediaBrowser.TV.Metadata;
|
||||
|
||||
namespace MediaBrowser.TV.Providers
|
||||
{
|
||||
[Export(typeof(BaseMetadataProvider))]
|
||||
public class EpisodeProviderFromXml : BaseMetadataProvider
|
||||
{
|
||||
public override bool Supports(BaseItem item)
|
||||
{
|
||||
return item is Episode;
|
||||
}
|
||||
|
||||
public override Task Fetch(BaseItem item, ItemResolveEventArgs args)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
string metadataFolder = Path.Combine(args.Parent.Path, "metadata");
|
||||
|
||||
string episodeFileName = Path.GetFileName(item.Path);
|
||||
|
||||
string metadataFile = Path.Combine(metadataFolder, Path.ChangeExtension(episodeFileName, ".xml"));
|
||||
|
||||
FetchMetadata(item as Episode, args.Parent as Season, metadataFile);
|
||||
});
|
||||
}
|
||||
|
||||
private void FetchMetadata(Episode item, Season season, string metadataFile)
|
||||
{
|
||||
if (season == null)
|
||||
{
|
||||
// Episode directly in Series folder
|
||||
// Need to validate it the slow way
|
||||
if (!File.Exists(metadataFile))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!season.MetadataFiles.Any(s => s.Equals(metadataFile, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
new EpisodeXmlParser().Fetch(item, metadataFile);
|
||||
}
|
||||
}
|
||||
}
|
32
MediaBrowser.TV/Providers/SeriesProviderFromXml.cs
Normal file
32
MediaBrowser.TV/Providers/SeriesProviderFromXml.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using System.ComponentModel.Composition;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Events;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Controller.Xml;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.TV.Entities;
|
||||
|
||||
namespace MediaBrowser.TV.Providers
|
||||
{
|
||||
[Export(typeof(BaseMetadataProvider))]
|
||||
public class SeriesProviderFromXml : BaseMetadataProvider
|
||||
{
|
||||
public override bool Supports(BaseItem item)
|
||||
{
|
||||
return item is Series;
|
||||
}
|
||||
|
||||
public override Task Fetch(BaseItem item, ItemResolveEventArgs args)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
var metadataFile = args.GetFileByName("series.xml");
|
||||
|
||||
if (metadataFile.HasValue)
|
||||
{
|
||||
new BaseItemXmlParser<Series>().Fetch(item as Series, metadataFile.Value.Key);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +1,7 @@
|
|||
using System;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.ComponentModel.Composition;
|
||||
using MediaBrowser.Controller.Events;
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
using MediaBrowser.TV.Entities;
|
||||
using MediaBrowser.TV.Metadata;
|
||||
|
||||
namespace MediaBrowser.TV.Resolvers
|
||||
{
|
||||
|
@ -21,65 +17,5 @@ namespace MediaBrowser.TV.Resolvers
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override void SetItemValues(Episode item, ItemResolveEventArgs args)
|
||||
{
|
||||
base.SetItemValues(item, args);
|
||||
|
||||
string metadataFolder = Path.Combine(args.Parent.Path, "metadata");
|
||||
|
||||
string episodeFileName = Path.GetFileName(item.Path);
|
||||
|
||||
string metadataFile = Path.Combine(metadataFolder, Path.ChangeExtension(episodeFileName, ".xml"));
|
||||
|
||||
Season season = args.Parent as Season;
|
||||
|
||||
FetchMetadata(item, season, metadataFile);
|
||||
|
||||
if (string.IsNullOrEmpty(item.PrimaryImagePath))
|
||||
{
|
||||
SetPrimaryImagePath(item, season, metadataFolder, episodeFileName);
|
||||
}
|
||||
}
|
||||
|
||||
private void FetchMetadata(Episode item, Season season, string metadataFile)
|
||||
{
|
||||
if (season == null)
|
||||
{
|
||||
// Episode directly in Series folder
|
||||
// Need to validate it the slow way
|
||||
if (!File.Exists(metadataFile))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!season.MetadataFiles.Any(s => s.Equals(metadataFile, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
new EpisodeXmlParser().Fetch(item, metadataFile);
|
||||
}
|
||||
|
||||
private void SetPrimaryImagePath(Episode item, Season season, string metadataFolder, string episodeFileName)
|
||||
{
|
||||
string[] imageFiles = new string[] {
|
||||
Path.Combine(metadataFolder, Path.ChangeExtension(episodeFileName, ".jpg")),
|
||||
Path.Combine(metadataFolder, Path.ChangeExtension(episodeFileName, ".png"))
|
||||
};
|
||||
|
||||
if (season == null)
|
||||
{
|
||||
// Gotta do this the slow way
|
||||
item.PrimaryImagePath = imageFiles.FirstOrDefault(f => File.Exists(f));
|
||||
}
|
||||
else
|
||||
{
|
||||
item.PrimaryImagePath = imageFiles.FirstOrDefault(f => season.MetadataFiles.Any(s => s.Equals(f, StringComparison.OrdinalIgnoreCase)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ using System.IO;
|
|||
using MediaBrowser.Controller.Events;
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
using MediaBrowser.TV.Entities;
|
||||
using MediaBrowser.TV.Metadata;
|
||||
|
||||
namespace MediaBrowser.TV.Resolvers
|
||||
{
|
||||
|
@ -37,23 +36,5 @@ namespace MediaBrowser.TV.Resolvers
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override void SetItemValues(Series item, ItemResolveEventArgs args)
|
||||
{
|
||||
base.SetItemValues(item, args);
|
||||
|
||||
// Read data from series.xml, if it exists
|
||||
PopulateFolderMetadata(item, args);
|
||||
}
|
||||
|
||||
private void PopulateFolderMetadata(Series item, ItemResolveEventArgs args)
|
||||
{
|
||||
var metadataFile = args.GetFileByName("series.xml");
|
||||
|
||||
if (metadataFile.HasValue)
|
||||
{
|
||||
new SeriesXmlParser().Fetch(item, metadataFile.Value.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user