Esempio n. 1
0
        public static List <VideoData> ParseSearch(string jsonSource)
        {
            object json;

            if (!VideoDataParser.ParseJSON(jsonSource, out json))
            {
                Service.Get <StaRTSLogger>().Error("Failed to parse Search JSON");
                return(null);
            }
            Dictionary <string, List <VideoData> > dictionary = new Dictionary <string, List <VideoData> >();

            if (!VideoDataParser.ParseFeed(json, ref dictionary))
            {
                Service.Get <StaRTSLogger>().Error("Failed to parse Search");
                return(null);
            }
            using (Dictionary <string, List <VideoData> > .ValueCollection.Enumerator enumerator = dictionary.Values.GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    return(enumerator.Current);
                }
            }
            return(null);
        }
Esempio n. 2
0
        private static bool ParseSection(object json, ref Dictionary <string, List <VideoData> > feed)
        {
            Dictionary <string, object> dictionary = json as Dictionary <string, object>;

            if (dictionary == null)
            {
                Service.Get <StaRTSLogger>().ErrorFormat("Invalid structure for Section - {0}", new object[]
                {
                    json.GetType().ToString()
                });
                return(false);
            }
            if (!dictionary.ContainsKey("internal"))
            {
                Service.Get <StaRTSLogger>().Error("Failed to find Section Name in JSON");
                return(false);
            }
            if (!dictionary.ContainsKey("items"))
            {
                Service.Get <StaRTSLogger>().Error("Failed to find Videos in JSON");
                return(false);
            }
            string key = (string)dictionary["internal"];

            feed[key] = VideoDataParser.ParseVideoList(dictionary["items"]);
            return(true);
        }
Esempio n. 3
0
        private void ParseTag(string json, object callback, object data)
        {
            VideoDataManager.DataListQueryCompleteDelegate dataListQueryCompleteDelegate = (VideoDataManager.DataListQueryCompleteDelegate)callback;
            string        key  = (string)data;
            List <string> list = null;

            if (!string.IsNullOrEmpty(json))
            {
                list           = VideoDataParser.ParseTag(json);
                this.Tags[key] = list;
            }
            dataListQueryCompleteDelegate(list);
        }
Esempio n. 4
0
        public static List <string> ParseTag(string jsonSource)
        {
            object obj;

            if (!VideoDataParser.ParseJSON(jsonSource, out obj))
            {
                Service.Get <StaRTSLogger>().Error("Failed to parse Tag JSON");
                return(null);
            }
            if (obj == null)
            {
                Service.Get <StaRTSLogger>().Error("Failed to parse jsonSource");
                return(null);
            }
            Dictionary <string, object> dictionary = obj as Dictionary <string, object>;

            if (dictionary == null)
            {
                Service.Get <StaRTSLogger>().ErrorFormat("Invalid structure for Tag - {0}", new object[]
                {
                    obj.GetType().ToString()
                });
                return(null);
            }
            if (!dictionary.ContainsKey("item_groups"))
            {
                Service.Get <StaRTSLogger>().Error("Failed to find Group in Categories");
                return(null);
            }
            List <object> list = dictionary["item_groups"] as List <object>;

            if (list == null)
            {
                Service.Get <StaRTSLogger>().Error("Null Group in Categories");
                return(null);
            }
            List <string> result = new List <string>();

            for (int i = 0; i < list.Count; i++)
            {
                if (!VideoDataParser.ParseTagGroup(list[i], ref result))
                {
                    Service.Get <StaRTSLogger>().ErrorFormat("Failed to parse Category Group {0}", new object[]
                    {
                        i
                    });
                    return(null);
                }
            }
            return(result);
        }
Esempio n. 5
0
        private void ParseDetails(string json, object callback, object data)
        {
            VideoDataManager.DataQueryCompleteDelegate dataQueryCompleteDelegate = (VideoDataManager.DataQueryCompleteDelegate)callback;
            string    videoGuid = (string)data;
            VideoData videoData = VideoDataParser.ParseDetails(videoGuid, json);

            if (videoData != null)
            {
                this.Merge(videoData);
                dataQueryCompleteDelegate(videoData.Guid);
                return;
            }
            dataQueryCompleteDelegate(null);
        }
Esempio n. 6
0
        private void ParseFeed(string json, object callback, object data)
        {
            Dictionary <string, List <VideoData> > dictionary = VideoDataParser.ParseUserFeed(json);

            if (dictionary != null)
            {
                foreach (string current in dictionary.Keys)
                {
                    this.Sections[current] = this.LoadVideoDataList(dictionary[current]);
                }
            }
            this.IsFeedLoaded = true;
            this.GetFeed((VideoDataManager.DataListQueryCompleteDelegate)callback);
        }
