示例#1
0
 private void GetTVEpisodeData(ITVEpisode payload, out string title, out IEnumerable <string> genres, out string description, out Stream image)
 {
     title       = payload.Title;
     genres      = payload.Parent.Parent.Genres;
     description = GetValueRecursive(d => !string.IsNullOrEmpty(d), () => payload.Description, () => payload.Parent.Description, () => payload.Parent.Parent.Description);
     image       = GetValueRecursive(d => d != null, () => payload.Parent.GetImage(), () => payload.Parent.Parent.GetImage());
 }
示例#2
0
        private bool TagMp4TVEpisode(ITVEpisode payload, IFileAbstraction target)
        {
            using (var file = Create(target))
            {
                file.RemoveTags(TagTypes.AllTags);
                var tag = (AppleTag)file.GetTag(TagTypes.Apple, true);
                GetTVEpisodeData(payload, out var title, out var genres, out var description, out var image);
                SetBasicProperties(tag, title, genres, description, image);

                SetPropertyIfValid(tag, $"https://www.themoviedb.org/tv/{payload.Parent.Parent.ID}", AppleDefaultBoxes.Url);
                tag.SetData(AppleDefaultBoxes.TvSeasonNumber, ByteVector.FromInt(payload.Parent.Number), 0);
                tag.SetData(AppleDefaultBoxes.TvEpisodeNumber, ByteVector.FromInt(payload.Number), 0);
                SetPropertyIfValid(tag, payload.Parent.Parent.Title, AppleDefaultBoxes.TvShowName);
                SetItunesMediaProperties(tag, file.Properties, AppleDefaultBoxes.ITunesMediaTypes.TVShow);
                file.Save();
            }

            return(true);
        }
示例#3
0
        private bool TagMkvTVEpisode(ITVEpisode payload, IFileAbstraction target)
        {
            using (var file = Create(target))
            {
                file.RemoveTags(TagTypes.AllTags);
                var tag = (TagLib.Matroska.Tag)file.GetTag(TagTypes.Matroska, true);
                GetTVEpisodeData(payload, out var title, out var genres, out var description, out var image);
                SetBasicProperties(tag, title, genres, description, image);

                SetPropertyIfValid(tag, "TV_SHOW", MkvMediaTypeLabel);
                SetPropertyIfValid(tag, payload.Parent.Parent.ID, payload.Parent.Parent.Parent.IDTagLabel);
                SetPropertyIfValid(tag, payload.Parent.Number.ToString(), "SEASON_NUMBER");
                SetPropertyIfValid(tag, payload.Number.ToString(), "EPISODE_NUMBER");
                SetPropertyIfValid(tag, payload.Parent.Parent.Title, "SHOW_TITLE");
                SetPropertyIfValid(tag, payload.Parent.Title, "SEASON_TITLE");
                file.Save();
            }

            return(true);
        }
示例#4
0
        public bool Tag(ITVEpisode payload, IFileAbstraction target)
        {
            try
            {
                if (MkvExtensions.Contains(Path.GetExtension(target.Name)))
                {
                    return(TagMkvTVEpisode(payload, target));
                }
                else if (Mp4Extensions.Contains(Path.GetExtension(target.Name)))
                {
                    return(TagMp4TVEpisode(payload, target));
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.Data);
                return(false);
            }

            return(false);
        }