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