Inheritance: System.VideoInfo
        public List <VideoInfo> GetJsonVideos(LastFmCategory category, int currentPage)
        {
            List <VideoInfo> videos     = new List <VideoInfo>();
            string           currentUrl = category.Url;
            bool             paginate   = currentUrl.EndsWith("{0}");
            string           url        = paginate ? string.Format(currentUrl, currentPage) : currentUrl;
            JObject          json       = GetWebData <JObject>(url, cookies: Cookies, cache: false);

            foreach (JToken song in json["playlist"])
            {
                JToken playlink = song["playlinks"].First(pl => pl["affiliate"].Value <string>() == "youtube");
                if (playlink != null)
                {
                    try
                    {
                        bool        addVideo = true;
                        LastFmVideo video    = new LastFmVideo();
                        if (filterOutUnplayable)
                        {
                            Dictionary <string, string> pbos = Hoster.HosterFactory.GetHoster("youtube").GetPlaybackOptions(playlink["url"].Value <string>());
                            video.Other = pbos;
                            addVideo    = pbos != null && pbos.Count > 0;
                        }
                        if (addVideo)
                        {
                            video.Artist   = song["artists"].First()["name"].Value <string>();
                            video.Track    = song["name"].Value <string>();
                            video.Title    = video.Artist + " - " + video.Track;
                            video.VideoUrl = playlink["url"].Value <string>();
                            if (song["duration"] == null || song["duration"].Type == JTokenType.Null)
                            {
                                video.Duration = 0;
                            }
                            else
                            {
                                video.Duration = song["duration"].Value <int>();
                                video.Length   = OnlineVideos.Helpers.TimeUtils.TimeFromSeconds(video.Duration.ToString());
                            }
                            string trackUrl = song["url"].Value <string>();
                            Regex  regex    = new Regex(@"^/music/(?<artist>[^/]*)/[^/]*/(?<track>.*?)$");
                            Match  m        = regex.Match(trackUrl);
                            if (m.Success)
                            {
                                video.ArtistSlug = m.Groups["artist"].Value;
                                video.TrackSlug  = m.Groups["track"].Value;
                            }
                            videos.Add(video);
                        }
                    }
                    catch (OnlineVideosException e)
                    {
                        Log.Debug("Not a playable video, Url: {0}, message: {1}", playlink["url"].Value <string>(), e.Message);
                    }
                }
            }
            HasNextPage = paginate;
            if (HasNextPage)
            {
                currentVideoMethod = (Func <List <VideoInfo> >)(() => GetJsonVideos(category, currentPage + 1));
            }
            return(videos);
        }
 public List<VideoInfo> GetJsonVideos(LastFmCategory category, int currentPage)
 {
     List<VideoInfo> videos = new List<VideoInfo>();
     string currentUrl = category.Url;
     bool paginate = currentUrl.EndsWith("{0}");
     string url = paginate ? string.Format(currentUrl, currentPage) : currentUrl;
     JObject json = GetWebData<JObject>(url, cookies: Cookies, cache: false);
     foreach (JToken song in json["playlist"])
     {
         JToken playlink = song["playlinks"].First(pl => pl["affiliate"].Value<string>() == "youtube");
         if (playlink != null)
         {
             try
             {
                 bool addVideo = true;
                 LastFmVideo video = new LastFmVideo();
                 if (filterOutUnplayable)
                 {
                     Dictionary<string, string> pbos = Hoster.HosterFactory.GetHoster("youtube").GetPlaybackOptions(playlink["url"].Value<string>());
                     video.Other = pbos;
                     addVideo = pbos != null && pbos.Count > 0;
                 }
                 if (addVideo)
                 {
                     video.Artist = song["artists"].First()["name"].Value<string>();
                     video.Track = song["name"].Value<string>();
                     video.Title = video.Artist + " - " + video.Track;
                     video.VideoUrl = playlink["url"].Value<string>();
                     if (song["duration"] == null || song["duration"].Type == JTokenType.Null)
                     {
                         video.Duration = 0;
                     }
                     else
                     {
                         video.Duration = song["duration"].Value<int>();
                         video.Length = OnlineVideos.Helpers.TimeUtils.TimeFromSeconds(video.Duration.ToString());
                     }
                     string trackUrl = song["url"].Value<string>();
                     Regex regex = new Regex(@"^/music/(?<artist>[^/]*)/[^/]*/(?<track>.*?)$");
                     Match m = regex.Match(trackUrl);
                     if (m.Success)
                     {
                         video.ArtistSlug = m.Groups["artist"].Value;
                         video.TrackSlug = m.Groups["track"].Value;
                     }
                     videos.Add(video);
                 }
             }
             catch (OnlineVideosException e)
             {
                 Log.Debug("Not a playable video, Url: {0}, message: {1}", playlink["url"].Value<string>(), e.Message);
             }
         }
     }
     HasNextPage = paginate;
     if (HasNextPage)
         currentVideoMethod = (Func<List<VideoInfo>>)(() => GetJsonVideos(category, currentPage + 1));
     return videos;
 }
        private List <VideoInfo> GetHtmlVideos(LastFmCategory category, int currentPage, SerializableDictionary <string, string> parameters, bool skipNextPage = false)
        {
            List <VideoInfo> videos = new List <VideoInfo>();
            string           url    = category.Url;

            url += "?" + "_pjax=%23content&page=" + currentPage;
            if (parameters != null)
            {
                foreach (KeyValuePair <string, string> param in parameters)
                {
                    url += "&" + param.Key + "=" + param.Value;
                }
            }
            string data = GetWebData(url, cookies: Cookies, referer: category.Url);
            Regex  regex;

            if (url.Contains("/library"))
            {
                regex = new Regex(@"""chartlist-play-image"">[^<]*<img src=""(?<img>[^""]*)[^<]*?<a[^>]*?href=""(?<url>https{0,1}://www.youtube.com/watch[^""]*)[^>]*?data-track-name=""(?<track>[^""]*)[^>]*?data-track-url=""(?<slug>[^""]*)[^>]*?data-artist-name=""(?<artist>[^""]*)", RegexOptions.Singleline);
            }
            else
            {
                regex = new Regex(@"""chartlist-play"">[^<]*<a[^>]*?href=""(?<url>https{0,1}://www.youtube.com/watch[^""]*)[^>]*?data-track-name=""(?<track>[^""]*)[^>]*?data-track-url=""(?<slug>[^""]*)[^>]*?data-artist-name=""(?<artist>[^""]*)", RegexOptions.Singleline);
            }
            foreach (Match m in regex.Matches(data))
            {
                try
                {
                    bool        addVideo = true;
                    LastFmVideo track    = new LastFmVideo();
                    if (filterOutUnplayable)
                    {
                        Dictionary <string, string> pbos = Hoster.HosterFactory.GetHoster("youtube").GetPlaybackOptions(m.Groups["url"].Value);
                        track.Other = pbos;
                        addVideo    = pbos != null && pbos.Count > 0;
                    }
                    if (addVideo)
                    {
                        Regex  trackRegex = new Regex(@"^/music/(?<artist>[^/]*)/[^/]*/(?<track>.*?)$");
                        string trackUrl   = m.Groups["slug"].Value;
                        Match  trackMatch = trackRegex.Match(trackUrl);
                        if (trackMatch.Success)
                        {
                            track.ArtistSlug = trackMatch.Groups["artist"].Value;
                            track.TrackSlug  = trackMatch.Groups["track"].Value;
                            track.Track      = m.Groups["track"].Value;
                            track.Artist     = m.Groups["artist"].Value;
                            track.VideoUrl   = m.Groups["url"].Value;
                            track.Thumb      = m.Groups["img"].Value;
                            track.Title      = track.Artist + " - " + track.Track;
                            videos.Add(track);
                        }
                    }
                }
                catch (OnlineVideosException e)
                {
                    Log.Debug("Not a playable video, Url: {0}, message: {1}", m.Groups["url"].Value, e.Message);
                }
            }
            if (!skipNextPage)
            {
                regex = new Regex(@"<li class=""next"">(?<next>.*?)</", RegexOptions.Singleline);
                Match nextMatch = regex.Match(data);
                HasNextPage = (nextMatch.Success && !string.IsNullOrWhiteSpace(nextMatch.Groups["next"].Value));
                if (HasNextPage)
                {
                    currentVideoMethod = (Func <List <VideoInfo> >)(() => GetHtmlVideos(category, currentPage + 1, parameters));
                }
            }
            return(videos);
        }
 private List<VideoInfo> GetHtmlVideos(LastFmCategory category, int currentPage, SerializableDictionary<string, string> parameters, bool skipNextPage = false)
 {
     List<VideoInfo> videos = new List<VideoInfo>();
     string url = category.Url;
     url += "?" + "_pjax=%23content&page=" + currentPage;
     if (parameters != null)
     {
         foreach (KeyValuePair<string, string> param in parameters)
         {
             url += "&" + param.Key + "=" + param.Value;
         }
     }
     string data = GetWebData(url, cookies: Cookies, referer: category.Url);
     Regex regex;
     if (url.Contains("/library"))
         regex = new Regex(@"""chartlist-play-image"">[^<]*<img src=""(?<img>[^""]*)[^<]*?<a[^>]*?href=""(?<url>https{0,1}://www.youtube.com/watch[^""]*)[^>]*?data-track-name=""(?<track>[^""]*)[^>]*?data-track-url=""(?<slug>[^""]*)[^>]*?data-artist-name=""(?<artist>[^""]*)", RegexOptions.Singleline);
     else
         regex = new Regex(@"""chartlist-play"">[^<]*<a[^>]*?href=""(?<url>https{0,1}://www.youtube.com/watch[^""]*)[^>]*?data-track-name=""(?<track>[^""]*)[^>]*?data-track-url=""(?<slug>[^""]*)[^>]*?data-artist-name=""(?<artist>[^""]*)", RegexOptions.Singleline);
     foreach (Match m in regex.Matches(data))
     {
         try
         {
             bool addVideo = true;
             LastFmVideo track = new LastFmVideo();
             if (filterOutUnplayable)
             {
                 Dictionary<string, string> pbos = Hoster.HosterFactory.GetHoster("youtube").GetPlaybackOptions(m.Groups["url"].Value);
                 track.Other = pbos;
                 addVideo = pbos != null && pbos.Count > 0;
             }
             if (addVideo)
             {
                 Regex trackRegex = new Regex(@"^/music/(?<artist>[^/]*)/[^/]*/(?<track>.*?)$");
                 string trackUrl = m.Groups["slug"].Value;
                 Match trackMatch = trackRegex.Match(trackUrl);
                 if (trackMatch.Success)
                 {
                     track.ArtistSlug = trackMatch.Groups["artist"].Value;
                     track.TrackSlug = trackMatch.Groups["track"].Value;
                     track.Track = m.Groups["track"].Value;
                     track.Artist = m.Groups["artist"].Value;
                     track.VideoUrl = m.Groups["url"].Value;
                     track.Thumb = m.Groups["img"].Value;
                     track.Title = track.Artist + " - " + track.Track;
                     videos.Add(track);
                 }
             }
         }
         catch (OnlineVideosException e)
         {
             Log.Debug("Not a playable video, Url: {0}, message: {1}", m.Groups["url"].Value, e.Message);
         }
     }
     if (!skipNextPage)
     {
         regex = new Regex(@"<li class=""next"">(?<next>.*?)</", RegexOptions.Singleline);
         Match nextMatch = regex.Match(data);
         HasNextPage = (nextMatch.Success && !string.IsNullOrWhiteSpace(nextMatch.Groups["next"].Value));
         if (HasNextPage)
             currentVideoMethod = (Func<List<VideoInfo>>)(() => GetHtmlVideos(category, currentPage + 1, parameters));
     }
     return videos;
 }