diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs
index 94e2f63e62..af29fd7df2 100644
--- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs
+++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs
@@ -220,9 +220,31 @@ namespace MediaBrowser.Model.Configuration
///
/// true if [create virtual future episodes]; otherwise, false.
public bool CreateVirtualFutureEpisodes { get; set; }
-
+
+ ///
+ /// Gets or sets the image saving convention.
+ ///
+ /// The image saving convention.
public ImageSavingConvention ImageSavingConvention { get; set; }
+ ///
+ /// Gets or sets the width of the min movie backdrop.
+ ///
+ /// The width of the min movie backdrop.
+ public int MinMovieBackdropWidth { get; set; }
+
+ ///
+ /// Gets or sets the width of the min movie poster.
+ ///
+ /// The width of the min movie poster.
+ public int MinMoviePosterWidth { get; set; }
+
+ ///
+ /// Gets or sets the width of the min series backdrop.
+ ///
+ /// The width of the min series backdrop.
+ public int MinSeriesBackdropWidth { get; set; }
+
///
/// Initializes a new instance of the class.
///
@@ -268,6 +290,10 @@ namespace MediaBrowser.Model.Configuration
SortRemoveWords = new[] { "the", "a", "an" };
SeasonZeroDisplayName = "Specials";
+
+ MinMovieBackdropWidth = 1920;
+ MinSeriesBackdropWidth = 1920;
+ MinMoviePosterWidth = 1000;
}
}
diff --git a/MediaBrowser.Providers/Movies/FanArtMovieProvider.cs b/MediaBrowser.Providers/Movies/FanArtMovieProvider.cs
index 5715da2f15..9ef4c68887 100644
--- a/MediaBrowser.Providers/Movies/FanArtMovieProvider.cs
+++ b/MediaBrowser.Providers/Movies/FanArtMovieProvider.cs
@@ -97,7 +97,7 @@ namespace MediaBrowser.Providers.Movies
{
get
{
- return MetadataProviderPriority.Fourth;
+ return MetadataProviderPriority.Fifth;
}
}
@@ -300,17 +300,17 @@ namespace MediaBrowser.Providers.Movies
string path;
- //if (ConfigurationManager.Configuration.DownloadMovieImages.Disc && !item.HasImage(ImageType.Disc))
- //{
- // var node = doc.SelectSingleNode("//fanart/movie/movieposters/movieposter[@lang = \"" + language + "\"]/@url") ??
- // doc.SelectSingleNode("//fanart/movie/movieposters/movieposter/@url");
- // path = node != null ? node.Value : null;
- // if (!string.IsNullOrEmpty(path))
- // {
- // await _providerManager.SaveImage(item, path, FanArtResourcePool, ImageType.Disc, null, cancellationToken)
- // .ConfigureAwait(false);
- // }
- //}
+ if (ConfigurationManager.Configuration.DownloadMovieImages.Disc && !item.HasImage(ImageType.Disc))
+ {
+ var node = doc.SelectSingleNode("//fanart/movie/movieposters/movieposter[@lang = \"" + language + "\"]/@url") ??
+ doc.SelectSingleNode("//fanart/movie/movieposters/movieposter/@url");
+ path = node != null ? node.Value : null;
+ if (!string.IsNullOrEmpty(path))
+ {
+ await _providerManager.SaveImage(item, path, FanArtResourcePool, ImageType.Disc, null, cancellationToken)
+ .ConfigureAwait(false);
+ }
+ }
cancellationToken.ThrowIfCancellationRequested();
diff --git a/MediaBrowser.Providers/Movies/MovieDbImagesProvider.cs b/MediaBrowser.Providers/Movies/MovieDbImagesProvider.cs
index 1599de72f5..21dbd63a95 100644
--- a/MediaBrowser.Providers/Movies/MovieDbImagesProvider.cs
+++ b/MediaBrowser.Providers/Movies/MovieDbImagesProvider.cs
@@ -56,7 +56,7 @@ namespace MediaBrowser.Providers.Movies
/// The priority.
public override MetadataProviderPriority Priority
{
- get { return MetadataProviderPriority.Fifth; }
+ get { return MetadataProviderPriority.Fourth; }
}
///
@@ -202,15 +202,20 @@ namespace MediaBrowser.Providers.Movies
var status = ProviderRefreshStatus.Success;
+ var eligiblePosters = images.posters == null ?
+ new List() :
+ images.posters.Where(i => i.width >= ConfigurationManager.Configuration.MinMoviePosterWidth)
+ .ToList();
+
// poster
- if (images.posters != null && images.posters.Count > 0 && !item.HasImage(ImageType.Primary))
+ if (eligiblePosters.Count > 0 && !item.HasImage(ImageType.Primary))
{
var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false);
var tmdbImageUrl = tmdbSettings.images.base_url + "original";
// get highest rated poster for our language
- var postersSortedByVote = images.posters.OrderByDescending(i => i.vote_average);
+ var postersSortedByVote = eligiblePosters.OrderByDescending(i => i.vote_average);
var poster = postersSortedByVote.FirstOrDefault(p => p.iso_639_1 != null && p.iso_639_1.Equals(ConfigurationManager.Configuration.PreferredMetadataLanguage, StringComparison.OrdinalIgnoreCase));
if (poster == null && !ConfigurationManager.Configuration.PreferredMetadataLanguage.Equals("en"))
@@ -245,14 +250,18 @@ namespace MediaBrowser.Providers.Movies
cancellationToken.ThrowIfCancellationRequested();
+ var eligibleBackdrops = images.backdrops == null ? new List() :
+ images.backdrops.Where(i => i.width >= ConfigurationManager.Configuration.MinMovieBackdropWidth)
+ .ToList();
+
// backdrops - only download if earlier providers didn't find any (fanart)
- if (images.backdrops != null && images.backdrops.Count > 0 && ConfigurationManager.Configuration.DownloadMovieImages.Backdrops && item.BackdropImagePaths.Count == 0)
+ if (eligibleBackdrops.Count > 0 && ConfigurationManager.Configuration.DownloadMovieImages.Backdrops && item.BackdropImagePaths.Count == 0)
{
var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false);
var tmdbImageUrl = tmdbSettings.images.base_url + "original";
- for (var i = 0; i < images.backdrops.Count; i++)
+ for (var i = 0; i < eligibleBackdrops.Count; i++)
{
var bdName = "backdrop" + (i == 0 ? "" : i.ToString(CultureInfo.InvariantCulture));
@@ -262,12 +271,12 @@ namespace MediaBrowser.Providers.Movies
{
var img = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions
{
- Url = tmdbImageUrl + images.backdrops[i].file_path,
+ Url = tmdbImageUrl + eligibleBackdrops[i].file_path,
CancellationToken = cancellationToken
}).ConfigureAwait(false);
- await _providerManager.SaveImage(item, img, MimeTypes.GetMimeType(images.backdrops[i].file_path), ImageType.Backdrop, item.BackdropImagePaths.Count, cancellationToken)
+ await _providerManager.SaveImage(item, img, MimeTypes.GetMimeType(eligibleBackdrops[i].file_path), ImageType.Backdrop, item.BackdropImagePaths.Count, cancellationToken)
.ConfigureAwait(false);
}
diff --git a/MediaBrowser.Providers/Movies/MovieUpdatesPrescanTask.cs b/MediaBrowser.Providers/Movies/MovieUpdatesPrescanTask.cs
index 984faa59a3..b5d2646829 100644
--- a/MediaBrowser.Providers/Movies/MovieUpdatesPrescanTask.cs
+++ b/MediaBrowser.Providers/Movies/MovieUpdatesPrescanTask.cs
@@ -61,7 +61,7 @@ namespace MediaBrowser.Providers.Movies
/// Task.
public async Task Run(IProgress progress, CancellationToken cancellationToken)
{
- if (!_config.Configuration.EnableInternetProviders || !_config.Configuration.EnableTmdbUpdates)
+ if (!_config.Configuration.EnableInternetProviders)
{
progress.Report(100);
return;
@@ -97,8 +97,10 @@ namespace MediaBrowser.Providers.Movies
var timestampFileInfo = new FileInfo(timestampFile);
+ var refreshDays = _config.Configuration.EnableTmdbUpdates ? 1 : 7;
+
// Don't check for tvdb updates anymore frequently than 24 hours
- if (timestampFileInfo.Exists && (DateTime.UtcNow - timestampFileInfo.LastWriteTimeUtc).TotalDays < 1)
+ if (timestampFileInfo.Exists && (DateTime.UtcNow - timestampFileInfo.LastWriteTimeUtc).TotalDays < refreshDays)
{
return;
}
diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
index 3f74bb52a3..3857127008 100644
--- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
+++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
@@ -172,7 +172,6 @@
-
diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteUserDataRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteUserDataRepository.cs
index fa8e69b9bb..7fabe6a903 100644
--- a/MediaBrowser.Server.Implementations/Persistence/SqliteUserDataRepository.cs
+++ b/MediaBrowser.Server.Implementations/Persistence/SqliteUserDataRepository.cs
@@ -86,13 +86,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
};
_connection.RunQueries(queries, _logger);
-
- var oldFile = Path.Combine(_appPaths.DataPath, "userdata.db");
-
- if (File.Exists(oldFile))
- {
- await UserDataMigration.Migrate(oldFile, _connection, _logger, _jsonSerializer).ConfigureAwait(false);
- }
}
///
diff --git a/MediaBrowser.Server.Implementations/Persistence/UserDataMigration.cs b/MediaBrowser.Server.Implementations/Persistence/UserDataMigration.cs
deleted file mode 100644
index 51436f94b2..0000000000
--- a/MediaBrowser.Server.Implementations/Persistence/UserDataMigration.cs
+++ /dev/null
@@ -1,144 +0,0 @@
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Model.Logging;
-using MediaBrowser.Model.Serialization;
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace MediaBrowser.Server.Implementations.Persistence
-{
- public static class UserDataMigration
- {
- ///
- /// Migrates the specified old file.
- ///
- /// The old file.
- /// The new database.
- /// The logger.
- /// The json.
- /// Task.
- public static async Task Migrate(string oldFile, IDbConnection newDatabase, ILogger logger, IJsonSerializer json)
- {
- var oldDb = await SqliteExtensions.ConnectToDb(oldFile).ConfigureAwait(false);
-
- using (oldDb)
- {
- IDbTransaction transaction = null;
-
- var data = GetAllUserData(oldDb, json).ToList();
-
- try
- {
- transaction = newDatabase.BeginTransaction();
-
- foreach (var userdata in data)
- {
- PersistUserData(userdata, newDatabase, transaction);
- }
-
- transaction.Commit();
- }
- catch (OperationCanceledException)
- {
- if (transaction != null)
- {
- transaction.Rollback();
- }
-
- throw;
- }
- catch (Exception e)
- {
- logger.ErrorException("Failed to save user data:", e);
-
- if (transaction != null)
- {
- transaction.Rollback();
- }
-
- throw;
- }
- finally
- {
- if (transaction != null)
- {
- transaction.Dispose();
- }
- }
- }
-
- var backupFile = Path.Combine(Path.GetDirectoryName(oldFile), "userdata_v1.db.bak");
-
- if (File.Exists(backupFile))
- {
- File.Delete(backupFile);
- }
-
- File.Move(oldFile, backupFile);
- }
-
- ///
- /// Gets all user data.
- ///
- /// The old database.
- /// The json serializer.
- /// IEnumerable{UserItemData}.
- private static IEnumerable GetAllUserData(IDbConnection oldDatabase, IJsonSerializer jsonSerializer)
- {
- using (var cmd = oldDatabase.CreateCommand())
- {
- cmd.CommandText = "select userId,key,data from userdata";
-
- using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult))
- {
- while (reader.Read())
- {
- var userId = reader.GetGuid(0);
- var key = reader.GetString(1);
-
- using (var stream = reader.GetMemoryStream(2))
- {
- var userData = jsonSerializer.DeserializeFromStream(stream);
-
- userData.UserId = userId;
- userData.Key = key;
-
- yield return userData;
- }
- }
- }
- }
- }
-
- ///
- /// Persists the user data.
- ///
- /// The user data.
- /// The database.
- /// The transaction.
- private static void PersistUserData(UserItemData userData, IDbConnection database, IDbTransaction transaction)
- {
- using (var cmd = database.CreateCommand())
- {
- cmd.CommandText = "replace into userdata (key, userId, rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate) values (@key, @userId, @rating,@played,@playCount,@isFavorite,@playbackPositionTicks,@lastPlayedDate)";
-
- cmd.Parameters.Add(cmd, "@key", DbType.String).Value = userData.Key;
- cmd.Parameters.Add(cmd, "@userId", DbType.Guid).Value = userData.UserId;
- cmd.Parameters.Add(cmd, "@rating", DbType.Double).Value = userData.Rating;
- cmd.Parameters.Add(cmd, "@played", DbType.Boolean).Value = userData.Played;
- cmd.Parameters.Add(cmd, "@playCount", DbType.Int32).Value = userData.PlayCount;
- cmd.Parameters.Add(cmd, "@isFavorite", DbType.Boolean).Value = userData.IsFavorite;
- cmd.Parameters.Add(cmd, "@playbackPositionTicks", DbType.Int64).Value = userData.PlaybackPositionTicks;
- cmd.Parameters.Add(cmd, "@lastPlayedDate", DbType.DateTime).Value = userData.LastPlayedDate;
-
- cmd.Transaction = transaction;
-
- cmd.ExecuteNonQuery();
- }
- }
-
- }
-}