add imdbid detection from media file
This commit is contained in:
parent
767590125b
commit
5d4c53522b
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Library
|
||||
{
|
||||
|
@ -31,6 +32,14 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
int end = str.IndexOf(']', start);
|
||||
return str.Substring(start, end - start);
|
||||
}
|
||||
// for imdbid we also accept pattern matching
|
||||
if (attrib == "imdbid")
|
||||
{
|
||||
Regex imdbPattern = new Regex("tt\\d{7}");
|
||||
var m = imdbPattern.Match(str);
|
||||
return m.Success ? m.Value : null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -248,24 +248,34 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
|
|||
{
|
||||
base.SetInitialItemValues(item, args);
|
||||
|
||||
SetProviderIdFromPath(item);
|
||||
SetProviderIdsFromPath(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the provider id from path.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
private void SetProviderIdFromPath(Video item)
|
||||
private void SetProviderIdsFromPath(Video item)
|
||||
{
|
||||
//we need to only look at the name of this actual item (not parents)
|
||||
var justName = item.IsInMixedFolder ? Path.GetFileName(item.Path) : Path.GetFileName(item.ContainingFolderPath);
|
||||
|
||||
var id = justName.GetAttributeValue("tmdbid");
|
||||
// check for tmdb id
|
||||
var tmdbid = justName.GetAttributeValue("tmdbid");
|
||||
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
if (!string.IsNullOrEmpty(tmdbid))
|
||||
{
|
||||
item.SetProviderId(MetadataProviders.Tmdb, id);
|
||||
item.SetProviderId(MetadataProviders.Tmdb, tmdbid);
|
||||
}
|
||||
|
||||
// check for imdb id - we use full media path, as we can assume, that this will match in any use case (wither id in parent dir or in file name)
|
||||
var imdbid = item.Path.GetAttributeValue("imdbid");
|
||||
|
||||
if (!string.IsNullOrEmpty(imdbid))
|
||||
{
|
||||
item.SetProviderId(MetadataProviders.Imdb, imdbid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue
Block a user