adjust imdb id parsing

This commit is contained in:
Luke Pulverenti 2015-01-04 09:34:15 -05:00
parent 3eb4ca598c
commit 5a5ec56328
3 changed files with 29 additions and 26 deletions

View File

@ -29,13 +29,14 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
private readonly ConcurrentDictionary<Guid, ClientInfo> _apps = new ConcurrentDictionary<Guid, ClientInfo>(); private readonly ConcurrentDictionary<Guid, ClientInfo> _apps = new ConcurrentDictionary<Guid, ClientInfo>();
public UsageEntryPoint(ILogger logger, IApplicationHost applicationHost, INetworkManager networkManager, IHttpClient httpClient, ISessionManager sessionManager) public UsageEntryPoint(ILogger logger, IApplicationHost applicationHost, INetworkManager networkManager, IHttpClient httpClient, ISessionManager sessionManager, IUserManager userManager)
{ {
_logger = logger; _logger = logger;
_applicationHost = applicationHost; _applicationHost = applicationHost;
_networkManager = networkManager; _networkManager = networkManager;
_httpClient = httpClient; _httpClient = httpClient;
_sessionManager = sessionManager; _sessionManager = sessionManager;
_userManager = userManager;
_sessionManager.SessionStarted += _sessionManager_SessionStarted; _sessionManager.SessionStarted += _sessionManager_SessionStarted;
} }

View File

@ -33,13 +33,12 @@ namespace MediaBrowser.Server.Implementations.Library
return str.Substring(start, end - start); return str.Substring(start, end - start);
} }
// for imdbid we also accept pattern matching // for imdbid we also accept pattern matching
if (attrib == "imdbid") if (string.Equals(attrib, "imdbid", StringComparison.OrdinalIgnoreCase))
{ {
Regex imdbPattern = new Regex("tt\\d{7}"); var m = Regex.Match(str, "tt\\d{7}", RegexOptions.IgnoreCase);
var m = imdbPattern.Match(str); return m.Success ? m.Value : null;
return m.Success ? m.Value : null;
} }
return null; return null;
} }
} }

View File

@ -19,7 +19,8 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
/// </summary> /// </summary>
public class MovieResolver : BaseVideoResolver<Video>, IMultiItemResolver public class MovieResolver : BaseVideoResolver<Video>, IMultiItemResolver
{ {
public MovieResolver(ILibraryManager libraryManager) : base(libraryManager) public MovieResolver(ILibraryManager libraryManager)
: base(libraryManager)
{ {
} }
@ -39,7 +40,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
} }
} }
public MultiItemResolverResult ResolveMultiple(Folder parent, public MultiItemResolverResult ResolveMultiple(Folder parent,
List<FileSystemInfo> files, List<FileSystemInfo> files,
string collectionType, string collectionType,
IDirectoryService directoryService) IDirectoryService directoryService)
@ -237,25 +238,27 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
/// <param name="item">The item.</param> /// <param name="item">The item.</param>
private void SetProviderIdsFromPath(Video item) private void SetProviderIdsFromPath(Video item)
{ {
//we need to only look at the name of this actual item (not parents) if (item is Movie || item is MusicVideo)
var justName = item.IsInMixedFolder ? Path.GetFileName(item.Path) : Path.GetFileName(item.ContainingFolderPath);
// check for tmdb id
var tmdbid = justName.GetAttributeValue("tmdbid");
if (!string.IsNullOrEmpty(tmdbid))
{ {
item.SetProviderId(MetadataProviders.Tmdb, tmdbid); //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);
// check for tmdb id
var tmdbid = justName.GetAttributeValue("tmdbid");
if (!string.IsNullOrEmpty(tmdbid))
{
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);
}
} }
// 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> /// <summary>
@ -272,7 +275,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
where T : Video, new() where T : Video, new()
{ {
var multiDiscFolders = new List<FileSystemInfo>(); var multiDiscFolders = new List<FileSystemInfo>();
// Search for a folder rip // Search for a folder rip
foreach (var child in fileSystemEntries) foreach (var child in fileSystemEntries)
{ {