private Option <string> LocatePoster(Season season, string seasonFolder)
    {
        string folder = Path.GetDirectoryName(seasonFolder) ?? string.Empty;

        return(ImageFileExtensions
               .Map(ext => Path.Combine(folder, $"season{season.SeasonNumber:00}-poster.{ext}"))
               .Filter(s => _localFileSystem.FileExists(s))
               .HeadOrNone());
    }
示例#2
0
    private Option <string> LocateThumbnail(MusicVideo musicVideo)
    {
        string path = musicVideo.MediaVersions.Head().MediaFiles.Head().Path;

        return(ImageFileExtensions
               .Map(ext => Path.ChangeExtension(path, ext))
               .Filter(f => _localFileSystem.FileExists(f))
               .HeadOrNone());
    }
    private Option <string> LocateThumbnail(Episode episode)
    {
        string path   = episode.MediaVersions.Head().MediaFiles.Head().Path;
        string folder = Path.GetDirectoryName(path) ?? string.Empty;

        return(ImageFileExtensions
               .Map(ext => Path.GetFileNameWithoutExtension(path) + $"-thumb.{ext}")
               .Map(f => Path.Combine(folder, f))
               .Filter(f => _localFileSystem.FileExists(f))
               .HeadOrNone());
    }
示例#4
0
    private Option <string> LocateThumbnail(Song song)
    {
        string path = song.MediaVersions.Head().MediaFiles.Head().Path;
        Option <DirectoryInfo> parent = Optional(Directory.GetParent(path));

        return(parent.Map(
                   di =>
        {
            string coverPath = Path.Combine(di.FullName, "cover.jpg");
            return ImageFileExtensions
            .Map(ext => Path.ChangeExtension(coverPath, ext))
            .Filter(f => _localFileSystem.FileExists(f))
            .HeadOrNone();
        }).Flatten());
    }
示例#5
0
    private Option <string> LocateArtworkForArtist(string artistFolder, ArtworkKind artworkKind)
    {
        string segment = artworkKind switch
        {
            ArtworkKind.Thumbnail => "thumb",
            ArtworkKind.FanArt => "fanart",
            _ => throw new ArgumentOutOfRangeException(nameof(artworkKind))
        };

        return(ImageFileExtensions
               .Map(ext => $"{segment}.{ext}")
               .Map(f => Path.Combine(artistFolder, f))
               .Filter(s => _localFileSystem.FileExists(s))
               .HeadOrNone());
    }
        private Option <string> LocateArtworkForShow(string showFolder, ArtworkKind artworkKind)
        {
            string[] segments = artworkKind switch
            {
                ArtworkKind.Poster => new[] { "poster", "folder" },
                ArtworkKind.FanArt => new[] { "fanart" },
                _ => throw new ArgumentOutOfRangeException(nameof(artworkKind))
            };

            return(ImageFileExtensions
                   .Map(ext => segments.Map(segment => $"{segment}.{ext}"))
                   .Flatten()
                   .Map(f => Path.Combine(showFolder, f))
                   .Filter(s => _localFileSystem.FileExists(s))
                   .HeadOrNone());
        }