internal void Add(YoutubeVideoFormat item)
 {
     if (this.itemList.ContainsKey(item))
     {
         throw new ArgumentException("Item has already been added.", nameof(item));
     }
     // this.itemList.Add
     if (this.Content is WrapPanel wrapPanel)
     {
         YoutubeVideoFormatViewModel viewmodel = new YoutubeVideoFormatViewModel(item.FormatID);
         this.itemList.Add(item, viewmodel);
         wrapPanel.Children.Add(viewmodel);
     }
 }
示例#2
0
        // Extracts Youtube video formats available.
        public YoutubeVideoFormat[] ExtractFormats()
        {
            var streamMap    = ExtractStreamMap();
            var adpStreamMap = ExtractAdaptiveStreamMap();

            // Combine StreamMap and AdaptiveStreamMap into a single string then
            // split it into queries.
            var finalMap = streamMap + "," + adpStreamMap;
            var queries  = finalMap.Split(',');

            var vidFmts = new YoutubeVideoFormat[queries.Length];

            for (int i = 0; i < queries.Length; i++)
            {
                var queryParams = Utils.ParseQuery(queries[i]);

                if (!queryParams.Contains("url"))
                {
                    continue; //throw new ExtractionException("Query does not contain parameter 'url'.");
                }
                var url = Uri.UnescapeDataString((string)queryParams["url"]);

                var itag = -1;
                if (queryParams.Contains("itag"))
                {
                    itag = int.Parse((string)queryParams["itag"]);
                }

                var format = new YoutubeVideoFormat(itag)
                {
                    _videoUrl = new Uri(url)
                };
                vidFmts[i] = format;
            }

            return(vidFmts);
        }
 internal void Remove(YoutubeVideoFormat item)
 {
 }
示例#4
0
 public YoutubeVideoFormatDataContext(YoutubeVideoFormat format)
 {
     this.Format = format;
 }
 public override int Compare(YoutubeVideoFormat left, YoutubeVideoFormat right) => base.Compare(right, left);