aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2017-11-20 13:02:59 -0500
committerGitHub <noreply@github.com>2017-11-20 13:02:59 -0500
commit8f78652398ad4e9e9af53a1bd065afe4b9d9260e (patch)
tree32bc4144212d7f6ee3941c9c2471b56ab9c5d3e2 /MediaBrowser.Controller
parent7d15b140cfe4f761e03f661f82cf946f327863f5 (diff)
parent71ff88284be60fb39a7389e0c4990c94f2207ed4 (diff)
Merge pull request #3032 from MediaBrowser/beta
Beta
Diffstat (limited to 'MediaBrowser.Controller')
-rw-r--r--MediaBrowser.Controller/Entities/BaseItem.cs7
-rw-r--r--MediaBrowser.Controller/Entities/CollectionFolder.cs15
-rw-r--r--MediaBrowser.Controller/Entities/Folder.cs12
-rw-r--r--MediaBrowser.Controller/Entities/Video.cs78
-rw-r--r--MediaBrowser.Controller/IO/StreamHelper.cs23
-rw-r--r--MediaBrowser.Controller/LiveTv/ITunerHost.cs2
-rw-r--r--MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs16
-rw-r--r--MediaBrowser.Controller/MediaEncoding/IEncodingManager.cs3
-rw-r--r--MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs3
-rw-r--r--MediaBrowser.Controller/Providers/DirectoryService.cs52
-rw-r--r--MediaBrowser.Controller/Providers/IDirectoryService.cs3
11 files changed, 105 insertions, 109 deletions
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index 5b4cd59001..f6a8f1d5a4 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -1376,11 +1376,6 @@ namespace MediaBrowser.Controller.Entities
return list;
}
- internal virtual bool IsValidFromResolver(BaseItem newItem)
- {
- return true;
- }
-
internal virtual ItemUpdateType UpdateFromResolvedItem(BaseItem newItem)
{
var updateType = ItemUpdateType.None;
@@ -2045,7 +2040,7 @@ namespace MediaBrowser.Controller.Entities
.Where(i => i.IsLocalFile)
.Select(i => FileSystem.GetDirectoryName(i.Path))
.Distinct(StringComparer.OrdinalIgnoreCase)
- .SelectMany(i => FileSystem.GetFilePaths(i))
+ .SelectMany(i => directoryService.GetFilePaths(i))
.ToList();
var deletedImages = ImageInfos
diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs
index 5fb9e517c8..03fca60c89 100644
--- a/MediaBrowser.Controller/Entities/CollectionFolder.cs
+++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs
@@ -265,21 +265,6 @@ namespace MediaBrowser.Controller.Entities
return changed;
}
- internal override bool IsValidFromResolver(BaseItem newItem)
- {
- var newCollectionFolder = newItem as CollectionFolder;
-
- if (newCollectionFolder != null)
- {
- if (!string.Equals(CollectionType, newCollectionFolder.CollectionType, StringComparison.OrdinalIgnoreCase))
- {
- return false;
- }
- }
-
- return base.IsValidFromResolver(newItem);
- }
-
private ItemResolveArgs CreateResolveArgs(IDirectoryService directoryService, bool setPhysicalLocations)
{
var path = ContainingFolderPath;
diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs
index 12183aec2f..504d03a276 100644
--- a/MediaBrowser.Controller/Entities/Folder.cs
+++ b/MediaBrowser.Controller/Entities/Folder.cs
@@ -416,7 +416,7 @@ namespace MediaBrowser.Controller.Entities
{
BaseItem currentChild;
- if (currentChildren.TryGetValue(child.Id, out currentChild) && currentChild.IsValidFromResolver(child))
+ if (currentChildren.TryGetValue(child.Id, out currentChild))
{
validChildren.Add(currentChild);
@@ -1421,6 +1421,16 @@ namespace MediaBrowser.Controller.Entities
// Sweep through recursively and update status
foreach (var item in itemsResult)
{
+ if (item.IsVirtualItem)
+ {
+ // The querying doesn't support virtual unaired
+ var episode = item as Episode;
+ if (episode != null && episode.IsUnaired)
+ {
+ continue;
+ }
+ }
+
item.MarkPlayed(user, datePlayed, resetPosition);
}
}
diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs
index 52f1dd0514..dca1cfd01b 100644
--- a/MediaBrowser.Controller/Entities/Video.cs
+++ b/MediaBrowser.Controller/Entities/Video.cs
@@ -84,6 +84,20 @@ namespace MediaBrowser.Controller.Entities
}
}
+ public void SetPrimaryVersionId(string id)
+ {
+ if (string.IsNullOrWhiteSpace(id))
+ {
+ PrimaryVersionId = null;
+ }
+ else
+ {
+ PrimaryVersionId = id;
+ }
+
+ PresentationUniqueKey = CreatePresentationUniqueKey();
+ }
+
public override string CreatePresentationUniqueKey()
{
if (!string.IsNullOrWhiteSpace(PrimaryVersionId))
@@ -667,8 +681,6 @@ namespace MediaBrowser.Controller.Entities
throw new ArgumentNullException("media");
}
- var mediaStreams = MediaSourceManager.GetMediaStreams(media.Id);
-
var locationType = media.LocationType;
var info = new MediaSourceInfo
@@ -676,8 +688,8 @@ namespace MediaBrowser.Controller.Entities
Id = media.Id.ToString("N"),
IsoType = media.IsoType,
Protocol = locationType == LocationType.Remote ? MediaProtocol.Http : MediaProtocol.File,
- MediaStreams = mediaStreams,
- Name = GetMediaSourceName(media, mediaStreams),
+ MediaStreams = MediaSourceManager.GetMediaStreams(media.Id),
+ Name = GetMediaSourceName(media),
Path = enablePathSubstitution ? GetMappedPath(media, media.Path, locationType) : media.Path,
RunTimeTicks = media.RunTimeTicks,
Video3DFormat = media.Video3DFormat,
@@ -740,12 +752,20 @@ namespace MediaBrowser.Controller.Entities
return info;
}
- private static string GetMediaSourceName(Video video, List<MediaStream> mediaStreams)
+ private static string GetMediaSourceName(Video video)
{
var terms = new List<string>();
- var videoStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Video);
- var audioStream = mediaStreams.FirstOrDefault(i => i.Type == MediaStreamType.Audio);
+ var locationType = video.LocationType;
+ var path = video.Path;
+ if ((locationType == LocationType.FileSystem || locationType == LocationType.Offline) && !string.IsNullOrWhiteSpace(path))
+ {
+ terms.Add(System.IO.Path.GetFileName(path));
+ }
+ else
+ {
+ terms.Add(video.Name);
+ }
if (video.Video3DFormat.HasValue)
{
@@ -779,50 +799,6 @@ namespace MediaBrowser.Controller.Entities
}
}
- if (videoStream != null)
- {
- if (videoStream.Width.HasValue)
- {
- if (videoStream.Width.Value >= 3800)
- {
- terms.Add("4K");
- }
- else if (videoStream.Width.Value >= 1900)
- {
- terms.Add("1080P");
- }
- else if (videoStream.Width.Value >= 1270)
- {
- terms.Add("720P");
- }
- else if (videoStream.Width.Value >= 700)
- {
- terms.Add("480P");
- }
- else
- {
- terms.Add("SD");
- }
- }
- }
-
- if (videoStream != null && !string.IsNullOrWhiteSpace(videoStream.Codec))
- {
- terms.Add(videoStream.Codec.ToUpper());
- }
-
- if (audioStream != null)
- {
- var audioCodec = string.Equals(audioStream.Codec, "dca", StringComparison.OrdinalIgnoreCase)
- ? audioStream.Profile
- : audioStream.Codec;
-
- if (!string.IsNullOrEmpty(audioCodec))
- {
- terms.Add(audioCodec.ToUpper());
- }
- }
-
return string.Join("/", terms.ToArray(terms.Count));
}
diff --git a/MediaBrowser.Controller/IO/StreamHelper.cs b/MediaBrowser.Controller/IO/StreamHelper.cs
index 106fec41fc..5aec9a1828 100644
--- a/MediaBrowser.Controller/IO/StreamHelper.cs
+++ b/MediaBrowser.Controller/IO/StreamHelper.cs
@@ -1,6 +1,7 @@
using System.IO;
using System.Threading;
using System;
+using System.Threading.Tasks;
namespace MediaBrowser.Controller.IO
{
@@ -23,5 +24,27 @@ namespace MediaBrowser.Controller.IO
}
}
}
+
+ public static async Task CopyToAsync(Stream source, Stream destination, int bufferSize, IProgress<double> progress, long contentLength, CancellationToken cancellationToken)
+ {
+ byte[] buffer = new byte[bufferSize];
+ int read;
+ long totalRead = 0;
+
+ while ((read = source.Read(buffer, 0, buffer.Length)) != 0)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+
+ destination.Write(buffer, 0, read);
+
+ totalRead += read;
+
+ double pct = totalRead;
+ pct /= contentLength;
+ pct *= 100;
+
+ progress.Report(pct);
+ }
+ }
}
}
diff --git a/MediaBrowser.Controller/LiveTv/ITunerHost.cs b/MediaBrowser.Controller/LiveTv/ITunerHost.cs
index 523eec24ac..242011db06 100644
--- a/MediaBrowser.Controller/LiveTv/ITunerHost.cs
+++ b/MediaBrowser.Controller/LiveTv/ITunerHost.cs
@@ -63,8 +63,8 @@ namespace MediaBrowser.Controller.LiveTv
void Close();
int ConsumerCount { get; }
string OriginalStreamId { get; set; }
+ string TunerHostId { get; }
bool EnableStreamSharing { get; set; }
- ITunerHost TunerHost { get; set; }
MediaSourceInfo OpenedMediaSource { get; set; }
string UniqueId { get; }
List<string> SharedStreamIds { get; }
diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
index bddafe9a6a..8f8791922d 100644
--- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
+++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
@@ -1325,6 +1325,8 @@ namespace MediaBrowser.Controller.MediaEncoding
if (state.VideoStream != null && state.VideoStream.Width.HasValue && state.VideoStream.Height.HasValue)
{
videoSizeParam = string.Format("scale={0}:{1}", state.VideoStream.Width.Value.ToString(_usCulture), state.VideoStream.Height.Value.ToString(_usCulture));
+
+ videoSizeParam += ":force_original_aspect_ratio=decrease";
}
var mapPrefix = state.SubtitleStream.IsExternal ?
@@ -1335,7 +1337,7 @@ namespace MediaBrowser.Controller.MediaEncoding
? 0
: state.SubtitleStream.Index;
- return string.Format(" -filter_complex \"[{0}:{1}]{4}[sub] ; [0:{2}] [sub] overlay{3}\"",
+ return string.Format(" -filter_complex \"[{0}:{1}]{4}[sub];[0:{2}][sub]overlay{3}\"",
mapPrefix.ToString(_usCulture),
subtitleStreamIndex.ToString(_usCulture),
state.VideoStream.Index.ToString(_usCulture),
@@ -2094,6 +2096,12 @@ namespace MediaBrowser.Controller.MediaEncoding
args += " -avoid_negative_ts disabled -start_at_zero";
}
+ // This is for internal graphical subs
+ if (hasGraphicalSubs)
+ {
+ args += GetGraphicalSubtitleParam(state, encodingOptions, videoCodec);
+ }
+
var qualityParam = GetVideoQualityParam(state, videoCodec, encodingOptions, defaultH264Preset);
if (!string.IsNullOrEmpty(qualityParam))
@@ -2101,12 +2109,6 @@ namespace MediaBrowser.Controller.MediaEncoding
args += " " + qualityParam.Trim();
}
- // This is for internal graphical subs
- if (hasGraphicalSubs)
- {
- args += GetGraphicalSubtitleParam(state, encodingOptions, videoCodec);
- }
-
if (!state.RunTimeTicks.HasValue)
{
args += " -flags -global_header";
diff --git a/MediaBrowser.Controller/MediaEncoding/IEncodingManager.cs b/MediaBrowser.Controller/MediaEncoding/IEncodingManager.cs
index 81269fe3fa..7d50efd5ed 100644
--- a/MediaBrowser.Controller/MediaEncoding/IEncodingManager.cs
+++ b/MediaBrowser.Controller/MediaEncoding/IEncodingManager.cs
@@ -3,6 +3,7 @@ using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Entities;
+using MediaBrowser.Controller.Providers;
namespace MediaBrowser.Controller.MediaEncoding
{
@@ -11,6 +12,6 @@ namespace MediaBrowser.Controller.MediaEncoding
/// <summary>
/// Refreshes the chapter images.
/// </summary>
- Task<bool> RefreshChapterImages(Video video, List<ChapterInfo> chapters, bool extractImages, bool saveChapters, CancellationToken cancellationToken);
+ Task<bool> RefreshChapterImages(Video video, IDirectoryService directoryService, List<ChapterInfo> chapters, bool extractImages, bool saveChapters, CancellationToken cancellationToken);
}
}
diff --git a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs
index 31cd96c9a6..2712380c70 100644
--- a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs
+++ b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs
@@ -118,9 +118,6 @@ namespace MediaBrowser.Controller.MediaEncoding
void UpdateEncoderPath(string path, string pathType);
bool SupportsEncoder(string encoder);
- void SetLogFilename(string name);
- void ClearLogFilename();
-
string[] GetPlayableStreamFileNames(string path, VideoType videoType);
IEnumerable<string> GetPrimaryPlaylistVobFiles(string path, IIsoMount isoMount, uint? titleNumber);
}
diff --git a/MediaBrowser.Controller/Providers/DirectoryService.cs b/MediaBrowser.Controller/Providers/DirectoryService.cs
index d957470d3b..d673198fdc 100644
--- a/MediaBrowser.Controller/Providers/DirectoryService.cs
+++ b/MediaBrowser.Controller/Providers/DirectoryService.cs
@@ -14,11 +14,11 @@ namespace MediaBrowser.Controller.Providers
private readonly ILogger _logger;
private readonly IFileSystem _fileSystem;
- private readonly ConcurrentDictionary<string, FileSystemMetadata[]> _cache =
- new ConcurrentDictionary<string, FileSystemMetadata[]>(StringComparer.OrdinalIgnoreCase);
+ private readonly Dictionary<string, FileSystemMetadata[]> _cache = new Dictionary<string, FileSystemMetadata[]>(StringComparer.OrdinalIgnoreCase);
- private readonly ConcurrentDictionary<string, FileSystemMetadata> _fileCache =
- new ConcurrentDictionary<string, FileSystemMetadata>(StringComparer.OrdinalIgnoreCase);
+ private readonly Dictionary<string, FileSystemMetadata> _fileCache = new Dictionary<string, FileSystemMetadata>(StringComparer.OrdinalIgnoreCase);
+
+ private readonly Dictionary<string, List<string>> _filePathCache = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);
public DirectoryService(ILogger logger, IFileSystem fileSystem)
{
@@ -33,11 +33,6 @@ namespace MediaBrowser.Controller.Providers
public FileSystemMetadata[] GetFileSystemEntries(string path)
{
- return GetFileSystemEntries(path, false);
- }
-
- private FileSystemMetadata[] GetFileSystemEntries(string path, bool clearCache)
- {
if (string.IsNullOrWhiteSpace(path))
{
throw new ArgumentNullException("path");
@@ -45,13 +40,6 @@ namespace MediaBrowser.Controller.Providers
FileSystemMetadata[] entries;
- if (clearCache)
- {
- FileSystemMetadata[] removed;
-
- _cache.TryRemove(path, out removed);
- }
-
if (!_cache.TryGetValue(path, out entries))
{
//_logger.Debug("Getting files for " + path);
@@ -66,7 +54,8 @@ namespace MediaBrowser.Controller.Providers
entries = new FileSystemMetadata[] { };
}
- _cache.TryAdd(path, entries);
+ //_cache.TryAdd(path, entries);
+ _cache[path] = entries;
}
return entries;
@@ -74,13 +63,8 @@ namespace MediaBrowser.Controller.Providers
public List<FileSystemMetadata> GetFiles(string path)
{
- return GetFiles(path, false);
- }
-
- public List<FileSystemMetadata> GetFiles(string path, bool clearCache)
- {
var list = new List<FileSystemMetadata>();
- var items = GetFileSystemEntries(path, clearCache);
+ var items = GetFileSystemEntries(path);
foreach (var item in items)
{
if (!item.IsDirectory)
@@ -100,7 +84,8 @@ namespace MediaBrowser.Controller.Providers
if (file != null && file.Exists)
{
- _fileCache.TryAdd(path, file);
+ //_fileCache.TryAdd(path, file);
+ _fileCache[path] = file;
}
else
{
@@ -111,5 +96,24 @@ namespace MediaBrowser.Controller.Providers
return file;
//return _fileSystem.GetFileInfo(path);
}
+
+ public List<string> GetFilePaths(string path)
+ {
+ return GetFilePaths(path, false);
+ }
+
+ public List<string> GetFilePaths(string path, bool clearCache)
+ {
+ List<string> result;
+ if (clearCache || !_filePathCache.TryGetValue(path, out result))
+ {
+ result = _fileSystem.GetFilePaths(path).ToList();
+
+ _filePathCache[path] = result;
+ }
+
+ return result;
+ }
+
}
}
diff --git a/MediaBrowser.Controller/Providers/IDirectoryService.cs b/MediaBrowser.Controller/Providers/IDirectoryService.cs
index 6f864f4be2..0b4574f6e5 100644
--- a/MediaBrowser.Controller/Providers/IDirectoryService.cs
+++ b/MediaBrowser.Controller/Providers/IDirectoryService.cs
@@ -8,5 +8,8 @@ namespace MediaBrowser.Controller.Providers
FileSystemMetadata[] GetFileSystemEntries(string path);
List<FileSystemMetadata> GetFiles(string path);
FileSystemMetadata GetFile(string path);
+
+ List<string> GetFilePaths(string path);
+ List<string> GetFilePaths(string path, bool clearCache);
}
} \ No newline at end of file