distinguish between metadata download and edit

This commit is contained in:
Luke Pulverenti 2013-06-27 19:01:03 -04:00
parent 58356619ff
commit ab6a060163
21 changed files with 138 additions and 147 deletions

View File

@ -797,7 +797,7 @@ namespace MediaBrowser.Controller.Entities
}
});
await ((Folder)child).ValidateChildren(innerProgress, cancellationToken, recursive).ConfigureAwait(false);
await ((Folder)child).ValidateChildren(innerProgress, cancellationToken, recursive, forceRefreshMetadata).ConfigureAwait(false);
}
else
{

View File

@ -9,11 +9,12 @@ namespace MediaBrowser.Controller.Library
public interface IMetadataSaver
{
/// <summary>
/// Supportses the specified item.
/// Determines whether [is enabled for] [the specified item].
/// </summary>
/// <param name="item">The item.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
bool Supports(BaseItem item);
/// <param name="updateType">Type of the update.</param>
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
bool IsEnabledFor(BaseItem item, ItemUpdateType updateType);
/// <summary>
/// Gets the save path.

View File

@ -8,6 +8,7 @@ namespace MediaBrowser.Controller.Library
Unspecified = 1,
MetadataImport = 2,
ImageUpdate = 4,
MetadataDownload = 8,
MetadataEdit = 16
}
}

View File

@ -706,7 +706,7 @@ namespace MediaBrowser.Controller.Providers
if (!string.IsNullOrWhiteSpace(tag))
{
item.AddTagline(tag);
item.AddTag(tag);
}
break;
}

View File

@ -77,7 +77,7 @@ namespace MediaBrowser.Controller.Providers
public virtual ItemUpdateType ItemUpdateType
{
get { return RequiresInternet ? ItemUpdateType.MetadataEdit : ItemUpdateType.MetadataImport; }
get { return RequiresInternet ? ItemUpdateType.MetadataDownload : ItemUpdateType.MetadataImport; }
}
/// <summary>

View File

@ -71,7 +71,7 @@ namespace MediaBrowser.Providers.Movies
{
get
{
return ItemUpdateType.ImageUpdate | ItemUpdateType.MetadataEdit;
return ItemUpdateType.ImageUpdate | ItemUpdateType.MetadataDownload;
}
}

View File

