internal SpotifyPlaylist(MetadataFactory factory, PlaylistResult result, WebApi webApi) { this.factory = factory; this.uri = result.uri; this.name = result.name; PagingObjectResult <PlaylistTrackResult> tracks = result.tracks; var wrap = new PagingWrapper <ISong, PlaylistTrackResult>(tracks, webApi, false); this.page1 = wrap; // Submit items for caching foreach (var playlistTrack in tracks.items) { this.factory.CacheSubmit(playlistTrack); } }
public IMetadata ToMetadata(WebApi webApi, MetadataFactory metadata) { return(new SpotifySong(metadata, track)); }
public IMetadata ToMetadata(WebApi webApi, MetadataFactory metadata) { // TODO cache return(null); }
public MetadataFactory(WebApi webApi) { this.webApi = webApi; }
// This one is a bit different than the other 3 obtainers, because the API is totally different internal static List <SpotifyPlaylist> ObtainPlaylists(MetadataFactory factory, IList <string> uids, WebApi webApi) { var result = new List <SpotifyPlaylist>(); foreach (var uid in uids) { // Format example: spotify:user:wizzlersmate:playlist:1AVZz0mBuGbCEoNRQdYQju var lastColon = uid.LastIndexOf(':'); var id = uid.Substring(lastColon + 1); var username = uid.Substring(13, lastColon - 9 - 13); var task = Task.Run(async() => { return(await webApi.GetJson("/users/" + username + "/playlists/" + id)); }); var json = task.Result; var jsonResult = JsonConvert.DeserializeObject <PlaylistResult>(json); result.Add(new SpotifyPlaylist(factory, jsonResult, webApi)); } return(result); }
internal SpotifyPlaylist(MetadataFactory factory, PartialPlaylistResult result, WebApi webApi) { this.factory = factory; this.uri = result.uri; this.name = result.name; var trackHref = result.tracks.href; var wrap = new PagingWrapper <ISong, PlaylistTrackResult>(trackHref, webApi, false); this.page1 = wrap; }
public IMetadata ToMetadata(WebApi webApi, MetadataFactory metadata) { return(new SpotifyPlaylist(metadata, this, webApi)); }
public IMetadata ToMetadata(WebApi webApi, MetadataFactory metadata) { return(new SpotifyAlbum(metadata, this)); }