update keep up to deletion

This commit is contained in:
Luke Pulverenti 2017-04-15 15:46:07 -04:00
parent 8eb4c034b4
commit eedf62d80d
5 changed files with 50 additions and 7 deletions

View File

@ -219,7 +219,7 @@ namespace Emby.Server.Implementations.Library.Resolvers.Movies
if (string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase))
{
return FindMovie<MusicVideo>(args.Path, args.Parent, files, args.DirectoryService, collectionType, false);
return FindMovie<MusicVideo>(args.Path, args.Parent, files, args.DirectoryService, collectionType, true);
}
if (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase))

View File

@ -39,6 +39,7 @@ using MediaBrowser.Model.FileOrganization;
using MediaBrowser.Model.System;
using MediaBrowser.Model.Threading;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.Querying;
namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
@ -1512,7 +1513,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
_timerProvider.AddOrUpdate(timer, false);
SaveRecordingMetadata(timer, recordPath, seriesPath);
EnforceKeepUpTo(timer);
EnforceKeepUpTo(timer, seriesPath);
};
await recorder.Record(mediaStreamInfo, recordPath, duration, onStarted, cancellationToken)
@ -1583,12 +1584,16 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}, _logger);
}
private async void EnforceKeepUpTo(TimerInfo timer)
private async void EnforceKeepUpTo(TimerInfo timer, string seriesPath)
{
if (string.IsNullOrWhiteSpace(timer.SeriesTimerId))
{
return;
}
if (string.IsNullOrWhiteSpace(seriesPath))
{
return;
}
var seriesTimerId = timer.SeriesTimerId;
var seriesTimer = _seriesTimerProvider.GetAll().FirstOrDefault(i => string.Equals(i.Id, seriesTimerId, StringComparison.OrdinalIgnoreCase));
@ -1621,6 +1626,43 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
.ToList();
await DeleteLibraryItemsForTimers(timersToDelete).ConfigureAwait(false);
var librarySeries = _libraryManager.FindByPath(seriesPath, true) as Folder;
if (librarySeries == null)
{
return;
}
var episodesToDelete = (await librarySeries.GetItems(new InternalItemsQuery
{
SortBy = new[] { ItemSortBy.DateCreated },
SortOrder = SortOrder.Descending,
IsVirtualItem = false,
IsFolder = false,
Recursive = true
}).ConfigureAwait(false))
.Items
.Where(i => i.LocationType == LocationType.FileSystem && _fileSystem.FileExists(i.Path))
.Skip(seriesTimer.KeepUpTo - 1)
.ToList();
foreach (var item in episodesToDelete)
{
try
{
await _libraryManager.DeleteItem(item, new DeleteOptions
{
DeleteFileLocation = true
}).ConfigureAwait(false);
}
catch (Exception ex)
{
_logger.ErrorException("Error deleting item", ex);
}
}
}
finally
{
@ -1658,7 +1700,8 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
await _libraryManager.DeleteItem(libraryItem, new DeleteOptions
{
DeleteFileLocation = true
});
}).ConfigureAwait(false);
}
else
{

View File

@ -84,7 +84,7 @@ namespace Emby.Server.Implementations.LiveTv
if (width >= 1900)
{
videoStream.BitRate = 8000000;
videoStream.BitRate = 15000000;
}
else if (width >= 1260)

View File

@ -185,7 +185,7 @@ namespace Emby.Server.Implementations.LiveTv
if (width >= 1900)
{
videoStream.BitRate = 8000000;
videoStream.BitRate = 15000000;
}
else if (width >= 1260)

View File

@ -29,7 +29,7 @@ namespace MediaBrowser.Controller.Entities
{
get
{
return true;
return false;
}
}