@ -21,20 +21,18 @@ namespace MediaBrowser.Providers.Savers
}
/// <summary>
/// Supportses the specified item.
/// Determines whether [is enabled for] [the specified item].
/// </summary>
/// <param name="item">The item.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
public bool Supports(BaseItem item)
/// <param name="updateType">Type of the update.</param>
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
{
if (item.LocationType != LocationType.FileSystem)
// If new metadata has been downloaded and save local is on, OR metadata was manually edited, proceed
if ((_config.Configuration.SaveLocalMeta && (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload)
|| (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit)
{
return false;
}
if (item is MusicAlbum)
{
return _config.Configuration.SaveLocalMeta;
return item is MusicAlbum;
}
return false;

View File

@ -21,23 +21,34 @@ namespace MediaBrowser.Providers.Savers
}
/// <summary>
/// Supportses the specified item.
/// Determines whether [is enabled for] [the specified item].
/// </summary>
/// <param name="item">The item.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
public bool Supports(BaseItem item)
/// <param name="updateType">Type of the update.</param>
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
{
if (item.LocationType != LocationType.FileSystem)
// If new metadata has been downloaded and save local is on, OR metadata was manually edited, proceed
if ((_config.Configuration.SaveLocalMeta && (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload)
|| (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit)
{
return false;
if (item is MusicArtist)
{
return true;
}
}
if (item is MusicArtist)
// If new metadata has been downloaded or metadata was manually edited, proceed
if ((updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload
|| (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit)
{
return _config.Configuration.SaveLocalMeta;
if (item is Artist)
{
return true;
}
}
return item is Artist;
return false;
}
/// <summary>

View File

@ -19,23 +19,21 @@ namespace MediaBrowser.Providers.Savers
}
/// <summary>
/// Supportses the specified item.
/// Determines whether [is enabled for] [the specified item].
/// </summary>
/// <param name="item">The item.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
public bool Supports(BaseItem item)
/// <param name="updateType">Type of the update.</param>
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
{
if (item.LocationType != LocationType.FileSystem)
// If new metadata has been downloaded and save local is on, OR metadata was manually edited, proceed
if ((_config.Configuration.SaveLocalMeta && (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload)
|| (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit)
{
return false;
return item is BoxSet;
}
if (!_config.Configuration.SaveLocalMeta)
{
return false;
}
return item is BoxSet;
return false;
}
/// <summary>

View File

@ -2,7 +2,6 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Entities;
using MediaBrowser.Providers.TV;
using System;
using System.Globalization;
@ -16,20 +15,23 @@ namespace MediaBrowser.Providers.Savers
public class EpisodeXmlSaver : IMetadataSaver
{
private readonly IServerConfigurationManager _config;
/// <summary>
/// Supportses the specified item.
/// Determines whether [is enabled for] [the specified item].
/// </summary>
/// <param name="item">The item.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
public bool Supports(BaseItem item)
/// <param name="updateType">Type of the update.</param>
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
{
if (!_config.Configuration.SaveLocalMeta || item.LocationType != LocationType.FileSystem)
// If new metadata has been downloaded and save local is on, OR metadata was manually edited, proceed
if ((_config.Configuration.SaveLocalMeta && (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload)
|| (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit)
{
return false;
return item is Episode;
}
return item is Episode;
return false;
}
private readonly CultureInfo _usCulture = new CultureInfo("en-US");

View File

@ -21,34 +21,40 @@ namespace MediaBrowser.Providers.Savers
}
/// <summary>
/// Supportses the specified item.
/// Determines whether [is enabled for] [the specified item].
/// </summary>
/// <param name="item">The item.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
public bool Supports(BaseItem item)
/// <param name="updateType">Type of the update.</param>
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
{
if (item.LocationType != LocationType.FileSystem)
{
return false;
}
if (!(item is Folder))
{
return false;
}
// For these we can proceed even if save local metadata is off
if (item is AggregateFolder || item is UserRootFolder || item is CollectionFolder)
// If new metadata has been downloaded and save local is on, OR metadata was manually edited, proceed
if ((_config.Configuration.SaveLocalMeta && (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload)
|| (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit)
{
return true;
}
if (!_config.Configuration.SaveLocalMeta)
{
return false;
if (!(item is Series) && !(item is BoxSet) && !(item is MusicArtist) && !(item is MusicAlbum) &&
!(item is Season))
{
return true;
}
}
return !(item is Series) && !(item is BoxSet) && !(item is MusicArtist) && !(item is MusicAlbum) && !(item is Season);
// If new metadata has been downloaded or metadata was manually edited, proceed
if ((updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload
|| (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit)
{
if (item is AggregateFolder || item is UserRootFolder || item is CollectionFolder)
{
return true;
}
}
return false;
}
/// <summary>

View File

@ -24,26 +24,29 @@ namespace MediaBrowser.Providers.Savers
}
/// <summary>
/// Supportses the specified item.
/// Determines whether [is enabled for] [the specified item].
/// </summary>
/// <param name="item">The item.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
public bool Supports(BaseItem item)
/// <param name="updateType">Type of the update.</param>
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
{
if (!_config.Configuration.SaveLocalMeta || item.LocationType != LocationType.FileSystem)
// If new metadata has been downloaded and save local is on, OR metadata was manually edited, proceed
if ((_config.Configuration.SaveLocalMeta && (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload)
|| (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit)
{
return false;
var trailer = item as Trailer;
// Don't support local trailers
if (trailer != null)
{
return !trailer.IsLocalTrailer;
}
return item is Movie || item is MusicVideo;
}
var trailer = item as Trailer;
if (trailer != null)
{
return !trailer.IsLocalTrailer;
}
// Don't support local trailers
return item is Movie || item is MusicVideo;
return false;
}
/// <summary>

View File

@ -15,18 +15,21 @@ namespace MediaBrowser.Providers.Savers
public class PersonXmlSaver : IMetadataSaver
{
/// <summary>
/// Supportses the specified item.
/// Determines whether [is enabled for] [the specified item].
/// </summary>
/// <param name="item">The item.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
public bool Supports(BaseItem item)
/// <param name="updateType">Type of the update.</param>
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
{
if (item.LocationType != LocationType.FileSystem)
// If new metadata has been downloaded or metadata was manually edited, proceed
if ((updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload
|| (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit)
{
return false;
return item is Person;
}
return item is Person;
return false;
}
/// <summary>

View File

@ -19,23 +19,21 @@ namespace MediaBrowser.Providers.Savers
}
/// <summary>
/// Supportses the specified item.
/// Determines whether [is enabled for] [the specified item].
/// </summary>
/// <param name="item">The item.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
public bool Supports(BaseItem item)
/// <param name="updateType">Type of the update.</param>
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
{
if (item.LocationType != LocationType.FileSystem)
// If new metadata has been downloaded and save local is on, OR metadata was manually edited, proceed
if ((_config.Configuration.SaveLocalMeta && (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload)
|| (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit)
{
return false;
return item is Season;
}
if (!_config.Configuration.SaveLocalMeta)
{
return false;
}
return item is Season;
return false;
}
/// <summary>

View File

@ -1,14 +1,14 @@
using System;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Entities;
using MediaBrowser.Providers.TV;
using System;
using System.IO;
using System.Security;
using System.Text;
using System.Threading;
using MediaBrowser.Providers.TV;
namespace MediaBrowser.Providers.Savers
{
@ -22,18 +22,21 @@ namespace MediaBrowser.Providers.Savers
}
/// <summary>
/// Supportses the specified item.
/// Determines whether [is enabled for] [the specified item].
/// </summary>
/// <param name="item">The item.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
public bool Supports(BaseItem item)
/// <param name="updateType">Type of the update.</param>
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public bool IsEnabledFor(BaseItem item, ItemUpdateType updateType)
{
if (!_config.Configuration.SaveLocalMeta || item.LocationType != LocationType.FileSystem)
// If new metadata has been downloaded and save local is on, OR metadata was manually edited, proceed
if ((_config.Configuration.SaveLocalMeta && (updateType & ItemUpdateType.MetadataDownload) == ItemUpdateType.MetadataDownload)
|| (updateType & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit)
{
return false;
return item is Series;
}
return item is Series;
return false;
}
/// <summary>

View File

@ -65,7 +65,7 @@ namespace MediaBrowser.Providers.TV
{
get
{
return ItemUpdateType.ImageUpdate | ItemUpdateType.MetadataEdit;
return ItemUpdateType.ImageUpdate | ItemUpdateType.MetadataDownload;
}
}
@ -358,14 +358,6 @@ namespace MediaBrowser.Providers.TV
}
}
}
if (ConfigurationManager.Configuration.SaveLocalMeta)
{
//if (!Directory.Exists(episode.MetaLocation)) Directory.CreateDirectory(episode.MetaLocation);
//var ms = new MemoryStream();
//doc.Save(ms);
//await _providerManager.SaveToLibraryFilesystem(episode, Path.Combine(episode.MetaLocation, Path.GetFileNameWithoutExtension(episode.Path) + ".xml"), ms, cancellationToken).ConfigureAwait(false);
}
return status;
}

View File

@ -258,6 +258,7 @@ namespace MediaBrowser.Providers.TV
seriesDoc.Load(seriesXmlPath);
FetchMainInfo(series, seriesDoc);
if (!series.LockedFields.Contains(MetadataFields.Cast))
{
var actorsDoc = new XmlDocument();
@ -424,18 +425,6 @@ namespace MediaBrowser.Providers.TV
/// <returns>Task.</returns>
private void FetchActors(Series series, XmlDocument actorsDoc, XmlDocument seriesDoc)
{
XmlNode actorsNode = null;
if (ConfigurationManager.Configuration.SaveLocalMeta)
{
//add to the main seriesDoc for saving
var seriesNode = seriesDoc.SelectSingleNode("//Series");
if (seriesNode != null)
{
actorsNode = seriesDoc.CreateNode(XmlNodeType.Element, "Persons", null);
seriesNode.AppendChild(actorsNode);
}
}
var xmlNodeList = actorsDoc.SelectNodes("Actors/Actor");
if (xmlNodeList != null)
@ -450,20 +439,6 @@ namespace MediaBrowser.Providers.TV
{
// Sometimes tvdb actors have leading spaces
series.AddPerson(new PersonInfo { Type = PersonType.Actor, Name = actorName.Trim(), Role = actorRole });
if (ConfigurationManager.Configuration.SaveLocalMeta && actorsNode != null)
{
//create in main seriesDoc
var personNode = seriesDoc.CreateNode(XmlNodeType.Element, "Person", null);
foreach (XmlNode subNode in p.ChildNodes)
personNode.AppendChild(seriesDoc.ImportNode(subNode, true));
//need to add the type
var typeNode = seriesDoc.CreateNode(XmlNodeType.Element, "Type", null);
typeNode.InnerText = PersonType.Actor;
personNode.AppendChild(typeNode);
actorsNode.AppendChild(personNode);
}
}
}
}

View File

@ -347,7 +347,7 @@ namespace MediaBrowser.Server.Implementations.Library
try
{
await UpdateItem(season, ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false);
await UpdateItem(season, ItemUpdateType.MetadataDownload, cancellationToken).ConfigureAwait(false);
}
catch (Exception ex)
{
@ -1311,10 +1311,9 @@ namespace MediaBrowser.Server.Implementations.Library
UpdateItemInLibraryCache(item);
// If metadata was downloaded or edited, save external metadata
if ((updateReason & ItemUpdateType.MetadataEdit) == ItemUpdateType.MetadataEdit)
if (item.LocationType == LocationType.FileSystem)
{
await SaveMetadata(item).ConfigureAwait(false);
await SaveMetadata(item, updateReason).ConfigureAwait(false);
}
if (ItemUpdated != null)
@ -1365,10 +1364,11 @@ namespace MediaBrowser.Server.Implementations.Library
/// Saves the metadata.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="updateType">Type of the update.</param>
/// <returns>Task.</returns>
private async Task SaveMetadata(BaseItem item)
private async Task SaveMetadata(BaseItem item, ItemUpdateType updateType)
{
foreach (var saver in _savers.Where(i => i.Supports(item)))
foreach (var saver in _savers.Where(i => i.IsEnabledFor(item, updateType)))
{
var path = saver.GetSavePath(item);

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.131</version>
<version>3.0.132</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.131" />
<dependency id="MediaBrowser.Common" version="3.0.132" />
<dependency id="NLog" version="2.0.1.2" />
<dependency id="ServiceStack.Text" version="3.9.45" />
<dependency id="SimpleInjector" version="2.2.3" />

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.131</version>
<version>3.0.132</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.131</version>
<version>3.0.132</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.131" />
<dependency id="MediaBrowser.Common" version="3.0.132" />
</dependencies>
</metadata>
<files>