Esempio n. 7
0
        public static VideoData ParseDetails(string videoGuid, string jsonSource)
        {
            if (jsonSource == null)
            {
                return(null);
            }
            object json;

            if (!VideoDataParser.ParseJSON(jsonSource, out json))
            {
                Service.Get <StaRTSLogger>().Error("Failed to parse VideoDetails JSON");
                return(null);
            }
            return(new VideoData(videoGuid, json));
        }
Esempio n. 8
0
        private void ParseTagWithQuery(string json, object query, object data)
        {
            QueryData queryData = (QueryData)query;

            if (!queryData.Active)
            {
                return;
            }
            List <string> list = null;

            if (!string.IsNullOrEmpty(json))
            {
                list = VideoDataParser.ParseTag(json);
            }
            string key = (string)data;

            this.Tags[key] = list;
            queryData.AddResult(list, false);
            queryData.FilterResults();
        }
Esempio n. 9
0
        private void ParseKeywords(string json, object query, object data)
        {
            QueryData queryData = (QueryData)query;

            if (!queryData.Active)
            {
                return;
            }
            List <VideoData> list = null;

            if (json != null)
            {
                list = VideoDataParser.ParseSearch(json);
            }
            string        key   = (string)data;
            List <string> list2 = this.LoadVideoDataList(list);

            this.Keywords[key] = list2;
            queryData.AddResult(list2, false);
            queryData.FilterResults();
        }
Esempio n. 10
0
        public static Dictionary <string, List <VideoData> > ParseUserFeed(string jsonSource)
        {
            if (jsonSource == null)
            {
                return(null);
            }
            object json;

            if (!VideoDataParser.ParseJSON(jsonSource, out json))
            {
                Service.Get <StaRTSLogger>().Error("Failed to parse UserFeed JSON");
                return(null);
            }
            Dictionary <string, List <VideoData> > result = new Dictionary <string, List <VideoData> >();

            if (!VideoDataParser.ParseFeed(json, ref result))
            {
                Service.Get <StaRTSLogger>().Error("Failed to parse UserFeed");
                return(null);
            }
            return(result);
        }
Esempio n. 11
0
        private static bool ParseTagGroup(object json, ref List <string> videosReceived)
        {
            Dictionary <string, object> dictionary = json as Dictionary <string, object>;

            if (dictionary == null)
            {
                Service.Get <StaRTSLogger>().ErrorFormat("Invalid structure for Group - {0}", new object[]
                {
                    json.GetType().ToString()
                });
                return(false);
            }
            if (!dictionary.ContainsKey("items"))
            {
                Service.Get <StaRTSLogger>().Error("Failed to find Items in JSON");
                return(false);
            }
            List <object> list = dictionary["items"] as List <object>;

            if (list == null)
            {
                Service.Get <StaRTSLogger>().Error("Null Items in JSON");
                return(false);
            }
            for (int i = 0; i < list.Count; i++)
            {
                if (!VideoDataParser.ParseTagItem(list[i], ref videosReceived))
                {
                    Service.Get <StaRTSLogger>().ErrorFormat("Failed to parse Item {0}", new object[]
                    {
                        i
                    });
                }
            }
            return(true);
        }
Esempio n. 12
0
        private static bool ParseGroup(object json, ref Dictionary <string, List <VideoData> > feed)
        {
            Dictionary <string, object> dictionary = json as Dictionary <string, object>;

            if (dictionary == null)
            {
                Service.Get <StaRTSLogger>().ErrorFormat("Invalid structure for Group - {0}", new object[]
                {
                    json.GetType().ToString()
                });
                return(false);
            }
            if (!dictionary.ContainsKey("sections"))
            {
                Service.Get <StaRTSLogger>().Error("Failed to find Sections in JSON");
                return(false);
            }
            List <object> list = dictionary["sections"] as List <object>;

            if (list == null)
            {
                Service.Get <StaRTSLogger>().Error("Null Sections in JSON");
                return(false);
            }
            foreach (object current in list)
            {
                if (!VideoDataParser.ParseSection(current, ref feed))
                {
                    Service.Get <StaRTSLogger>().ErrorFormat("Failed to parse Section {0}", new object[]
                    {
                        list.IndexOf(current)
                    });
                }
            }
            return(true);
        }
Esempio n. 13
0
 public unsafe static long $Invoke4(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(VideoDataParser.ParseVideoList(GCHandledObjects.GCHandleToObject(*args))));
 }
Esempio n. 14
0
 public unsafe static long $Invoke3(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(VideoDataParser.ParseUserFeed(Marshal.PtrToStringUni(*(IntPtr *)args))));
 }
Esempio n. 15
0
 public unsafe static long $Invoke0(long instance, long *args)
 {
     return(GCHandledObjects.ObjectToGCHandle(VideoDataParser.ParseDetails(Marshal.PtrToStringUni(*(IntPtr *)args), Marshal.PtrToStringUni(*(IntPtr *)(args + 1)))));
 }