using System; using System.Text.RegularExpressions; using System.Net; using System.Text; using Newtonsoft.Json.Linq; using Newtonsoft.Json; using System.Collections.Generic; using System.Xml; using System.ComponentModel; using System.Threading; namespace OnlineVideos.Sites { public class DRNUUtil : SiteUtilBase { private string baseUrl = "http://www.dr.dk/nu/api"; public override string getUrl(VideoInfo video) { string url = video.VideoUrl; return base.getUrl(video); } private List getvideos(JArray contentData) { List res = new List(); if (contentData != null) { foreach (var item in contentData) { string redirectUrl = GetWebData(item.Value("videoManifestUrl")); VideoInfo video = new VideoInfo(); video.Title = item.Value("title"); video.Description = item.Value("description"); video.VideoUrl = redirectUrl.Replace("rtmp://vod.dr.dk/", "rtmp://vod.dr.dk/cms/"); video.ImageUrl = baseUrl + "/videos/" + item.Value("id") + "/images/200x100.jpg"; string len = item.Value("duration"); string air = item.Value("formattedBroadcastTime"); video.Length = len + '|' + Translation.Airdate + ": " + air; res.Add(video); } } return res; } public override List getVideoList(Category category) { string url = baseUrl + "/programseries/" + category.Other + "/videos"; string json = GetWebData(url); JArray contentData = JArray.Parse(json); return getvideos(contentData); } public override int DiscoverDynamicCategories() { List categories = new List(); string json = GetWebData(baseUrl + "/programseries"); foreach (var item in JArray.Parse(json)) { string title = item.Value("title"); Category mainCategory = new Category() { Name = title, HasSubCategories = false, SubCategoriesDiscovered = false, SubCategories = new List() }; mainCategory.Description = item.Value("description"); mainCategory.Other = item.Value("slug"); mainCategory.Thumb = baseUrl + "/programseries/" + item.Value("slug") + "/images/200x100.jpg"; Settings.Categories.Add(mainCategory); } Settings.DynamicCategoriesDiscovered = true; return Settings.Categories.Count; } } }