public void Parse(JObject rootObject, TrendsList trendsList) { LogService.Debug(this.GetType(), "Entering Parse for WhatTheThrendTrendsParser"); try { JArray trendsJArray = rootObject.Value<JArray>("trends"); if (trendsJArray != null) { foreach (JObject trendJObject in trendsJArray) { string name = trendJObject.Value<string>("name"); if (name != null && !name.Contains("#") && !name.Contains("WTT test") && !name.Contains("ttrtpt")) { JToken t; trendJObject.TryGetValue("description", out t); if (t.HasValues) { JObject descriptionJSONObject = trendJObject.Value<JObject>("description"); if (descriptionJSONObject != null) { string text = descriptionJSONObject.Value<string>("text"); if (text != null) { TrendItem trendItem = new TrendItem(name, name, ProviderEnum.WhatTheTrend); trendItem.Weight = 5; trendsList.Add(trendItem); ExplanationItem explanationLItem = new ExplanationItem(trendItem.Title, trendItem.Title, text); ExplanationCacheHelper.CacheExplanationItem(trendItem.Title, explanationLItem); } } } } } } } catch (Exception exception) { ErrorService.Log("WhatTheTrendTrendsService", "Parse", null, exception); } LogService.Debug(this.GetType(), "Exiting Parse for WhatTheThrendTrendsParser"); }
public void Parse(EntryData data, ITunesTypeEnum iTunesType, TrendsList trendsList) { LogService.Debug(this.GetType(), "Entering Parse for ITunesTrendsParser"); try { EntryList entryList = data.EntryList; int i = 0; foreach (Entry entry in entryList) { string name; CategoryEnum category; switch (iTunesType) { case ITunesTypeEnum.Top10Songs: name = entry.Get("im:artist"); category = CategoryEnum.Music; break; default: name = entry.Get("im:name"); category = CategoryEnum.Movie; break; } TrendItem trendItem = new TrendItem(name, name, ProviderEnum.ITunes); trendItem.ImageURL = entry.Get("im:image"); trendItem.Weight = CalculateWeight(i); trendItem.Category = category; trendsList.Add(trendItem); i++; } } catch (Exception exception) { ErrorService.Log("ITunesTrendsParser", "Parse", null, exception); } LogService.Debug(this.GetType(), "Exiting Parse for ITunesTrendsParser"); }