internal static YoutubeMediaInfo FromDynamicJson(dynamic Source) { var Result = new YoutubeMediaInfo { VideoID = Source.id, Description = Source.description, Title = Source.fulltitle, License = Source.license, Duration = TimeSpan.FromSeconds(Convert.ToDouble(Source.duration)) }; Result.Rating = new VideoRating( Likes: Convert.ToInt32(Source.like_count), Dislikes: Convert.ToInt32(Source.dislike_count) ); Result.Uploader = new VideoUploader( ProfileID: Source.uploader_id, ProfileName: Source.uploader, ProfileUri: Source.uploader_url ); if (Source.alt_title != null && Source.creator != null) { Result.RecognizedMedia = new SystemRecognizedMedia { Title = Source.alt_title, Artist = Source.creator }; } foreach (dynamic thumb in Source.thumbnails) { Result.Thumbnails.Add( new Thumbnail { ID = Convert.ToInt32(thumb.id), Uri = thumb.url } ); } foreach (dynamic tag in Source.tags) { Result.Keywords.Add(tag.ToString()); } foreach (dynamic format in Source.formats) { MediaFormat f = MediaFormat.DetectMediaFormat(format); if (f != null) { Result.MediaFormats.Add(f); } } return(Result); }
internal static MediaFormat DetectMediaFormat(dynamic Source) { MediaFormat Result = null; if (Source.format_note == "DASH audio") { Result = DashAudio.FromDynamic(Source); } else if (Source.format_note == "DASH video") { Result = DashVideo.FromDynamic(Source); } else { return(null); } Result.Note = Source.format_note; Result.FormatID = Convert.ToInt32(Source.format_id); Result.FileSize = Convert.ToInt32(Source.filesize); Result.Extension = Source.ext; return(Result); }