// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Collections.Generic; using System.Net; using System.Web.Script.Serialization; namespace E { public class Program { public int id { get; set; } public int pid { get; set; } public string end { get; set; } public string start { get; set; } public int overlap { get; set; } public string cat { get; set; } public string title { get; set; } public string description { get; set; } } public class DayProgram { public int id { get; set; } public string sort { get; set; } public string logo { get; set; } public string name { get; set; } public string group { get; set; } public Program[] programs { get; set; } } public class Test { private static long k = (new DateTime(1970, 1, 1, 0, 0, 0) + TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now)).Ticks; public static int N2U(DateTime dt) { return (int)((dt.Ticks - k) / 10000000); } public static DayProgram[] GetPrograms(DateTime dt) { DateTime dt2 = dt-TimeZone.CurrentTimeZone.GetUtcOffset(dt); WebClient wc = new WebClient(); string html = wc.DownloadString("http://tvtid.tv2.dk/allekanaler/get.php/day-" + N2U(dt2) + ".html"); JavaScriptSerializer jss = new JavaScriptSerializer(); return jss.Deserialize(html); } public static void Main(string[] args) { foreach(DayProgram dp in GetPrograms(new DateTime(2010, 4, 10))) { Console.WriteLine("****" + dp.name + "****"); foreach(Program p in dp.programs) { Console.WriteLine(p.title + " : " + p.start + "-" + p.end); } } } } }