Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DynamicJsonObject : DynamicObject
- {
- private IDictionary<string, object> Dictionary { get; set; }
- public DynamicJsonObject(IDictionary<string, object> dictionary)
- {
- this.Dictionary = dictionary;
- }
- public override bool TryGetMember(GetMemberBinder binder, out object result)
- {
- result = this.Dictionary[binder.Name];
- if (result is IDictionary<string, object>)
- {
- result = new DynamicJsonObject(result as IDictionary<string, object>);
- }
- else if (result is ArrayList && (result as ArrayList) is IDictionary<string, object>)
- {
- result = new List<DynamicJsonObject>((result as ArrayList).ToArray().Select(x => new DynamicJsonObject(x as IDictionary<string, object>)));
- }
- else if (result is ArrayList)
- {
- result = new List<object>((result as ArrayList).ToArray());
- }
- return this.Dictionary.ContainsKey(binder.Name);
- }
- }
- public class DynamicJsonConverter : JavaScriptConverter
- {
- public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
- {
- if (dictionary == null)
- throw new ArgumentNullException("dictionary");
- if (type == typeof(object))
- {
- return new DynamicJsonObject(dictionary);
- }
- return null;
- }
- public override IDictionary<string, object> Serialize(object obj, JavaScriptSerializer serializer)
- {
- throw new NotImplementedException();
- }
- public override IEnumerable<Type> SupportedTypes
- {
- get { return new ReadOnlyCollection<Type>(new List<Type>(new Type[] { typeof(object) })); }
- }
- }
- void Main()
- {
- 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""}]";
- JavaScriptSerializer jss = new JavaScriptSerializer();
- jss.RegisterConverters(new JavaScriptConverter[] { new DynamicJsonConverter() });
- dynamic objs = jss.Deserialize(strr, typeof(object)) as dynamic;
- var container = new List<string>();
- foreach (var obj in objs)
- {
- var wc = new WebClient();
- var dlStr = wc.DownloadString(obj.playlist);
- foreach (var block in dlStr.Replace("[playlist]", "þ").Split('þ'))
- {
- var p = block.Split('\n');
- foreach (var element in p)
- {
- if (element.StartsWith("File1="))
- {
- var url = element.Substring(6);
- container.Add(url);
- }
- }
- }
- }
- container.OrderBy(n => n.Substring(n.LastIndexOf('/'))).Dump();
- string argstr = "";
- foreach (var element in container)
- {
- argstr += " " + element;
- }
- argstr.Dump();
- //var lof = strr.Replace(@"""playlist"":", "þ").Split('þ').Select(n => n.Split('"')).Skip(1).Select(n => n[1].Replace(@"\/", "/")).Dump();
- Process.Start(@"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe", argstr);
- }
- // Define other methods and classes here
Advertisement
Add Comment
Please, Sign In to add comment