public Playlist GetPlaylistEntries(string playlist_id) { if (String.IsNullOrEmpty(playlist_id)) return null; Playlist playlist = null; string jsArray = String.Format(@"[[""{0}"",1],[""{1}""]]", _sessionId, playlist_id); string response = GoogleMusicService(Service.loaduserplaylist, jsArray); if (!String.IsNullOrEmpty(response)) { playlist = new Playlist { id = playlist_id }; ArrayList array = _parser.Parse(response)[1] as ArrayList; if (array.Count > 0) { array = array[0] as ArrayList; foreach (ArrayList t in array) { Track track = new Track(); for (int i = 0; i < trackProperties.Length; i++) { string property = trackProperties[i]; if (!String.IsNullOrEmpty(property)) { MethodInfo info = typeof(Track).GetMethod("set_" + property, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (info != null && i < t.Count) { object ti = t[i]; if (ti != null) ti = Convert.ChangeType(ti, info.GetParameters()[0].ParameterType); info.Invoke(track, new[] { ti }); } else ThrowError(String.Format("Track property '{0}' not matched!", property)); } } playlist.entries.Add(new PlaylistEntry { track = track }); } } } return playlist; }
public Playlists GetPlaylists(bool includeTracks = true) { Playlists playlists = null; string jsArray = String.Format(@"[[""{0}"",1],[""all""]]", _sessionId); string response = GoogleMusicService(Service.loadplaylists, jsArray); if (!String.IsNullOrEmpty(response)) { ArrayList array = (_parser.Parse(response)[1] as ArrayList)[0] as ArrayList; playlists = new Playlists(); playlists.lastUpdatedTimestamp = DateTime.Now; foreach (ArrayList pl in array) { Playlist playlist = new Playlist(); for (int i = 0; i < playlistProperties.Length; i++) { string property = playlistProperties[i]; if (!String.IsNullOrEmpty(property)) { MethodInfo info = typeof(Playlist).GetMethod("set_" + property, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (info != null && i < pl.Count) { object pli = pl[i]; if (pli != null) pli = Convert.ChangeType(pli, info.GetParameters()[0].ParameterType); info.Invoke(playlist, new[] { pli }); } else ThrowError(String.Format("Playlist property '{0}' not matched!", property)); } } playlists.Add(playlist); } if (includeTracks) { foreach (Playlist playlist in playlists) playlist.entries = GetPlaylistEntries(playlist.id).entries; } } return playlists; }