public static UserPlaylist ToUserPlaylist(this GoogleMusicPlaylist googleMusicPlaylist)
        {
            var userPlaylist = new UserPlaylist();

            Mapper(googleMusicPlaylist, userPlaylist);

            return(userPlaylist);
        }
 public static void Mapper(GoogleMusicPlaylist googleMusicPlaylist, UserPlaylist userPlaylist)
 {
     userPlaylist.PlaylistId   = googleMusicPlaylist.Id;
     userPlaylist.Title        = googleMusicPlaylist.Name;
     userPlaylist.TitleNorm    = googleMusicPlaylist.Name.Normalize();
     userPlaylist.CreationDate =
         DateTimeExtensions.FromUnixFileTime(googleMusicPlaylist.CreationTimestramp / 1000);
     userPlaylist.LastModified =
         DateTimeExtensions.FromUnixFileTime(googleMusicPlaylist.LastModifiedTimestamp / 1000);
     userPlaylist.RecentDate           = DateTimeExtensions.FromUnixFileTime(googleMusicPlaylist.RecentTimestamp / 1000);
     userPlaylist.Type                 = googleMusicPlaylist.Type;
     userPlaylist.ShareToken           = googleMusicPlaylist.ShareToken;
     userPlaylist.OwnerName            = googleMusicPlaylist.OwnerName;
     userPlaylist.OwnerProfilePhotoUrl = googleMusicPlaylist.OwnerProfilePhotoUrl;
     userPlaylist.AccessControlled     = googleMusicPlaylist.AccessControlled;
 }
示例#3
0
        private async Task LoadSongsAsync(IProgress <int> progress = null)
        {
            GoogleMusicPlaylist playlist = null;

            Task commitTask = Task.FromResult <object>(null);

            do
            {
                var jsonProperties = new Dictionary <string, string>();

                if (playlist != null && !string.IsNullOrEmpty(playlist.ContinuationToken))
                {
                    jsonProperties.Add("continuationToken", JsonConvert.ToString(playlist.ContinuationToken));
                }

                Task <GoogleMusicPlaylist> loadSongsTask = this.googleMusicWebService.PostAsync <GoogleMusicPlaylist>(AllSongsUrl, jsonProperties: jsonProperties);

                await Task.WhenAll(commitTask, loadSongsTask);

                playlist = await loadSongsTask;

                ICollection <Song> songs;
                if (playlist != null && playlist.Playlist != null)
                {
                    songs = playlist.Playlist.Select(x => x.ToSong()).ToList();
                    this.AddRange(songs);
                }
                else
                {
                    songs = new Song[0];
                }

                commitTask = this.songsRepository.InsertAsync(songs);

                await progress.SafeReportAsync(this.songEntities.Count);
            }while (playlist != null && !string.IsNullOrEmpty(playlist.ContinuationToken));

            await commitTask;
        }
示例#4
0
        public async Task <UserPlaylistsUpdateStatus> UpdateUserPlaylistAsync(UserPlaylist userPlaylist)
        {
            GoogleMusicPlaylist googleMusicPlaylist = await this.playlistsWebService.GetAsync(userPlaylist.ProviderPlaylistId);

            return(await this.UpdateUserPlaylistsInternalAsync(new[] { userPlaylist }, googleMusicPlaylist == null?new GoogleMusicPlaylist[] { } : new[] { googleMusicPlaylist }));
        }