mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-03 14:28:46 +01:00
improve cancellation support of auto-organize
This commit is contained in:
@@ -72,17 +72,24 @@ namespace Emby.Server.Implementations.FileOrganization
|
||||
|
||||
foreach (var file in eligibleFiles)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
var organizer = new EpisodeFileOrganizer(_organizationService, _config, _fileSystem, _logger, _libraryManager,
|
||||
_libraryMonitor, _providerManager);
|
||||
|
||||
try
|
||||
{
|
||||
var result = await organizer.OrganizeEpisodeFile(file.FullName, options, options.TvOptions.OverwriteExistingEpisodes, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result.Status == FileSortingStatus.Success && !processedFolders.Contains(file.DirectoryName, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
processedFolders.Add(file.DirectoryName);
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
break;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error organizing episode {0}", ex, file.FullName);
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.MediaEncoding;
|
||||
using MediaBrowser.Model.Dlna;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
|
||||
namespace Emby.Server.Implementations.LiveTv
|
||||
@@ -29,6 +30,8 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
|
||||
var now = DateTime.UtcNow;
|
||||
|
||||
var allowVideoStreamCopy = mediaSource.MediaStreams.Any(i => i.Type == MediaStreamType.Video && i.AllowStreamCopy);
|
||||
|
||||
var info = await _mediaEncoder.GetMediaInfo(new MediaInfoRequest
|
||||
{
|
||||
InputPath = mediaSource.Path,
|
||||
@@ -73,6 +76,8 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
var videoStream = mediaSource.MediaStreams.FirstOrDefault(i => i.Type == MediaBrowser.Model.Entities.MediaStreamType.Video);
|
||||
if (videoStream != null)
|
||||
{
|
||||
videoStream.AllowStreamCopy = allowVideoStreamCopy;
|
||||
|
||||
if (!videoStream.BitRate.HasValue)
|
||||
{
|
||||
var width = videoStream.Width ?? 1920;
|
||||
|
||||
@@ -261,7 +261,7 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
return info.Item1;
|
||||
}
|
||||
|
||||
public Task<Tuple<MediaSourceInfo, IDirectStreamProvider, bool>> GetChannelStream(string id, string mediaSourceId, CancellationToken cancellationToken)
|
||||
public Task<Tuple<MediaSourceInfo, IDirectStreamProvider>> GetChannelStream(string id, string mediaSourceId, CancellationToken cancellationToken)
|
||||
{
|
||||
return GetLiveStream(id, mediaSourceId, true, cancellationToken);
|
||||
}
|
||||
@@ -323,7 +323,7 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
return _services.FirstOrDefault(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
private async Task<Tuple<MediaSourceInfo, IDirectStreamProvider, bool>> GetLiveStream(string id, string mediaSourceId, bool isChannel, CancellationToken cancellationToken)
|
||||
private async Task<Tuple<MediaSourceInfo, IDirectStreamProvider>> GetLiveStream(string id, string mediaSourceId, bool isChannel, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.Equals(id, mediaSourceId, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
@@ -334,7 +334,6 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
bool isVideo;
|
||||
ILiveTvService service;
|
||||
IDirectStreamProvider directStreamProvider = null;
|
||||
var assumeInterlaced = false;
|
||||
|
||||
if (isChannel)
|
||||
{
|
||||
@@ -383,12 +382,7 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
|
||||
Normalize(info, service, isVideo);
|
||||
|
||||
if (!(service is EmbyTV.EmbyTV))
|
||||
{
|
||||
assumeInterlaced = true;
|
||||
}
|
||||
|
||||
return new Tuple<MediaSourceInfo, IDirectStreamProvider, bool>(info, directStreamProvider, assumeInterlaced);
|
||||
return new Tuple<MediaSourceInfo, IDirectStreamProvider>(info, directStreamProvider);
|
||||
}
|
||||
|
||||
private void Normalize(MediaSourceInfo mediaSource, ILiveTvService service, bool isVideo)
|
||||
@@ -492,6 +486,12 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
{
|
||||
stream.NalLengthSize = "0";
|
||||
}
|
||||
|
||||
if (stream.Type == MediaStreamType.Video)
|
||||
{
|
||||
stream.IsInterlaced = true;
|
||||
stream.AllowStreamCopy = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
openKeys.Add(item.Id.ToString("N"));
|
||||
openKeys.Add(source.Id ?? string.Empty);
|
||||
source.OpenToken = string.Join(StreamIdDelimeterString, openKeys.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
// Dummy this up so that direct play checks can still run
|
||||
if (string.IsNullOrEmpty(source.Path) && source.Protocol == MediaProtocol.Http)
|
||||
@@ -142,7 +142,7 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
{
|
||||
if (!stream.SupportsProbing || stream.MediaStreams.Any(i => i.Index != -1))
|
||||
{
|
||||
await AddMediaInfo(stream, isAudio, cancellationToken).ConfigureAwait(false);
|
||||
AddMediaInfo(stream, isAudio, cancellationToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -158,7 +158,7 @@ namespace Emby.Server.Implementations.LiveTv
|
||||
return new Tuple<MediaSourceInfo, IDirectStreamProvider>(stream, directStreamProvider);
|
||||
}
|
||||
|
||||
private async Task AddMediaInfo(MediaSourceInfo mediaSource, bool isAudio, CancellationToken cancellationToken)
|
||||
private void AddMediaInfo(MediaSourceInfo mediaSource, bool isAudio, CancellationToken cancellationToken)
|
||||
{
|
||||
mediaSource.DefaultSubtitleStreamIndex = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user