public override System.Threading.Tasks.Task <bool> DeletePlaylist(MusicPlayer.Models.Playlist playlist)
 {
     throw new NotImplementedException();
 }
 public override System.Threading.Tasks.Task <bool> AddToPlaylist(System.Collections.Generic.List <MusicPlayer.Models.Track> songs, MusicPlayer.Models.Playlist playlist)
 {
     throw new NotImplementedException();
 }
Beispiel #3
0
        public async Task <List <FullPlaylistTrackData> > getPlaylistEntries(Playlist playlist, string nextToken = "")
        {
            var entries = new List <FullPlaylistTrackData> ();

            try{
                var path = "playlistItems?part=id,contentDetails,snippet&maxResults=50&playlistId=" + playlist.Id;
                if (!string.IsNullOrWhiteSpace(nextToken))
                {
                    path = $"{path}&pageToken={nextToken}";
                }
                Dictionary <string, string> headers = null;
                if (!string.IsNullOrWhiteSpace(playlist.ServiceExtra))
                {
                    headers = new Dictionary <string, string> {
                        { "ETag", playlist.ServiceExtra }
                    }
                }
                ;
                int order            = 0;
                var playlistResponse = await Api.Get <PlaylistItemListResponse>(path, headers : headers);

                if (playlistResponse.ETag == playlist.ServiceExtra)
                {
                    return(entries);
                }
                foreach (var item in playlistResponse.Items)
                {
                    order++;
                    var id = item.ContentDetails.VideoId;

                    var notes = GetNotes(item.ContentDetails.Note) ?? new Notes
                    {
                        Title = item.Snippet.Title,
                    };
                    var t = new FullPlaylistTrackData(notes.Title, notes.Artist, notes.AlbumArtist, notes.Album, notes.Genre)
                    {
                        AlbumArtwork = new List <AlbumArtwork> {
                            new AlbumArtwork {
                                Url = string.Format("http://img.youtube.com/vi/{0}/0.jpg", id)
                            }
                        },
                        MediaType       = MediaType.Video,
                        ServiceId       = Id,
                        Id              = id,
                        ServiceType     = ServiceType,
                        FileExtension   = "mp4",
                        TrackId         = id,
                        PlaylistId      = playlist.Id,
                        PlaylistEntryId = item.Id,
                        SOrder          = item.Snippet.Position ?? order,
                        Disc            = notes.Disc,
                        Track           = notes.Track,
                        Year            = notes.Year,
                    };
                    entries.Add(t);
                }
                playlist.ServiceExtra = playlistResponse.ETag;
                if (!string.IsNullOrWhiteSpace(playlistResponse.NextPageToken))
                {
                    entries.AddRange(await getPlaylistEntries(playlist, playlistResponse.NextPageToken));
                }
            }

            catch (Exception ex) {
                LogManager.Shared.Report(ex);
            }
            return(entries);
        }
Beispiel #4
0
        public async Task <bool> AddToPlaylist(Track song, Playlist playlist, string notes = "")
        {
            try{
                if (string.IsNullOrWhiteSpace(playlist.Id))
                {
                    playlist.ServiceType = ServiceType;
                    await CreatePlaylist(playlist);
                }
                var content = !string.IsNullOrWhiteSpace(notes) ? new PlaylistItemContentDetails
                {
                    Note = notes
                } : null;
                var body = new Google.Apis.Youtube.v3.Data.PlaylistItem {
                    Snippet = new PlaylistItemSnippet {
                        PlaylistId = playlist.Id,
                        ResourceId = new ResourceId {
                            Kind    = "youtube#video",
                            VideoId = song.Id,
                        }
                    },
                    ContentDetails = content
                };
                var resp = await Api.Post <Google.Apis.Youtube.v3.Data.PlaylistItem> (body, "playlistItems?part=id%2CcontentDetails%2Csnippet");

                if (string.IsNullOrWhiteSpace(body.Id))
                {
                    return(false);
                }
                var id   = body.ContentDetails.VideoId;
                var note = GetNotes(body.ContentDetails?.Note) ?? new Notes
                {
                    Title = body.Snippet.Title,
                };
                var t = new FullPlaylistTrackData(note.Title, note.Artist, note.AlbumArtist, note.Album, note.Genre)
                {
                    AlbumArtwork = new List <AlbumArtwork> {
                        new AlbumArtwork {
                            Url = string.Format("http://img.youtube.com/vi/{0}/0.jpg", id)
                        }
                    },
                    MediaType       = MediaType.Video,
                    ServiceId       = Id,
                    Id              = id,
                    ServiceType     = ServiceType,
                    FileExtension   = "mp4",
                    TrackId         = id,
                    PlaylistId      = playlist.Id,
                    PlaylistEntryId = body.Id,
                    SOrder          = body.Snippet.Position ?? 1000,
                    Disc            = note.Disc,
                    Year            = note.Year,
                    Track           = note.Track,
                };
                await ProcessPlaylistTracks(new List <FullPlaylistTrackData> {
                    t
                }, new List <TempPlaylistEntry>());
                await FinalizePlaylists(Id);

                return(true);
            }
            catch (Exception ex) {
                LogManager.Shared.Report(ex);
                return(false);
            }
        }
Beispiel #5
0
        public override async Task <bool> AddToPlaylist(System.Collections.Generic.List <Track> songs, Playlist playlist)
        {
            foreach (var track in songs)
            {
                if (!await AddToPlaylist(track, playlist))
                {
                    return(false);
                }
            }

            await FinalizePlaylists(Id);

            return(true);
        }
 public override async Task <bool> AddToPlaylist(System.Collections.Generic.List <MusicPlayer.Models.Track> songs, MusicPlayer.Models.Playlist playlist)
 {
     App.ShowNotImplmented();
     return(false);
 }
 public override async Task <bool> DeletePlaylist(MusicPlayer.Models.Playlist playlist)
 {
     App.ShowNotImplmented();
     return(false);
 }