aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2015-01-27 01:50:40 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2015-01-27 01:50:40 -0500
commitb3127f19b546f3edce959dd70cafffb3d422a673 (patch)
tree6cb84de8f1cb0ede4e787f112e9305ae64e853b1
parentf5919990c9ef80bff28ec8a590acb2f72a806678 (diff)
updated tvdb search
-rw-r--r--MediaBrowser.Api/UserService.cs2
-rw-r--r--MediaBrowser.Controller/Entities/BaseItem.cs14
-rw-r--r--MediaBrowser.Controller/Entities/CollectionFolder.cs12
-rw-r--r--MediaBrowser.Controller/Entities/Folder.cs9
-rw-r--r--MediaBrowser.Controller/Entities/IHasMetadata.cs5
-rw-r--r--MediaBrowser.Controller/Entities/Movies/BoxSet.cs1
-rw-r--r--MediaBrowser.Controller/Entities/Trailer.cs2
-rw-r--r--MediaBrowser.Controller/Entities/User.cs10
-rw-r--r--MediaBrowser.Providers/Manager/MetadataService.cs4
-rw-r--r--MediaBrowser.Providers/Omdb/OmdbItemProvider.cs110
-rw-r--r--MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs13
-rw-r--r--MediaBrowser.Providers/TV/TvdbSeriesProvider.cs39
-rw-r--r--MediaBrowser.Server.Implementations/Dto/DtoService.cs3
-rw-r--r--MediaBrowser.Server.Implementations/Localization/Server/server.json1
-rw-r--r--MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj5
15 files changed, 175 insertions, 55 deletions
diff --git a/MediaBrowser.Api/UserService.cs b/MediaBrowser.Api/UserService.cs
index 37553e4a4..4f49dd37d 100644
--- a/MediaBrowser.Api/UserService.cs
+++ b/MediaBrowser.Api/UserService.cs
@@ -455,7 +455,7 @@ namespace MediaBrowser.Api
var user = _userManager.GetUserById(id);
- var task = user.Name.Equals(dtoUser.Name, StringComparison.Ordinal) ?
+ var task = string.Equals(user.Name, dtoUser.Name, StringComparison.Ordinal) ?
_userManager.UpdateUser(user) :
_userManager.RenameUser(user, dtoUser.Name);
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index b819d14e5..67be6c2ce 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -894,12 +894,14 @@ namespace MediaBrowser.Controller.Entities
/// <returns>System.String.</returns>
public string GetUserDataKey()
{
- if (!string.IsNullOrWhiteSpace(_userDataKey))
+ if (string.IsNullOrWhiteSpace(_userDataKey))
{
- return _userDataKey;
+ var key = CreateUserDataKey();
+ _userDataKey = key;
+ return key;
}
- return _userDataKey ?? (_userDataKey = CreateUserDataKey());
+ return _userDataKey;
}
protected virtual string CreateUserDataKey()
@@ -914,6 +916,12 @@ namespace MediaBrowser.Controller.Entities
return current.IsInMixedFolder == newItem.IsInMixedFolder;
}
+ public void AfterMetadataRefresh()
+ {
+ _sortName = null;
+ _userDataKey = null;
+ }
+
/// <summary>
/// Gets the preferred metadata language.
/// </summary>
diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs
index f47a439a7..5452c63a4 100644
--- a/MediaBrowser.Controller/Entities/CollectionFolder.cs
+++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs
@@ -121,12 +121,6 @@ namespace MediaBrowser.Controller.Entities
return args;
}
- // Cache this since it will be used a lot
- /// <summary>
- /// The null task result
- /// </summary>
- private static readonly Task NullTaskResult = Task.FromResult<object>(null);
-
/// <summary>
/// Compare our current children (presumably just read from the repo) with the current state of the file system and adjust for any changes
/// ***Currently does not contain logic to maintain items that are unavailable in the file system***
@@ -138,7 +132,7 @@ namespace MediaBrowser.Controller.Entities
/// <param name="refreshOptions">The refresh options.</param>
/// <param name="directoryService">The directory service.</param>
/// <returns>Task.</returns>
- protected override async Task ValidateChildrenInternal(IProgress<double> progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService)
+ protected override Task ValidateChildrenInternal(IProgress<double> progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService)
{
var list = PhysicalLocationsList.ToList();
@@ -146,8 +140,10 @@ namespace MediaBrowser.Controller.Entities
if (!list.SequenceEqual(PhysicalLocationsList))
{
- await UpdateToRepository(ItemUpdateType.MetadataImport, cancellationToken).ConfigureAwait(false);
+ return UpdateToRepository(ItemUpdateType.MetadataImport, cancellationToken);
}
+
+ return Task.FromResult(true);
}
/// <summary>
diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs
index 8c13c7e66..7a902c0c5 100644
--- a/MediaBrowser.Controller/Entities/Folder.cs
+++ b/MediaBrowser.Controller/Entities/Folder.cs
@@ -373,12 +373,7 @@ namespace MediaBrowser.Controller.Entities
/// <returns>Task.</returns>
public Task ValidateChildren(IProgress<double> progress, CancellationToken cancellationToken, MetadataRefreshOptions metadataRefreshOptions, bool recursive = true)
{
- return ValidateChildrenWithCancellationSupport(progress, cancellationToken, recursive, true, metadataRefreshOptions, metadataRefreshOptions.DirectoryService);
- }
-
- private Task ValidateChildrenWithCancellationSupport(IProgress<double> progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService)
- {
- return ValidateChildrenInternal(progress, cancellationToken, recursive, refreshChildMetadata, refreshOptions, directoryService);
+ return ValidateChildrenInternal(progress, cancellationToken, recursive, true, metadataRefreshOptions, metadataRefreshOptions.DirectoryService);
}
private Dictionary<Guid, BaseItem> GetActualChildrenDictionary()
@@ -676,7 +671,7 @@ namespace MediaBrowser.Controller.Entities
}
});
- await child.ValidateChildrenWithCancellationSupport(innerProgress, cancellationToken, true, false, null, directoryService)
+ await child.ValidateChildrenInternal(innerProgress, cancellationToken, true, false, null, directoryService)
.ConfigureAwait(false);
}
}
diff --git a/MediaBrowser.Controller/Entities/IHasMetadata.cs b/MediaBrowser.Controller/Entities/IHasMetadata.cs
index 10ddaa474..3643c58b3 100644
--- a/MediaBrowser.Controller/Entities/IHasMetadata.cs
+++ b/MediaBrowser.Controller/Entities/IHasMetadata.cs
@@ -54,5 +54,10 @@ namespace MediaBrowser.Controller.Entities
/// Gets the item identities.
/// </summary>
List<IItemIdentity> Identities { get; set; }
+
+ /// <summary>
+ /// Afters the metadata refresh.
+ /// </summary>
+ void AfterMetadataRefresh();
}
}
diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs
index dea97aed4..b8f8dcbe1 100644
--- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs
+++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs
@@ -138,6 +138,7 @@ namespace MediaBrowser.Controller.Entities.Movies
public async Task RefreshAllMetadata(MetadataRefreshOptions refreshOptions, IProgress<double> progress, CancellationToken cancellationToken)
{
+ var b = this;
// Refresh bottom up, children first, then the boxset
// By then hopefully the movies within will have Tmdb collection values
var items = GetRecursiveChildren().ToList();
diff --git a/MediaBrowser.Controller/Entities/Trailer.cs b/MediaBrowser.Controller/Entities/Trailer.cs
index 72e3640f2..522e6edf6 100644
--- a/MediaBrowser.Controller/Entities/Trailer.cs
+++ b/MediaBrowser.Controller/Entities/Trailer.cs
@@ -1,12 +1,12 @@
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities;
+using MediaBrowser.Model.Users;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.Serialization;
-using MediaBrowser.Model.Users;
namespace MediaBrowser.Controller.Entities
{
diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs
index ac1ab14de..3c89a9609 100644
--- a/MediaBrowser.Controller/Entities/User.cs
+++ b/MediaBrowser.Controller/Entities/User.cs
@@ -229,16 +229,16 @@ namespace MediaBrowser.Controller.Entities
/// <returns>System.String.</returns>
private string GetConfigurationDirectoryPath(string username)
{
- if (string.IsNullOrEmpty(username))
- {
- throw new ArgumentNullException("username");
- }
-
var parentPath = ConfigurationManager.ApplicationPaths.UserConfigurationDirectoryPath;
// Legacy
if (!UsesIdForConfigurationPath)
{
+ if (string.IsNullOrEmpty(username))
+ {
+ throw new ArgumentNullException("username");
+ }
+
var safeFolderName = FileSystem.GetValidFilename(username);
return System.IO.Path.Combine(ConfigurationManager.ApplicationPaths.UserConfigurationDirectoryPath, safeFolderName);
diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs
index fc329d64c..baccfa65b 100644
--- a/MediaBrowser.Providers/Manager/MetadataService.cs
+++ b/MediaBrowser.Providers/Manager/MetadataService.cs
@@ -114,7 +114,7 @@ namespace MediaBrowser.Providers.Manager
catch (Exception ex)
{
localImagesFailed = true;
- Logger.ErrorException("Error validating images for {0}", ex, item.Path ?? item.Name);
+ Logger.ErrorException("Error validating images for {0}", ex, item.Path ?? item.Name ?? "Unknown name");
refreshResult.AddStatus(ProviderRefreshStatus.Failure, ex.Message);
}
@@ -182,6 +182,8 @@ namespace MediaBrowser.Providers.Manager
{
await SaveProviderResult(itemOfType, refreshResult, refreshOptions.DirectoryService).ConfigureAwait(false);
}
+
+ itemOfType.AfterMetadataRefresh();
}
private void MergeIdentities(TItemType item, TIdType id)
diff --git a/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs b/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs
index 1494eaee8..bc87c07c9 100644
--- a/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs
+++ b/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs
@@ -14,6 +14,8 @@ using MediaBrowser.Providers.Movies;
using MediaBrowser.Providers.TV;
using System;
using System.Collections.Generic;
+using System.Globalization;
+using System.Net;
using System.Threading;
using System.Threading.Tasks;
@@ -35,19 +37,75 @@ namespace MediaBrowser.Providers.Omdb
_libraryManager = libraryManager;
}
- public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(SeriesInfo searchInfo, CancellationToken cancellationToken)
+ public Task<IEnumerable<RemoteSearchResult>> GetSearchResults(SeriesInfo searchInfo, CancellationToken cancellationToken)
{
- return new List<RemoteSearchResult>();
+ return GetSearchResults(searchInfo, "series", cancellationToken);
}
- public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(TrailerInfo searchInfo, CancellationToken cancellationToken)
+ public Task<IEnumerable<RemoteSearchResult>> GetSearchResults(MovieInfo searchInfo, CancellationToken cancellationToken)
{
- return new List<RemoteSearchResult>();
+ return GetSearchResults(searchInfo, "movie", cancellationToken);
}
- public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(MovieInfo searchInfo, CancellationToken cancellationToken)
+ public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(ItemLookupInfo searchInfo, string type, CancellationToken cancellationToken)
{
- return new List<RemoteSearchResult>();
+ var list = new List<RemoteSearchResult>();
+
+ var imdbId = searchInfo.GetProviderId(MetadataProviders.Imdb);
+ if (!string.IsNullOrWhiteSpace(imdbId))
+ {
+ return list;
+ }
+
+ var url = "http://www.omdbapi.com/?plot=short&r=json";
+
+ var name = searchInfo.Name;
+ var year = searchInfo.Year;
+
+ if (year.HasValue)
+ {
+ url += "&y=" + year.Value.ToString(CultureInfo.InvariantCulture);
+ }
+
+ url += "&t=" + WebUtility.UrlEncode(name);
+ url += "&type=" + type;
+
+ using (var stream = await _httpClient.Get(new HttpRequestOptions
+ {
+ Url = url,
+ ResourcePool = OmdbProvider.ResourcePool,
+ CancellationToken = cancellationToken,
+ CacheMode = CacheMode.Unconditional,
+ CacheLength = TimeSpan.FromDays(7)
+
+ }).ConfigureAwait(false))
+ {
+ var result = _jsonSerializer.DeserializeFromStream<SearchResult>(stream);
+
+ if (string.Equals(result.Response, "true", StringComparison.OrdinalIgnoreCase))
+ {
+ var item = new RemoteSearchResult();
+
+ item.SearchProviderName = Name;
+ item.Name = result.Title;
+ item.SetProviderId(MetadataProviders.Imdb, result.imdbID);
+
+ int parsedYear;
+ if (int.TryParse(result.Year, NumberStyles.Any, CultureInfo.InvariantCulture, out parsedYear))
+ {
+ item.ProductionYear = parsedYear;
+ }
+
+ if (!string.IsNullOrWhiteSpace(result.Poster) && !string.Equals(result.Poster, "N/A", StringComparison.OrdinalIgnoreCase))
+ {
+ item.ImageUrl = result.Poster;
+ }
+
+ list.Add(item);
+ }
+ }
+
+ return list;
}
public Task<MetadataResult<ChannelVideoItem>> GetMetadata(ChannelItemLookupInfo info, CancellationToken cancellationToken)
@@ -60,9 +118,14 @@ namespace MediaBrowser.Providers.Omdb
return GetMovieResult<ChannelVideoItem>(info, cancellationToken);
}
- public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(ChannelItemLookupInfo searchInfo, CancellationToken cancellationToken)
+ public Task<IEnumerable<RemoteSearchResult>> GetSearchResults(ChannelItemLookupInfo searchInfo, CancellationToken cancellationToken)
{
- return new List<RemoteSearchResult>();
+ if (searchInfo.ContentType != ChannelMediaContentType.MovieExtra || searchInfo.ExtraType != ExtraType.Trailer)
+ {
+ return Task.FromResult<IEnumerable<RemoteSearchResult>>(new List<RemoteSearchResult>());
+ }
+
+ return GetSearchResults(searchInfo, "movie", cancellationToken);
}
public string Name
@@ -185,7 +248,36 @@ namespace MediaBrowser.Providers.Omdb
public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
{
- throw new NotImplementedException();
+ return _httpClient.GetResponse(new HttpRequestOptions
+ {
+ CancellationToken = cancellationToken,
+ Url = url,
+ ResourcePool = OmdbProvider.ResourcePool
+ });
+ }
+
+ class SearchResult
+ {
+ public string Title { get; set; }
+ public string Year { get; set; }
+ public string Rated { get; set; }
+ public string Released { get; set; }
+ public string Runtime { get; set; }
+ public string Genre { get; set; }
+ public string Director { get; set; }
+ public string Writer { get; set; }
+ public string Actors { get; set; }
+ public string Plot { get; set; }
+ public string Language { get; set; }
+ public string Country { get; set; }
+ public string Awards { get; set; }
+ public string Poster { get; set; }
+ public string Metascore { get; set; }
+ public string imdbRating { get; set; }
+ public string imdbVotes { get; set; }
+ public string imdbID { get; set; }
+ public string Type { get; set; }
+ public string Response { get; set; }
}
}
}
diff --git a/MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs b/MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs
index 52c1ab7dd..cbd3f0af0 100644
--- a/MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs
+++ b/MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs
@@ -28,11 +28,13 @@ namespace MediaBrowser.Providers.TV
internal static TvdbEpisodeProvider Current;
private readonly IFileSystem _fileSystem;
private readonly IServerConfigurationManager _config;
+ private readonly IHttpClient _httpClient;
- public TvdbEpisodeProvider(IFileSystem fileSystem, IServerConfigurationManager config)
+ public TvdbEpisodeProvider(IFileSystem fileSystem, IServerConfigurationManager config, IHttpClient httpClient)
{
_fileSystem = fileSystem;
_config = config;
+ _httpClient = httpClient;
Current = this;
}
@@ -731,7 +733,12 @@ namespace MediaBrowser.Providers.TV
public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
{
- throw new NotImplementedException();
+ return _httpClient.GetResponse(new HttpRequestOptions
+ {
+ CancellationToken = cancellationToken,
+ Url = url,
+ ResourcePool = TvdbSeriesProvider.Current.TvDbResourcePool
+ });
}
public Task<EpisodeIdentity> FindIdentity(EpisodeInfo info)
@@ -743,7 +750,7 @@ namespace MediaBrowser.Providers.TV
{
return Task.FromResult<EpisodeIdentity>(null);
}
-
+
var id = new EpisodeIdentity
{
Type = MetadataProviders.Tvdb.ToString(),
diff --git a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs
index 2be319233..0f7a9f7d8 100644
--- a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs
+++ b/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs
@@ -304,8 +304,6 @@ namespace MediaBrowser.Providers.TV
private async Task<IEnumerable<RemoteSearchResult>> FindSeriesInternal(string name, CancellationToken cancellationToken)
{
- // TODO: Support returning more data, including image url's for the identify function
-
var url = string.Format(RootUrl + SeriesQuery, WebUtility.UrlEncode(name));
var doc = new XmlDocument();
@@ -330,6 +328,11 @@ namespace MediaBrowser.Providers.TV
{
foreach (XmlNode node in nodes)
{
+ var searchResult = new RemoteSearchResult
+ {
+ SearchProviderName = Name
+ };
+
var titles = new List<string>();
var nameNode = node.SelectSingleNode("./SeriesName");
@@ -345,19 +348,35 @@ namespace MediaBrowser.Providers.TV
titles.AddRange(alias);
}
+ var imdbIdNode = node.SelectSingleNode("./IMDB_ID");
+ if (imdbIdNode != null)
+ {
+ var val = imdbIdNode.InnerText;
+ if (!string.IsNullOrWhiteSpace(val))
+ {
+ searchResult.SetProviderId(MetadataProviders.Imdb, val);
+ }
+ }
+
+ var bannerNode = node.SelectSingleNode("./banner");
+ if (bannerNode != null)
+ {
+ var val = bannerNode.InnerText;
+ if (!string.IsNullOrWhiteSpace(val))
+ {
+ searchResult.ImageUrl = TVUtils.BannerUrl + val;
+ }
+ }
+
if (titles.Any(t => string.Equals(t, comparableName, StringComparison.OrdinalIgnoreCase)))
{
- var id = node.SelectSingleNode("./seriesid");
+ var id = node.SelectSingleNode("./seriesid") ??
+ node.SelectSingleNode("./id");
+
if (id != null)
{
- var searchResult = new RemoteSearchResult
- {
- Name = titles.FirstOrDefault(),
- SearchProviderName = Name
- };
-
+ searchResult.Name = titles.FirstOrDefault();
searchResult.SetProviderId(MetadataProviders.Tvdb, id.InnerText);
-
searchResults.Add(searchResult);
}
}
diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs
index 06b5138f1..0fa37435b 100644
--- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs
+++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs
@@ -162,8 +162,7 @@ namespace MediaBrowser.Server.Implementations.Dto
{
SyncJobItemStatus.Converting,
SyncJobItemStatus.Queued,
- SyncJobItemStatus.Transferring,
- SyncJobItemStatus.Synced
+ SyncJobItemStatus.Transferring
}
});
diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json
index d75a1bc3f..3e9c75220 100644
--- a/MediaBrowser.Server.Implementations/Localization/Server/server.json
+++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json
@@ -56,6 +56,7 @@
"HeaderVideo": "Video",
"HeaderPaths": "Paths",
"CategorySync": "Sync",
+ "RegisterWithPayPal": "Register with PayPal",
"HeaderSyncRequiresSupporterMembership": "Sync Requires a Supporter Membership",
"HeaderEnjoyDayTrial": "Enjoy a 14 Day Free Trial",
"LabelSyncTempPath": "Temporary file path:",
diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj
index 72f3a5757..0072ba257 100644
--- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj
+++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj
@@ -2168,11 +2168,6 @@
</Content>
</ItemGroup>
<ItemGroup>
- <Content Include="dashboard-ui\css\images\supporter\registerpaypal.png">
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- </Content>
- </ItemGroup>
- <ItemGroup>
<Content Include="dashboard-ui\css\images\notifications\done.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>