hlsdk

DI.FM Playlists

Nov 30th, 2011
458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 9.96 KB | None | 0 0
  1. public class DynamicJsonObject : DynamicObject
  2. {
  3.     private IDictionary<string, object> Dictionary { get; set; }
  4.  
  5.     public DynamicJsonObject(IDictionary<string, object> dictionary)
  6.     {
  7.         this.Dictionary = dictionary;
  8.     }
  9.  
  10.     public override bool TryGetMember(GetMemberBinder binder, out object result)
  11.     {
  12.         result = this.Dictionary[binder.Name];
  13.  
  14.         if (result is IDictionary<string, object>)
  15.         {
  16.             result = new DynamicJsonObject(result as IDictionary<string, object>);
  17.         }
  18.         else if (result is ArrayList && (result as ArrayList) is IDictionary<string, object>)
  19.         {
  20.             result = new List<DynamicJsonObject>((result as ArrayList).ToArray().Select(x => new DynamicJsonObject(x as IDictionary<string, object>)));
  21.         }
  22.         else if (result is ArrayList)
  23.         {
  24.             result = new List<object>((result as ArrayList).ToArray());
  25.         }
  26.  
  27.         return this.Dictionary.ContainsKey(binder.Name);
  28.     }
  29. }
  30.  
  31. public class DynamicJsonConverter : JavaScriptConverter
  32. {
  33.     public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
  34.     {
  35.         if (dictionary == null)
  36.             throw new ArgumentNullException("dictionary");
  37.  
  38.         if (type == typeof(object))
  39.         {
  40.             return new DynamicJsonObject(dictionary);
  41.         }
  42.  
  43.         return null;
  44.     }
  45.  
  46.     public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer)
  47.     {
  48.         throw new NotImplementedException();
  49.     }
  50.  
  51.     public override IEnumerable<Type> SupportedTypes
  52.     {
  53.         get { return new ReadOnlyCollection<Type>(new List<Type>(new Type[] { typeof(object) })); }
  54.     }
  55. }
  56.  
  57. void Main()
  58. {
  59.     var strr = @"[{""id"":1,""key"":""trance"",""name"":""Trance"",""description"":""The hottest, freshest trance music from around the globe!"",""playlist"":""http:\/\/listen.di.fm\/public3\/trance.pls""},{""id"":2,""key"":""vocaltrance"",""name"":""Vocal Trance"",""description"":""A fusion of trance, dance, and chilling vocals together!"",""playlist"":""http:\/\/listen.di.fm\/public3\/vocaltrance.pls""},{""id"":3,""key"":""chillout"",""name"":""Chillout"",""description"":""Full of trippy flavors, this channel is just what you need to relax."",""playlist"":""http:\/\/listen.di.fm\/public3\/chillout.pls""},{""id"":4,""key"":""house"",""name"":""House"",""description"":""Silky sexy deep house music direct from New York city!"",""playlist"":""http:\/\/listen.di.fm\/public3\/house.pls""},{""id"":5,""key"":""harddance"",""name"":""Hard Dance"",""description"":""Enjoy the harder side of throbbing house and trance. "",""playlist"":""http:\/\/listen.di.fm\/public3\/harddance.pls""},{""id"":6,""key"":""eurodance"",""name"":""EuroDance"",""description"":""The newest and best of Eurodance hits"",""playlist"":""http:\/\/listen.di.fm\/public3\/eurodance.pls""},{""id"":7,""key"":""progressive"",""name"":""Progressive"",""description"":""House, techno, and trance beats for your mind!"",""playlist"":""http:\/\/listen.di.fm\/public3\/progressive.pls""},{""id"":8,""key"":""goapsy"",""name"":""Goa-Psy Trance"",""description"":""A psychedelic voyage out of this world!"",""playlist"":""http:\/\/listen.di.fm\/public3\/goapsy.pls""},{""id"":9,""key"":""hardcore"",""name"":""Hardcore"",""description"":""DJ mixes, hard dance and NuNRG"",""playlist"":""http:\/\/listen.di.fm\/public3\/hardcore.pls""},{""id"":10,""key"":""djmixes"",""name"":""DJ Mixes"",""description"":""Non-stop DJ sets featuring various forms of techno & trance!"",""playlist"":""http:\/\/listen.di.fm\/public3\/djmixes.pls""},{""id"":11,""key"":""lounge"",""name"":""Lounge"",""description"":""Sit back and enjoy the lounge grooves!"",""playlist"":""http:\/\/listen.di.fm\/public3\/lounge.pls""},{""id"":12,""key"":""ambient"",""name"":""Ambient"",""description"":""A blend of ambient, downtempo, and chillout"",""playlist"":""http:\/\/listen.di.fm\/public3\/ambient.pls""},{""id"":13,""key"":""drumandbass"",""name"":""Drum 'n Bass"",""description"":""Tasty assortment to satisfy your drum and bass fix!"",""playlist"":""http:\/\/listen.di.fm\/public3\/drumandbass.pls""},{""id"":14,""key"":""classictechno"",""name"":""Classic Electronica"",""description"":""old school techno, trance & rave!"",""playlist"":""http:\/\/listen.di.fm\/public3\/classictechno.pls""},{""id"":123,""key"":""ukgarage"",""name"":""UK Garage"",""description"":""The latest and greatest in UK Garage!!"",""playlist"":""http:\/\/listen.di.fm\/public3\/ukgarage.pls""},{""id"":15,""key"":""breaks"",""name"":""Breaks"",""description"":""A fine assortment of trance and house breaks"",""playlist"":""http:\/\/listen.di.fm\/public3\/breaks.pls""},{""id"":16,""key"":""gabber"",""name"":""Gabber"",""description"":""Banging to the hardest sounds of gabber!"",""playlist"":""http:\/\/listen.di.fm\/public3\/gabber.pls""},{""id"":36,""key"":""techno"",""name"":""Techno"",""description"":""From Minimal to Detroit to Schranz & all in between!"",""playlist"":""http:\/\/listen.di.fm\/public3\/techno.pls""},{""id"":47,""key"":""soulfulhouse"",""name"":""Soulful House"",""description"":""House music selected from Paris with love!"",""playlist"":""http:\/\/listen.di.fm\/public3\/soulfulhouse.pls""},{""id"":53,""key"":""futuresynthpop"",""name"":""Future Synthpop"",""description"":""Finest selection of futurepop and synthpop!!"",""playlist"":""http:\/\/listen.di.fm\/public3\/futuresynthpop.pls""},{""id"":56,""key"":""electro"",""name"":""Electro House"",""description"":""An eclectic mix of electro and dirty house"",""playlist"":""http:\/\/listen.di.fm\/public3\/electro.pls""},{""id"":57,""key"":""tribalhouse"",""name"":""Tribal House"",""description"":""Finest selection of tribal and tech house!!"",""playlist"":""http:\/\/listen.di.fm\/public3\/tribalhouse.pls""},{""id"":58,""key"":""funkyhouse"",""name"":""Funky House"",""description"":""A fine selection of funky house music!!"",""playlist"":""http:\/\/listen.di.fm\/public3\/funkyhouse.pls""},{""id"":59,""key"":""minimal"",""name"":""Minimal"",""description"":""Finest selection of Minimal Techno & House!!"",""playlist"":""http:\/\/listen.di.fm\/public3\/minimal.pls""},{""id"":64,""key"":""spacemusic"",""name"":""Space Dreams"",""description"":""Ambient space music for expanding minds"",""playlist"":""http:\/\/listen.di.fm\/public3\/spacemusic.pls""},{""id"":60,""key"":""hardstyle"",""name"":""Hardstyle"",""description"":""Banging Hardstyle for your ears!!!"",""playlist"":""http:\/\/listen.di.fm\/public3\/hardstyle.pls""},{""id"":66,""key"":""techhouse"",""name"":""Tech House"",""description"":""A fusion of techno and house with a deep, soulful vibe."",""playlist"":""http:\/\/listen.di.fm\/public3\/techhouse.pls""},{""id"":67,""key"":""psychill"",""name"":""Psychill"",""description"":""Downtempo psychedelic dub grooves, goa ambient, and world beats."",""playlist"":""http:\/\/listen.di.fm\/public3\/psychill.pls""},{""id"":68,""key"":""chilloutdreams"",""name"":""Chillout Dreams"",""description"":""Relax to the sounds of dream and ibiza style chillout"",""playlist"":""http:\/\/listen.di.fm\/public3\/chilloutdreams.pls""},{""id"":69,""key"":""classiceurodance"",""name"":""Classic EuroDance"",""description"":""The finest imported cheese on the net!"",""playlist"":""http:\/\/listen.di.fm\/public3\/classiceurodance.pls""},{""id"":70,""key"":""club"",""name"":""Club Sounds"",""description"":""The hottest club and dance tunes 24\/7"",""playlist"":""http:\/\/listen.di.fm\/public3\/club.pls""},{""id"":90,""key"":""classictrance"",""name"":""Classic Trance"",""description"":""Relive the classic trance hits!!"",""playlist"":""http:\/\/listen.di.fm\/public3\/classictrance.pls""},{""id"":125,""key"":""classicvocaltrance"",""name"":""Classic Vocal Trance"",""description"":""Classic sounds of Vocal Trance"",""playlist"":""http:\/\/listen.di.fm\/public3\/classicvocaltrance.pls""},{""id"":91,""key"":""dubstep"",""name"":""Dubstep"",""description"":""Dubstep hits and mixes!!!!"",""playlist"":""http:\/\/listen.di.fm\/public3\/dubstep.pls""},{""id"":92,""key"":""discohouse"",""name"":""Disco House"",""description"":""The grooviest Disco House tunes on the web."",""playlist"":""http:\/\/listen.di.fm\/public3\/discohouse.pls""},{""id"":105,""key"":""liquiddnb"",""name"":""Liquid DnB"",""description"":""Flowing with the freshest Liquid DnB!!"",""playlist"":""http:\/\/listen.di.fm\/public3\/liquiddnb.pls""},{""id"":117,""key"":""latinhouse"",""name"":""Latin House"",""description"":""Finest selection of Latin house!!"",""playlist"":""http:\/\/listen.di.fm\/public3\/latinhouse.pls""},{""id"":124,""key"":""oldschoolacid"",""name"":""Oldschool Acid"",""description"":""Oldschool sounds of Acid Techno, House, and Trance!"",""playlist"":""http:\/\/listen.di.fm\/public3\/oldschoolacid.pls""},{""id"":104,""key"":""oldschoolhouse"",""name"":""Oldschool House"",""description"":""The sounds of old school house music!"",""playlist"":""http:\/\/listen.di.fm\/public3\/oldschoolhouse.pls""},{""id"":106,""key"":""chiptunes"",""name"":""Chiptunes"",""description"":""Playing the best chiptunes and video game music."",""playlist"":""http:\/\/listen.di.fm\/public3\/chiptunes.pls""}]"; 
  60.    
  61.     JavaScriptSerializer jss = new JavaScriptSerializer();
  62.     jss.RegisterConverters(new JavaScriptConverter[] { new DynamicJsonConverter() });
  63.    
  64.     dynamic objs = jss.Deserialize(strr, typeof(object)) as dynamic;
  65.     var container = new List<string>();
  66.    
  67.     foreach (var obj in objs)
  68.     {
  69.         var wc = new WebClient();
  70.         var dlStr = wc.DownloadString(obj.playlist);
  71.         foreach (var block in dlStr.Replace("[playlist]", "þ").Split('þ'))
  72.         {
  73.             var p = block.Split('\n');
  74.             foreach (var element in p)
  75.             {
  76.                 if (element.StartsWith("File1="))
  77.                 {
  78.                     var url = element.Substring(6);
  79.                     container.Add(url);
  80.                 }
  81.             }
  82.         }
  83.     }
  84.    
  85.     container.OrderBy(n => n.Substring(n.LastIndexOf('/'))).Dump();
  86.     string argstr = "";
  87.     foreach (var element in container)
  88.     {
  89.         argstr += " " + element;
  90.     }
  91.     argstr.Dump();
  92.     //var lof = strr.Replace(@"""playlist"":", "þ").Split('þ').Select(n => n.Split('"')).Skip(1).Select(n => n[1].Replace(@"\/", "/")).Dump();
  93.     Process.Start(@"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe", argstr);
  94. }
  95.  
  96. // Define other methods and classes here
  97.  
Advertisement
Add Comment
Please, Sign In to add comment