Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
 public IMetadata ToMetadata(WebApi webApi, MetadataFactory metadata)
 {
     return(new SpotifySong(metadata, track));
 }
Exemplo n.º 3
0
 public IMetadata ToMetadata(WebApi webApi, MetadataFactory metadata)
 {
     // TODO cache
     return(null);
 }
Exemplo n.º 4
0
 public MetadataFactory(WebApi webApi)
 {
     this.webApi = webApi;
 }
Exemplo n.º 5
0
        // 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);
        }
Exemplo n.º 6
0
        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;
        }
Exemplo n.º 7
0
 public IMetadata ToMetadata(WebApi webApi, MetadataFactory metadata)
 {
     return(new SpotifyPlaylist(metadata, this, webApi));
 }
Exemplo n.º 8
0
 public IMetadata ToMetadata(WebApi webApi, MetadataFactory metadata)
 {
     return(new SpotifyAlbum(metadata, this));
 }