/// <summary>
        /// Load the _Links sub-section from the JSON data returned from the URL - this will be our entry point to the data
        /// </summary>
        /// <param name="url"></param>
        /// <param name="parentCategType"></param>
        /// <returns></returns>
        public static JToken GetLinksTokensFromUrl(this string url, SkyGoCategoryData.CategoryType parentCategType)
        {
            var browser         = new SkyGoBrowserSession();
            var browserResponse = browser.LoadAsStr(url);

            browserResponse = browserResponse.Replace("azPage(", "").Replace("catalogueFeed(", "").Replace("series(", "");
            browserResponse = browserResponse.Replace(");", "");

            var jsonObj = JObject.Parse(browserResponse);

            if (jsonObj == null || jsonObj["_links"] == null)
            {
                return(null);
            }

            var tmpObj = jsonObj["_links"];

            if (parentCategType == SkyGoCategoryData.CategoryType.CatchUpSubCategory)
            {
                if (jsonObj["_links"][2]["_links"] != null)
                {
                    tmpObj = jsonObj["_links"][2]["_links"][2]["_links"];
                }
            }
            return(tmpObj);
        }
        /// <summary>
        /// Load the _Links sub-section from the JSON data returned from the URL - this will be our entry point to the data
        /// </summary>
        /// <param name="url"></param>
        /// <param name="parentCategType"></param>
        /// <returns></returns>
        public static JToken GetLinksTokensFromUrl(this string url, SkyGoCategoryData.CategoryType parentCategType)
        {
            var browser = new SkyGoBrowserSession();
            var browserResponse = browser.LoadAsStr(url);
            browserResponse = browserResponse.Replace("azPage(", "").Replace("catalogueFeed(", "").Replace("series(","");
            browserResponse = browserResponse.Replace(");", "");

            var jsonObj = JObject.Parse(browserResponse);

            if (jsonObj == null || jsonObj["_links"] == null) return null;

            var tmpObj = jsonObj["_links"];

            if (parentCategType == SkyGoCategoryData.CategoryType.CatchUpSubCategory)
            {
                if (jsonObj["_links"][2]["_links"] != null)
                    tmpObj = jsonObj["_links"][2]["_links"][2]["_links"];
            }
            return tmpObj;
        }
        /// <summary>
        /// Load the Live TV channels
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static List <VideoInfo> GetChannelsFromURL(this string url)
        {
            var browser         = new SkyGoBrowserSession();
            var browserResponse = browser.LoadAsStr(url);

            browserResponse = browserResponse.Replace("feedChannelList(", "");
            browserResponse = browserResponse.Replace(");", "");

            var jsonObj = JObject.Parse(browserResponse);
            var result  = new List <VideoInfo>();

            foreach (var item in jsonObj["linearStreams"].Children())
            {
                var video = new VideoInfo();
                //video.Description = token.GetValue("synopsis") + "\r\n" + GetStarring(token);

                video.Thumb = item.GetImage();
                video.Title = item.GetValue("title");
                video.Other = "Live/" + item.GetValue("id");
                result.Add(video);
            }
            return(result.OrderBy(x => x.Title).ToList());
        }
Example #4
0
        /// <summary>
        /// Load the now/next info on a separate thread
        /// </summary>
        /// <param name="video"></param>
        private static void GetNowNext(VideoInfo video)
        {
            var browser         = new SkyGoBrowserSession();
            var browserResponse = browser.LoadAsStr(Properties.Resources.SkyGo_LiveTvGetNowNextUrl(video.AssetId()));

            try
            {
                var jsonObj = JObject.Parse(browserResponse);
                var i       = 0;
                //video.Title = string.Empty;

                foreach (var item in jsonObj["listings"][video.AssetId()].Children())
                {
                    var head  = "Now:";
                    var title = " Now: ";
                    if (i > 0)
                    {
                        head  = "\r\nNext:";
                        title = ", Next: ";
                    }

                    var time = 0L;

                    long.TryParse(item.GetValue("s"), out time);

                    video.Title += string.Format("{0} {1} ({2})", title, item.GetValue("t"), FromUnixTime(time).ToString("HH:mm"));

                    video.Description += string.Format("{0} {1} ({2}) {3}", head, item.GetValue("t"), FromUnixTime(time).ToString("HH:mm"), item.GetValue("d"));
                    i++;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
        /// <summary>
        /// Load the Live TV channels
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static List<VideoInfo> GetChannelsFromURL(this string url)
        {
            var browser = new SkyGoBrowserSession();
            var browserResponse = browser.LoadAsStr(url);
            browserResponse = browserResponse.Replace("feedChannelList(", "");
            browserResponse = browserResponse.Replace(");", "");

            var jsonObj = JObject.Parse(browserResponse);
            var result = new List<VideoInfo>();

            foreach (var item in jsonObj["linearStreams"].Children())
            {
                var video = new VideoInfo();
                //video.Description = token.GetValue("synopsis") + "\r\n" + GetStarring(token);

                video.Thumb = item.GetImage();
                video.Title = item.GetValue("title");
                video.Other = "Live/" + item.GetValue("id");
                result.Add(video);

            }
            return result.OrderBy(x=>x.Title).ToList();
        }
        /// <summary>
        /// Load the now/next info on a separate thread
        /// </summary>
        /// <param name="video"></param>
        private static void GetNowNext(VideoInfo video)
        {
            var browser = new SkyGoBrowserSession();
            var browserResponse = browser.LoadAsStr(Properties.Resources.SkyGo_LiveTvGetNowNextUrl(video.AssetId()));

            try
            {
                var jsonObj = JObject.Parse(browserResponse);
                var i = 0;
                //video.Title = string.Empty;

                foreach (var item in jsonObj["listings"][video.AssetId()].Children())
                {
                    var head = "Now:";
                    var title = " Now: ";
                    if (i > 0)
                    {
                        head = "\r\nNext:";
                        title = ", Next: ";
                    }

                    var time = 0L;

                    long.TryParse(item.GetValue("s"), out time);
                    
                    video.Title += string.Format("{0} {1} ({2})", title, item.GetValue("t"), FromUnixTime(time).ToString("HH:mm"));

                    video.Description += string.Format("{0} {1} ({2}) {3}", head, item.GetValue("t"), FromUnixTime(time).ToString("HH:mm"), item.GetValue("d"));
                    i++;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }