Merge pull request #966 from MediaBrowser/dev

adjust imdb id parsing
This commit is contained in:
Luke 2015-01-04 09:37:18 -05:00
commit 15de5cbe1c
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>();
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;
_applicationHost = applicationHost;
_networkManager = networkManager;
_httpClient = httpClient;
_sessionManager = sessionManager;
_userManager = userManager;
_sessionManager.SessionStarted += _sessionManager_SessionStarted;
}

View File

@ -33,11 +33,10 @@ namespace MediaBrowser.Server.Implementations.Library
return str.Substring(start, end - start);
}
// 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 = imdbPattern.Match(str);
return m.Success ? m.Value : null;
var m = Regex.Match(str, "tt\\d{7}", RegexOptions.IgnoreCase);
return m.Success ? m.Value : null;
}
return null;

View File

@ -19,7 +19,8 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
/// </summary>
public class MovieResolver : BaseVideoResolver<Video>, IMultiItemResolver
{
public MovieResolver(ILibraryManager libraryManager) : base(libraryManager)
public MovieResolver(ILibraryManager libraryManager)
: base(libraryManager)
{
}
@ -237,25 +238,27 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
/// <param name="item">The item.</param>
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);
// check for tmdb id
var tmdbid = justName.GetAttributeValue("tmdbid");
if (!string.IsNullOrEmpty(tmdbid))
if (item is Movie || item is MusicVideo)
{
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>