Parses a given HLS playlist and checks for any substreams
Пример #1
0
 public override List<string> GetMultipleVideoUrls(VideoInfo video, bool inPlaylist = false)
 {
     video.PlaybackOptions = new Dictionary<string, string>();
     string videoUrl = video.VideoUrl;
     if (videoUrl.EndsWith(".m3u8"))
     {
         MyHlsPlaylistParser parser = new MyHlsPlaylistParser(GetWebData(videoUrl), videoUrl);
         foreach (MyHlsStreamInfo streamInfo in parser.StreamInfos)
             video.PlaybackOptions.Add(string.Format("{0}x{1} ({2}kbps)", streamInfo.Width, streamInfo.Height, streamInfo.Bandwidth), streamInfo.Url);
     }
     else
     {
         HosterBase hoster = HosterFactory.GetAllHosters().FirstOrDefault<HosterBase>((HosterBase h) => videoUrl.ToLower().Contains(h.GetHosterUrl().ToLower()));
         if (hoster != null)
         {
             video.PlaybackOptions = hoster.GetPlaybackOptions(videoUrl);
             if (hoster is ISubtitle)
                 video.SubtitleText = (hoster as ISubtitle).SubtitleText;
         }
     }
     if (video.PlaybackOptions.Count == 0)
         return new List<string>();
     string  url = video.PlaybackOptions.First<KeyValuePair<string, string>>().Value;
         if (inPlaylist)
             video.PlaybackOptions.Clear();
         return new List<string>() { url };
 }
Пример #2
0
 public override List<string> GetMultipleVideoUrls(VideoInfo video, bool inPlaylist = false)
 {
     string url = "";
     Regex regex = new Regex(@"""HttpLiveStreaming"",""mobileUrl"":""(?<url>[^""]*)");
     Match m = regex.Match(GetWebData(video.VideoUrl));
     if (m.Success)
     {
         string playlistUrl = m.Groups["url"].Value;
         MyHlsPlaylistParser playlist = new MyHlsPlaylistParser(GetWebData(playlistUrl), playlistUrl);
         video.PlaybackOptions = new Dictionary<string, string>();
         if (playlist.StreamInfos.Count > 0)
         {
             foreach (MyHlsStreamInfo si in playlist.StreamInfos)
             {
                 string key = "Bitrate: " + si.Bandwidth;
                 if (!video.PlaybackOptions.ContainsKey(key))
                     video.PlaybackOptions.Add("Bitrate: " + si.Bandwidth, si.Url);
             }
             url = video.PlaybackOptions.First().Value;
         }
         if (inPlaylist)
             video.PlaybackOptions.Clear();
     }
     return new List<string>() { url };
 }