Exemplo n.º 1
0
        public static ArtistSongsResult FromMusicResponsiveListItemRenderer(MusicResponsiveListItemRenderer renderer)
        {
            ArtistSongsResult song = new ArtistSongsResult();

            song.Thumbnails = renderer.Thumbnail.MusicThumbnailRenderer.Thumbnail.Thumbnails;

            var trackRuns = renderer.FlexColumns[0].MusicResponsiveListItemFlexColumnRenderer.Text.Runs[0];

            song.Title   = trackRuns.Text;
            song.VideoId = trackRuns.NavigationEndpoint.WatchEndpoint.VideoId;

            var artistRuns = renderer.FlexColumns[1].MusicResponsiveListItemFlexColumnRenderer.Text.Runs;

            foreach (var run in artistRuns)
            {
                if (run.NavigationEndpoint != null && run.Text != ", ")
                {
                    song.Artists.Add(new IdNamePair(run.NavigationEndpoint.BrowseEndpoint.BrowseId, run.Text));
                }
            }

            var albumRuns = renderer.FlexColumns[2].MusicResponsiveListItemFlexColumnRenderer.Text.Runs;

            song.Album = new IdNamePair(albumRuns[0].NavigationEndpoint.BrowseEndpoint.BrowseId, albumRuns[0].Text);

            song.LikeStatus = (LikeStatus)Enum.Parse(typeof(LikeStatus), renderer.Menu.MenuRenderer.TopLevelButtons[0].LikeButtonRenderer.LikeStatus);

            return(song);
        }
Exemplo n.º 2
0
        public static Songs FromMusicShelfRenderer(MusicShelfRenderer renderer)
        {
            Songs songs = new Songs();

            var songsRuns = renderer.Title.Runs[0];

            if (songsRuns.NavigationEndpoint != null)
            {
                songs.BrowseId = songsRuns.NavigationEndpoint.BrowseEndpoint.BrowseId;
                // do we need params?
                // songs.Parameters = songsRuns.NavigationEndpoint.BrowseEndpoint.Params;
            }

            foreach (var content in renderer.Contents)
            {
                songs.Results.Add(ArtistSongsResult.FromMusicResponsiveListItemRenderer(content.MusicResponsiveListItemRenderer));
            }

            return(songs);
        }