aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs
diff options
context:
space:
mode:
authorAndrew Rabert <ar@nullsum.net>2018-12-27 18:27:57 -0500
committerAndrew Rabert <ar@nullsum.net>2018-12-27 18:27:57 -0500
commita86b71899ec52c44ddc6c3018e8cc5e9d7ff4d62 (patch)
treea74f6ea4a8abfa1664a605d31d48bc38245ccf58 /MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs
parent9bac3ac616b01f67db98381feb09d34ebe821f9a (diff)
Add GPL modules
Diffstat (limited to 'MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs')
-rw-r--r--MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs53
1 files changed, 53 insertions, 0 deletions
diff --git a/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs b/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs
new file mode 100644
index 000000000..70e4db84f
--- /dev/null
+++ b/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs
@@ -0,0 +1,53 @@
+using MediaBrowser.Model.IO;
+using MediaBrowser.Model.MediaInfo;
+using System;
+using System.IO;
+using System.Linq;
+
+namespace MediaBrowser.Controller.MediaEncoding
+{
+ /// <summary>
+ /// Class MediaEncoderHelpers
+ /// </summary>
+ public static class MediaEncoderHelpers
+ {
+ /// <summary>
+ /// Gets the input argument.
+ /// </summary>
+ /// <param name="fileSystem">The file system.</param>
+ /// <param name="videoPath">The video path.</param>
+ /// <param name="protocol">The protocol.</param>
+ /// <param name="isoMount">The iso mount.</param>
+ /// <param name="playableStreamFileNames">The playable stream file names.</param>
+ /// <returns>System.String[][].</returns>
+ public static string[] GetInputArgument(IFileSystem fileSystem, string videoPath, MediaProtocol protocol, IIsoMount isoMount, string[] playableStreamFileNames)
+ {
+ if (playableStreamFileNames.Length > 0)
+ {
+ if (isoMount == null)
+ {
+ return GetPlayableStreamFiles(fileSystem, videoPath, playableStreamFileNames);
+ }
+ return GetPlayableStreamFiles(fileSystem, isoMount.MountedPath, playableStreamFileNames);
+ }
+
+ return new[] {videoPath};
+ }
+
+ private static string[] GetPlayableStreamFiles(IFileSystem fileSystem, string rootPath, string[] filenames)
+ {
+ if (filenames.Length == 0)
+ {
+ return new string[]{};
+ }
+
+ var allFiles = fileSystem
+ .GetFilePaths(rootPath, true)
+ .ToArray();
+
+ return filenames.Select(name => allFiles.FirstOrDefault(f => string.Equals(Path.GetFileName(f), name, StringComparison.OrdinalIgnoreCase)))
+ .Where(f => !string.IsNullOrEmpty(f))
+ .ToArray();
+ }
+ }
+}