Merge pull request #1913 from MediaBrowser/beta

Beta
This commit is contained in:
Luke 2016-07-02 17:51:27 -04:00 committed by GitHub
commit 7394ac0605
16 changed files with 118 additions and 62 deletions

View File

@ -996,7 +996,7 @@ namespace MediaBrowser.Api.Playback
UseShellExecute = false, UseShellExecute = false,
// Must consume both stdout and stderr or deadlocks may occur // Must consume both stdout and stderr or deadlocks may occur
RedirectStandardOutput = true, //RedirectStandardOutput = true,
RedirectStandardError = true, RedirectStandardError = true,
RedirectStandardInput = true, RedirectStandardInput = true,
@ -1063,7 +1063,7 @@ namespace MediaBrowser.Api.Playback
} }
// MUST read both stdout and stderr asynchronously or a deadlock may occurr // MUST read both stdout and stderr asynchronously or a deadlock may occurr
process.BeginOutputReadLine(); //process.BeginOutputReadLine();
// Important - don't await the log task or we won't be able to kill ffmpeg when the user stops playback // Important - don't await the log task or we won't be able to kill ffmpeg when the user stops playback
Task.Run(() => StartStreamingLog(transcodingJob, state, process.StandardError.BaseStream, state.LogFileStream)); Task.Run(() => StartStreamingLog(transcodingJob, state, process.StandardError.BaseStream, state.LogFileStream));

View File

@ -117,7 +117,7 @@ namespace MediaBrowser.Api
config.EnableCustomPathSubFolders = true; config.EnableCustomPathSubFolders = true;
config.EnableStandaloneMusicKeys = true; config.EnableStandaloneMusicKeys = true;
config.EnableCaseSensitiveItemIds = true; config.EnableCaseSensitiveItemIds = true;
config.EnableFolderView = true; //config.EnableFolderView = true;
config.SchemaVersion = 97; config.SchemaVersion = 97;
} }

View File

@ -106,6 +106,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
InitTriggerEvents(); InitTriggerEvents();
} }
private bool _readFromFile = false;
/// <summary> /// <summary>
/// The _last execution result /// The _last execution result
/// </summary> /// </summary>
@ -126,7 +127,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
lock (_lastExecutionResultSyncLock) lock (_lastExecutionResultSyncLock)
{ {
if (_lastExecutionResult == null) if (_lastExecutionResult == null && !_readFromFile)
{ {
try try
{ {
@ -144,6 +145,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
{ {
Logger.ErrorException("Error deserializing {0}", ex, path); Logger.ErrorException("Error deserializing {0}", ex, path);
} }
_readFromFile = true;
} }
} }

View File

@ -1655,7 +1655,7 @@ namespace MediaBrowser.Controller.Entities
if (datePlayed.HasValue) if (datePlayed.HasValue)
{ {
// Incremenet // Increment
data.PlayCount++; data.PlayCount++;
} }
@ -1667,7 +1667,7 @@ namespace MediaBrowser.Controller.Entities
data.PlaybackPositionTicks = 0; data.PlaybackPositionTicks = 0;
} }
data.LastPlayedDate = datePlayed ?? data.LastPlayedDate; data.LastPlayedDate = datePlayed ?? data.LastPlayedDate ?? DateTime.UtcNow;
data.Played = true; data.Played = true;
await UserDataManager.SaveUserData(user.Id, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None).ConfigureAwait(false); await UserDataManager.SaveUserData(user.Id, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None).ConfigureAwait(false);

View File

