using System.Collections.Generic; using System.Collections.Immutable; using System.IO; namespace Kyoo.Core.Models.Watch { /// /// A static class allowing one to identify files extensions. /// public static class FileExtensions { /// /// The list of known video extensions /// public static readonly ImmutableArray VideoExtensions = ImmutableArray.Create( ".webm", ".mkv", ".flv", ".vob", ".ogg", ".ogv", ".avi", ".mts", ".m2ts", ".ts", ".mov", ".qt", ".asf", ".mp4", ".m4p", ".m4v", ".mpg", ".mp2", ".mpeg", ".mpe", ".mpv", ".m2v", ".3gp", ".3g2" ); /// /// Check if a file represent a video file (only by checking the extension of the file) /// /// The path of the file to check /// true if the file is a video file, false otherwise. public static bool IsVideo(string filePath) { return VideoExtensions.Contains(Path.GetExtension(filePath)); } /// /// The dictionary of known subtitles extensions and the name of the subtitle codec. /// public static readonly ImmutableDictionary SubtitleExtensions = new Dictionary { {".ass", "ass"}, {".str", "subrip"} }.ToImmutableDictionary(); /// /// Check if a file represent a subtitle file (only by checking the extension of the file) /// /// The path of the file to check /// true if the file is a subtitle file, false otherwise. public static bool IsSubtitle(string filePath) { return SubtitleExtensions.ContainsKey(Path.GetExtension(filePath)); } } }