@ -111,11 +111,20 @@ namespace MediaBrowser.Controller.Entities.TV
} }
} }
private static string GetUniqueSeriesKey(BaseItem series)
{
if (ConfigurationManager.Configuration.SchemaVersion < 97)
{
return series.Id.ToString("N");
}
return series.PresentationUniqueKey;
}
public override int GetChildCount(User user) public override int GetChildCount(User user)
{ {
var result = LibraryManager.GetItemsResult(new InternalItemsQuery(user) var result = LibraryManager.GetItemsResult(new InternalItemsQuery(user)
{ {
AncestorWithPresentationUniqueKey = PresentationUniqueKey, AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(this),
IncludeItemTypes = new[] { typeof(Season).Name }, IncludeItemTypes = new[] { typeof(Season).Name },
SortBy = new[] { ItemSortBy.SortName }, SortBy = new[] { ItemSortBy.SortName },
IsVirtualItem = false, IsVirtualItem = false,
@ -202,7 +211,7 @@ namespace MediaBrowser.Controller.Entities.TV
if (query.Recursive) if (query.Recursive)
{ {
query.AncestorWithPresentationUniqueKey = PresentationUniqueKey; query.AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(this);
if (query.SortBy.Length == 0) if (query.SortBy.Length == 0)
{ {
query.SortBy = new[] { ItemSortBy.SortName }; query.SortBy = new[] { ItemSortBy.SortName };
@ -228,7 +237,7 @@ namespace MediaBrowser.Controller.Entities.TV
seasons = LibraryManager.GetItemList(new InternalItemsQuery(user) seasons = LibraryManager.GetItemList(new InternalItemsQuery(user)
{ {
AncestorWithPresentationUniqueKey = PresentationUniqueKey, AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(this),
IncludeItemTypes = new[] { typeof(Season).Name }, IncludeItemTypes = new[] { typeof(Season).Name },
SortBy = new[] { ItemSortBy.SortName } SortBy = new[] { ItemSortBy.SortName }
@ -257,7 +266,7 @@ namespace MediaBrowser.Controller.Entities.TV
{ {
var allItems = LibraryManager.GetItemList(new InternalItemsQuery(user) var allItems = LibraryManager.GetItemList(new InternalItemsQuery(user)
{ {
AncestorWithPresentationUniqueKey = PresentationUniqueKey, AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(this),
IncludeItemTypes = new[] { typeof(Episode).Name, typeof(Season).Name }, IncludeItemTypes = new[] { typeof(Episode).Name, typeof(Season).Name },
SortBy = new[] { ItemSortBy.SortName } SortBy = new[] { ItemSortBy.SortName }
@ -354,7 +363,7 @@ namespace MediaBrowser.Controller.Entities.TV
{ {
return LibraryManager.GetItemList(new InternalItemsQuery(user) return LibraryManager.GetItemList(new InternalItemsQuery(user)
{ {
AncestorWithPresentationUniqueKey = PresentationUniqueKey, AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(this),
IncludeItemTypes = new[] { typeof(Episode).Name }, IncludeItemTypes = new[] { typeof(Episode).Name },
SortBy = new[] { ItemSortBy.SortName } SortBy = new[] { ItemSortBy.SortName }
@ -423,7 +432,7 @@ namespace MediaBrowser.Controller.Entities.TV
public static IEnumerable<Episode> FilterEpisodesBySeason(IEnumerable<Episode> episodes, Season parentSeason, bool includeSpecials) public static IEnumerable<Episode> FilterEpisodesBySeason(IEnumerable<Episode> episodes, Season parentSeason, bool includeSpecials)
{ {
var seasonNumber = parentSeason.IndexNumber; var seasonNumber = parentSeason.IndexNumber;
var seasonPresentationKey = parentSeason.PresentationUniqueKey; var seasonPresentationKey = GetUniqueSeriesKey(parentSeason);
var supportSpecialsInSeason = includeSpecials && seasonNumber.HasValue && seasonNumber.Value != 0; var supportSpecialsInSeason = includeSpecials && seasonNumber.HasValue && seasonNumber.Value != 0;
@ -443,7 +452,7 @@ namespace MediaBrowser.Controller.Entities.TV
if (!episode.ParentIndexNumber.HasValue) if (!episode.ParentIndexNumber.HasValue)
{ {
var season = episode.Season; var season = episode.Season;
return season != null && string.Equals(season.PresentationUniqueKey, seasonPresentationKey, StringComparison.OrdinalIgnoreCase); return season != null && string.Equals(GetUniqueSeriesKey(season), seasonPresentationKey, StringComparison.OrdinalIgnoreCase);
} }
return false; return false;

View File

@ -20,6 +20,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Configuration;
using MoreLinq;
namespace MediaBrowser.Controller.Entities namespace MediaBrowser.Controller.Entities
{ {
@ -1200,7 +1201,7 @@ namespace MediaBrowser.Controller.Entities
{ {
var user = query.User; var user = query.User;
items = libraryManager.ReplaceVideosWithPrimaryVersions(items); items = items.DistinctBy(i => i.PresentationUniqueKey, StringComparer.OrdinalIgnoreCase);
if (query.SortBy.Length > 0) if (query.SortBy.Length > 0)
{ {

View File

@ -308,13 +308,6 @@ namespace MediaBrowser.Controller.Library
/// <returns>Task.</returns> /// <returns>Task.</returns>
Task DeleteItem(BaseItem item, DeleteOptions options); Task DeleteItem(BaseItem item, DeleteOptions options);
/// <summary>
/// Replaces the videos with primary versions.
/// </summary>
/// <param name="items">The items.</param>
/// <returns>IEnumerable{BaseItem}.</returns>
IEnumerable<BaseItem> ReplaceVideosWithPrimaryVersions(IEnumerable<BaseItem> items);
/// <summary> /// <summary>
/// Gets the named view. /// Gets the named view.
/// </summary> /// </summary>

View File

@ -81,7 +81,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
UseShellExecute = false, UseShellExecute = false,
// Must consume both stdout and stderr or deadlocks may occur // Must consume both stdout and stderr or deadlocks may occur
RedirectStandardOutput = true, //RedirectStandardOutput = true,
RedirectStandardError = true, RedirectStandardError = true,
RedirectStandardInput = true, RedirectStandardInput = true,
@ -133,7 +133,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
cancellationToken.Register(() => Cancel(process, encodingJob)); cancellationToken.Register(() => Cancel(process, encodingJob));
// MUST read both stdout and stderr asynchronously or a deadlock may occurr // MUST read both stdout and stderr asynchronously or a deadlock may occurr
process.BeginOutputReadLine(); //process.BeginOutputReadLine();
// Important - don't await the log task or we won't be able to kill ffmpeg when the user stops playback // Important - don't await the log task or we won't be able to kill ffmpeg when the user stops playback
new JobLogger(Logger).StartStreamingLog(encodingJob, process.StandardError.BaseStream, encodingJob.LogFileStream); new JobLogger(Logger).StartStreamingLog(encodingJob, process.StandardError.BaseStream, encodingJob.LogFileStream);

View File

@ -483,7 +483,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
// Must consume both or ffmpeg may hang due to deadlocks. See comments below. // Must consume both or ffmpeg may hang due to deadlocks. See comments below.
RedirectStandardOutput = true, RedirectStandardOutput = true,
RedirectStandardError = true, //RedirectStandardError = true,
RedirectStandardInput = true, RedirectStandardInput = true,
FileName = FFProbePath, FileName = FFProbePath,
Arguments = string.Format(args, Arguments = string.Format(args,
@ -517,7 +517,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
try try
{ {
process.BeginErrorReadLine(); //process.BeginErrorReadLine();
var result = _jsonSerializer.DeserializeFromStream<InternalMediaInfoResult>(process.StandardOutput.BaseStream); var result = _jsonSerializer.DeserializeFromStream<InternalMediaInfoResult>(process.StandardOutput.BaseStream);
@ -612,7 +612,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
UseShellExecute = false, UseShellExecute = false,
// Must consume both or ffmpeg may hang due to deadlocks. See comments below. // Must consume both or ffmpeg may hang due to deadlocks. See comments below.
RedirectStandardOutput = true, //RedirectStandardOutput = true,
RedirectStandardError = true, RedirectStandardError = true,
RedirectStandardInput = true, RedirectStandardInput = true,
FileName = FFMpegPath, FileName = FFMpegPath,
@ -643,7 +643,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
try try
{ {
process.BeginOutputReadLine(); //process.BeginOutputReadLine();
using (var reader = new StreamReader(process.StandardError.BaseStream)) using (var reader = new StreamReader(process.StandardError.BaseStream))
{ {

View File

@ -226,7 +226,7 @@ namespace MediaBrowser.Providers.Omdb
result.Item.SetProviderId(MetadataProviders.Imdb, imdbId); result.Item.SetProviderId(MetadataProviders.Imdb, imdbId);
result.HasMetadata = true; result.HasMetadata = true;
await new OmdbProvider(_jsonSerializer, _httpClient, _fileSystem, _configurationManager).Fetch(result.Item, imdbId, info.MetadataLanguage, info.MetadataCountryCode, cancellationToken).ConfigureAwait(false); await new OmdbProvider(_jsonSerializer, _httpClient, _fileSystem, _configurationManager).Fetch(result, imdbId, info.MetadataLanguage, info.MetadataCountryCode, cancellationToken).ConfigureAwait(false);
} }
return result; return result;
@ -265,7 +265,7 @@ namespace MediaBrowser.Providers.Omdb
result.Item.SetProviderId(MetadataProviders.Imdb, imdbId); result.Item.SetProviderId(MetadataProviders.Imdb, imdbId);
result.HasMetadata = true; result.HasMetadata = true;
await new OmdbProvider(_jsonSerializer, _httpClient, _fileSystem, _configurationManager).Fetch(result.Item, imdbId, info.MetadataLanguage, info.MetadataCountryCode, cancellationToken).ConfigureAwait(false); await new OmdbProvider(_jsonSerializer, _httpClient, _fileSystem, _configurationManager).Fetch(result, imdbId, info.MetadataLanguage, info.MetadataCountryCode, cancellationToken).ConfigureAwait(false);
} }
return result; return result;

View File

@ -3,6 +3,7 @@ using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Net; using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Serialization;
using System; using System;
@ -34,13 +35,16 @@ namespace MediaBrowser.Providers.Omdb
_configurationManager = configurationManager; _configurationManager = configurationManager;
} }
public async Task Fetch(BaseItem item, string imdbId, string language, string country, CancellationToken cancellationToken) public async Task Fetch<T>(MetadataResult<T> itemResult, string imdbId, string language, string country, CancellationToken cancellationToken)
where T :BaseItem
{ {
if (string.IsNullOrWhiteSpace(imdbId)) if (string.IsNullOrWhiteSpace(imdbId))
{ {
throw new ArgumentNullException("imdbId"); throw new ArgumentNullException("imdbId");
} }
T item = itemResult.Item;
var result = await GetRootObject(imdbId, cancellationToken); var result = await GetRootObject(imdbId, cancellationToken);
// Only take the name and rating if the user's language is set to english, since Omdb has no localization // Only take the name and rating if the user's language is set to english, since Omdb has no localization
@ -56,8 +60,8 @@ namespace MediaBrowser.Providers.Omdb
int year; int year;
if (!string.IsNullOrEmpty(result.Year) if (!string.IsNullOrEmpty(result.Year) && result.Year.Length >= 4
&& int.TryParse(result.Year, NumberStyles.Number, _usCulture, out year) && int.TryParse(result.Year.Substring(0, 4), NumberStyles.Number, _usCulture, out year)
&& year >= 0) && year >= 0)
{ {
item.ProductionYear = year; item.ProductionYear = year;
@ -112,16 +116,19 @@ namespace MediaBrowser.Providers.Omdb
item.SetProviderId(MetadataProviders.Imdb, result.imdbID); item.SetProviderId(MetadataProviders.Imdb, result.imdbID);
} }
ParseAdditionalMetadata(item, result); ParseAdditionalMetadata(itemResult, result);
} }
public async Task<bool> FetchEpisodeData(BaseItem item, int episodeNumber, int seasonNumber, string imdbId, string language, string country, CancellationToken cancellationToken) public async Task<bool> FetchEpisodeData<T>(MetadataResult<T> itemResult, int episodeNumber, int seasonNumber, string imdbId, string language, string country, CancellationToken cancellationToken)
where T : BaseItem
{ {
if (string.IsNullOrWhiteSpace(imdbId)) if (string.IsNullOrWhiteSpace(imdbId))
{ {
throw new ArgumentNullException("imdbId"); throw new ArgumentNullException("imdbId");
} }
T item = itemResult.Item;
var seasonResult = await GetSeasonRootObject(imdbId, seasonNumber, cancellationToken); var seasonResult = await GetSeasonRootObject(imdbId, seasonNumber, cancellationToken);
RootObject result = null; RootObject result = null;
@ -154,8 +161,8 @@ namespace MediaBrowser.Providers.Omdb
int year; int year;
if (!string.IsNullOrEmpty(result.Year) if (!string.IsNullOrEmpty(result.Year) && result.Year.Length >= 4
&& int.TryParse(result.Year, NumberStyles.Number, _usCulture, out year) && int.TryParse(result.Year.Substring(0, 4), NumberStyles.Number, _usCulture, out year)
&& year >= 0) && year >= 0)
{ {
item.ProductionYear = year; item.ProductionYear = year;
@ -210,7 +217,7 @@ namespace MediaBrowser.Providers.Omdb
item.SetProviderId(MetadataProviders.Imdb, result.imdbID); item.SetProviderId(MetadataProviders.Imdb, result.imdbID);
} }
ParseAdditionalMetadata(item, result); ParseAdditionalMetadata(itemResult, result);
return true; return true;
} }
@ -376,8 +383,11 @@ namespace MediaBrowser.Providers.Omdb
return Path.Combine(dataPath, filename); return Path.Combine(dataPath, filename);
} }
private void ParseAdditionalMetadata(BaseItem item, RootObject result) private void ParseAdditionalMetadata<T>(MetadataResult<T> itemResult, RootObject result)
where T : BaseItem
{ {
T item = itemResult.Item;
// Grab series genres because imdb data is better than tvdb. Leave movies alone // Grab series genres because imdb data is better than tvdb. Leave movies alone
// But only do it if english is the preferred language because this data will not be localized // But only do it if english is the preferred language because this data will not be localized
if (ShouldFetchGenres(item) && if (ShouldFetchGenres(item) &&
@ -417,6 +427,46 @@ namespace MediaBrowser.Providers.Omdb
// Imdb plots are usually pretty short // Imdb plots are usually pretty short
hasShortOverview.ShortOverview = result.Plot; hasShortOverview.ShortOverview = result.Plot;
} }
//if (!string.IsNullOrWhiteSpace(result.Director))
//{
// var person = new PersonInfo
// {
// Name = result.Director.Trim(),
// Type = PersonType.Director
// };
// itemResult.AddPerson(person);
//}
//if (!string.IsNullOrWhiteSpace(result.Writer))
//{
// var person = new PersonInfo
// {
// Name = result.Director.Trim(),
// Type = PersonType.Writer
// };
// itemResult.AddPerson(person);
//}
//if (!string.IsNullOrWhiteSpace(result.Actors))
//{
// var actorList = result.Actors.Split(',');
// foreach (var actor in actorList)
// {
// if (!string.IsNullOrWhiteSpace(actor))
// {
// var person = new PersonInfo
// {
// Name = actor.Trim(),
// Type = PersonType.Actor
// };
// itemResult.AddPerson(person);
// }
// }
//}
} }
private bool ShouldFetchGenres(BaseItem item) private bool ShouldFetchGenres(BaseItem item)

View File

@ -57,7 +57,7 @@ namespace MediaBrowser.Providers.TV
{ {
var seriesImdbId = info.SeriesProviderIds[MetadataProviders.Imdb.ToString()]; var seriesImdbId = info.SeriesProviderIds[MetadataProviders.Imdb.ToString()];
result.HasMetadata = await new OmdbProvider(_jsonSerializer, _httpClient, _fileSystem, _configurationManager).FetchEpisodeData(result.Item, info.IndexNumber.Value, info.ParentIndexNumber.Value, seriesImdbId, info.MetadataLanguage, info.MetadataCountryCode, cancellationToken).ConfigureAwait(false); result.HasMetadata = await new OmdbProvider(_jsonSerializer, _httpClient, _fileSystem, _configurationManager).FetchEpisodeData(result, info.IndexNumber.Value, info.ParentIndexNumber.Value, seriesImdbId, info.MetadataLanguage, info.MetadataCountryCode, cancellationToken).ConfigureAwait(false);
} }
return result; return result;

View File

@ -526,16 +526,6 @@ namespace MediaBrowser.Server.Implementations.Library
return key.GetMD5(); return key.GetMD5();
} }
public IEnumerable<BaseItem> ReplaceVideosWithPrimaryVersions(IEnumerable<BaseItem> items)
{
if (items == null)
{
throw new ArgumentNullException("items");
}
return items.DistinctBy(i => i.PresentationUniqueKey, StringComparer.OrdinalIgnoreCase);
}
/// <summary> /// <summary>
/// Ensure supplied item has only one instance throughout /// Ensure supplied item has only one instance throughout
/// </summary> /// </summary>

View File

@ -139,7 +139,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
UseShellExecute = false, UseShellExecute = false,
// Must consume both stdout and stderr or deadlocks may occur // Must consume both stdout and stderr or deadlocks may occur
RedirectStandardOutput = true, //RedirectStandardOutput = true,
RedirectStandardError = true, RedirectStandardError = true,
RedirectStandardInput = true, RedirectStandardInput = true,
@ -174,7 +174,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
cancellationToken.Register(Stop); cancellationToken.Register(Stop);
// MUST read both stdout and stderr asynchronously or a deadlock may occurr // MUST read both stdout and stderr asynchronously or a deadlock may occurr
process.BeginOutputReadLine(); //process.BeginOutputReadLine();
onStarted(); onStarted();

View File

@ -7,6 +7,7 @@ using MediaBrowser.Model.Querying;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using MediaBrowser.Controller.Configuration;
namespace MediaBrowser.Server.Implementations.TV namespace MediaBrowser.Server.Implementations.TV
{ {
@ -15,12 +16,14 @@ namespace MediaBrowser.Server.Implementations.TV
private readonly IUserManager _userManager; private readonly IUserManager _userManager;
private readonly IUserDataManager _userDataManager; private readonly IUserDataManager _userDataManager;
private readonly ILibraryManager _libraryManager; private readonly ILibraryManager _libraryManager;
private readonly IServerConfigurationManager _config;
public TVSeriesManager(IUserManager userManager, IUserDataManager userDataManager, ILibraryManager libraryManager) public TVSeriesManager(IUserManager userManager, IUserDataManager userDataManager, ILibraryManager libraryManager, IServerConfigurationManager config)
{ {
_userManager = userManager; _userManager = userManager;
_userDataManager = userDataManager; _userDataManager = userDataManager;
_libraryManager = libraryManager; _libraryManager = libraryManager;
_config = config;
} }
public QueryResult<BaseItem> GetNextUp(NextUpQuery request) public QueryResult<BaseItem> GetNextUp(NextUpQuery request)
@ -42,7 +45,7 @@ namespace MediaBrowser.Server.Implementations.TV
if (series != null) if (series != null)
{ {
presentationUniqueKey = series.PresentationUniqueKey; presentationUniqueKey = GetUniqueSeriesKey(series);
limit = 1; limit = 1;
} }
} }
@ -81,7 +84,7 @@ namespace MediaBrowser.Server.Implementations.TV
if (series != null) if (series != null)
{ {
presentationUniqueKey = series.PresentationUniqueKey; presentationUniqueKey = GetUniqueSeriesKey(series);
limit = 1; limit = 1;
} }
} }
@ -115,6 +118,15 @@ namespace MediaBrowser.Server.Implementations.TV
.Select(i => i.Item1); .Select(i => i.Item1);
} }
private string GetUniqueSeriesKey(BaseItem series)
{
if (_config.Configuration.SchemaVersion < 97)
{
return series.Id.ToString("N");
}
return series.PresentationUniqueKey;
}
/// <summary> /// <summary>
/// Gets the next up. /// Gets the next up.
/// </summary> /// </summary>
@ -125,7 +137,7 @@ namespace MediaBrowser.Server.Implementations.TV
{ {
var lastWatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user) var lastWatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user)
{ {
AncestorWithPresentationUniqueKey = series.PresentationUniqueKey, AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(series),
IncludeItemTypes = new[] { typeof(Episode).Name }, IncludeItemTypes = new[] { typeof(Episode).Name },
SortBy = new[] { ItemSortBy.SortName }, SortBy = new[] { ItemSortBy.SortName },
SortOrder = SortOrder.Descending, SortOrder = SortOrder.Descending,
@ -138,7 +150,7 @@ namespace MediaBrowser.Server.Implementations.TV
var firstUnwatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user) var firstUnwatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user)
{ {
AncestorWithPresentationUniqueKey = series.PresentationUniqueKey, AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(series),
IncludeItemTypes = new[] { typeof(Episode).Name }, IncludeItemTypes = new[] { typeof(Episode).Name },
SortBy = new[] { ItemSortBy.SortName }, SortBy = new[] { ItemSortBy.SortName },
SortOrder = SortOrder.Ascending, SortOrder = SortOrder.Ascending,
@ -150,14 +162,13 @@ namespace MediaBrowser.Server.Implementations.TV
}).Cast<Episode>().FirstOrDefault(); }).Cast<Episode>().FirstOrDefault();
if (lastWatchedEpisode != null) if (lastWatchedEpisode != null && firstUnwatchedEpisode != null)
{ {
var userData = _userDataManager.GetUserData(user, lastWatchedEpisode); var userData = _userDataManager.GetUserData(user, lastWatchedEpisode);
if (userData.LastPlayedDate.HasValue) var lastWatchedDate = userData.LastPlayedDate ?? DateTime.MinValue.AddDays(1);
{
return new Tuple<Episode, DateTime, bool>(firstUnwatchedEpisode, userData.LastPlayedDate.Value, false); return new Tuple<Episode, DateTime, bool>(firstUnwatchedEpisode, lastWatchedDate, false);
}
} }
// Return the first episode // Return the first episode

View File

@ -477,7 +477,7 @@ namespace MediaBrowser.Server.Startup.Common
ImageProcessor = GetImageProcessor(); ImageProcessor = GetImageProcessor();
RegisterSingleInstance(ImageProcessor); RegisterSingleInstance(ImageProcessor);
TVSeriesManager = new TVSeriesManager(UserManager, UserDataManager, LibraryManager); TVSeriesManager = new TVSeriesManager(UserManager, UserDataManager, LibraryManager, ServerConfigurationManager);
RegisterSingleInstance(TVSeriesManager); RegisterSingleInstance(TVSeriesManager);
SyncManager = new SyncManager(LibraryManager, SyncRepository, ImageProcessor, LogManager.GetLogger("SyncManager"), UserManager, () => DtoService, this, TVSeriesManager, () => MediaEncoder, FileSystemManager, () => SubtitleEncoder, ServerConfigurationManager, UserDataManager, () => MediaSourceManager, JsonSerializer, TaskManager); SyncManager = new SyncManager(LibraryManager, SyncRepository, ImageProcessor, LogManager.GetLogger("SyncManager"), UserManager, () => DtoService, this, TVSeriesManager, () => MediaEncoder, FileSystemManager, () => SubtitleEncoder, ServerConfigurationManager, UserDataManager, () => MediaSourceManager, JsonSerializer, TaskManager);