public ArtistResult(Content content)
 {
     Thumbnails = ContentStaticHelpers.GetThumbnails(content);
     BrowseId   = content.MusicResponsiveListItemRenderer.NavigationEndpoint.BrowseEndpoint.BrowseId;
     IsUpload   = ContentStaticHelpers.BrowseIdIndicatedUpload(BrowseId);
     Title      = content.MusicResponsiveListItemRenderer.FlexColumns[IndexInColumnsForArtistName].MusicResponsiveListItemFlexColumnRenderer.Text.Runs[IndexInRuns].Text;
 }
        private static void ParseInnerContent(SearchResult ret, Content content, SearchResultType filter)
        {
            SearchResultType type = ContentStaticHelpers.GetSearchResultType(content);
            int defaultIndex      = filter == SearchResultType.All ? 1 : 0;

            switch (type)
            {
            case SearchResultType.Album:
                ret.Albums.Add(new AlbumResult(content));
                break;

            case SearchResultType.Artist:
                ret.Artists.Add(new ArtistResult(content));
                break;

            case SearchResultType.Playlist:
                ret.Playlists.Add(new PlaylistResult(content, defaultIndex));
                break;

            case SearchResultType.Song:
                ret.Songs.Add(new SongResult(content, defaultIndex));
                break;

            case SearchResultType.Video:
                ret.Videos.Add(new VideoResult(content, defaultIndex));
                break;

            case SearchResultType.Upload:
                throw new Exception("We should not be handling Uploads specifically, Uploads should be handled as the type they are (Album, Artist, Song)");

            default:
                throw new Exception($"Unsupported type when parsing generated result: {type}");
            }
        }
 public PlaylistResult(Content content, int defaultIndex)
 {
     Thumbnails = ContentStaticHelpers.GetThumbnails(content);
     BrowseId   = content.MusicResponsiveListItemRenderer.NavigationEndpoint.BrowseEndpoint.BrowseId;
     Title      = content.MusicResponsiveListItemRenderer.FlexColumns[IndexInColumnsForTitle].MusicResponsiveListItemFlexColumnRenderer.Text.Runs[IndexInRuns].Text;
     Author     = content.MusicResponsiveListItemRenderer.FlexColumns[defaultIndex + IndexInColumnsForAuthor].MusicResponsiveListItemFlexColumnRenderer.Text.Runs[IndexInRuns].Text;
     ItemCount  = content.MusicResponsiveListItemRenderer.FlexColumns[defaultIndex + IndexInColumnsForItemCount].MusicResponsiveListItemFlexColumnRenderer.Text.Runs[IndexInRuns].Text.Split(' ')[0];
 }
        public VideoResult(Content content, int defaultIndex)
        {
            Thumbnails = ContentStaticHelpers.GetThumbnails(content);
            VideoId    = content.MusicResponsiveListItemRenderer.Overlay.MusicItemThumbnailOverlayRenderer.Content.MusicPlayButtonRenderer.PlayNavigationEndpoint.WatchEndpoint.VideoId;
            Params     = content.MusicResponsiveListItemRenderer.Overlay.MusicItemThumbnailOverlayRenderer.Content.MusicPlayButtonRenderer.PlayNavigationEndpoint.WatchEndpoint.Params;

            Title    = content.MusicResponsiveListItemRenderer.FlexColumns[IndexInColumnsForTitle].MusicResponsiveListItemFlexColumnRenderer.Text.Runs[IndexInRuns].Text;
            Artist   = content.MusicResponsiveListItemRenderer.FlexColumns[defaultIndex + IndexInColumnsForArtist].MusicResponsiveListItemFlexColumnRenderer.Text.Runs[IndexInRuns].Text;
            Views    = content.MusicResponsiveListItemRenderer.FlexColumns[defaultIndex + IndexInColumnsForViews].MusicResponsiveListItemFlexColumnRenderer.Text.Runs[IndexInRuns].Text;
            Duration = content.MusicResponsiveListItemRenderer.FlexColumns[defaultIndex + IndexInColumnsForDuration].MusicResponsiveListItemFlexColumnRenderer.Text.Runs[IndexInRuns].Text;
        }
Example #5
0
        public SongResult(Content content, int defaultIndex)
        {
            Thumbnails = ContentStaticHelpers.GetThumbnails(content);
            Title      = content.MusicResponsiveListItemRenderer.FlexColumns[IndexInColumnsForTitle].MusicResponsiveListItemFlexColumnRenderer.Text.Runs[IndexInRuns].Text;

            // Get artists first, so we can know if this is uploaded or not
            content.MusicResponsiveListItemRenderer.FlexColumns[defaultIndex + IndexInColumnsForArtists].MusicResponsiveListItemFlexColumnRenderer.Text.Runs.ForEach(x => Artists.Add(new IdNamePair(x.NavigationEndpoint.BrowseEndpoint.BrowseId, x.Text)));
            IsUpload = ContentStaticHelpers.BrowseIdIndicatedUpload(Artists[0].Id);
            if (IsUpload)
            {
                VideoId    = content.MusicResponsiveListItemRenderer.FlexColumns[IndexInColumnsForVideoId].MusicResponsiveListItemFlexColumnRenderer.Text.Runs[IndexInRuns].NavigationEndpoint.WatchEndpoint.VideoId;
                PlaylistId = content.MusicResponsiveListItemRenderer.FlexColumns[IndexInColumnsForPlaylistId].MusicResponsiveListItemFlexColumnRenderer.Text.Runs[IndexInRuns].NavigationEndpoint.WatchEndpoint.PlaylistId;
            }
            else
            {
                VideoId = content.MusicResponsiveListItemRenderer.Overlay.MusicItemThumbnailOverlayRenderer.Content.MusicPlayButtonRenderer.PlayNavigationEndpoint.WatchEndpoint.VideoId;
                Params  = content.MusicResponsiveListItemRenderer.Overlay.MusicItemThumbnailOverlayRenderer.Content.MusicPlayButtonRenderer.PlayNavigationEndpoint.WatchEndpoint.Params;
            }

            var flexColumnCount = content.MusicResponsiveListItemRenderer.FlexColumns.Count;

            // may not have an album
            if (flexColumnCount >= (defaultIndex + IndexInColumnsForAlbum + 1))
            {
                var albumRun = content.MusicResponsiveListItemRenderer.FlexColumns[defaultIndex + IndexInColumnsForAlbum].MusicResponsiveListItemFlexColumnRenderer.Text.Runs[IndexInRuns];
                Album = new IdNamePair(albumRun.NavigationEndpoint.BrowseEndpoint.BrowseId, albumRun.Text);
            }

            if (flexColumnCount >= (defaultIndex + IndexInColumnsForDuration + 1))
            {
                Duration = content.MusicResponsiveListItemRenderer.FlexColumns[defaultIndex + IndexInColumnsForDuration].MusicResponsiveListItemFlexColumnRenderer.Text.Runs[IndexInRuns].Text;
            }
            else
            {
                //duration might be in fixedColumns
                if (content.MusicResponsiveListItemRenderer.FixedColumns != null &&
                    content.MusicResponsiveListItemRenderer.FixedColumns.Count > 0 &&
                    content.MusicResponsiveListItemRenderer.FixedColumns[0].MusicResponsiveListItemFixedColumnRenderer != null)
                {
                    Duration = content.MusicResponsiveListItemRenderer.FixedColumns[0].MusicResponsiveListItemFixedColumnRenderer.Text.Runs[0].Text;
                }
            }
        }
Example #6
0
        public AlbumResult(Content content)
        {
            Thumbnails = ContentStaticHelpers.GetThumbnails(content);
            BrowseId   = content.MusicResponsiveListItemRenderer.NavigationEndpoint.BrowseEndpoint.BrowseId;
            IsUpload   = ContentStaticHelpers.BrowseIdIndicatedUpload(BrowseId);

            Title = content.MusicResponsiveListItemRenderer.FlexColumns[IndexInColumnsForTitle].MusicResponsiveListItemFlexColumnRenderer.Text.Runs[IndexInRuns].Text;

            AlbumType = content.MusicResponsiveListItemRenderer.FlexColumns[IndexInColumnsForAlbumType].MusicResponsiveListItemFlexColumnRenderer.Text.Runs[IndexInRuns].Text;

            var countFlexColumns = content.MusicResponsiveListItemRenderer.FlexColumns.Count;
            var runs             = content.MusicResponsiveListItemRenderer.FlexColumns[IndexInColumnsForAlbumType].MusicResponsiveListItemFlexColumnRenderer.Text.Runs;

            if (countFlexColumns >= IndexInColumnsForArtist + 1)
            {
                Artist = content.MusicResponsiveListItemRenderer.FlexColumns[IndexInColumnsForArtist].MusicResponsiveListItemFlexColumnRenderer.Text.Runs[IndexInRuns].Text;
            }

            if (countFlexColumns >= IndexInColumnsForYear + 1)
            {
                Year = content.MusicResponsiveListItemRenderer.FlexColumns[IndexInColumnsForYear].MusicResponsiveListItemFlexColumnRenderer.Text.Runs[IndexInRuns].Text;
            }

            if (countFlexColumns >= IndexInColumnsForReleaseDate + 1)
            {
                ReleaseDate = content.MusicResponsiveListItemRenderer.FlexColumns[IndexInColumnsForReleaseDate].MusicResponsiveListItemFlexColumnRenderer.Text.Runs[IndexInRuns].Text;
            }

            if (runs.Count >= IndexInColumnsForArtist + 1)
            {
                Artist = runs[IndexInColumnsForArtist].Text;
            }

            if (runs.Count >= IndexInColumnsForReleaseDate + 1)
            {
                ReleaseDate = runs[IndexInColumnsForReleaseDate].Text;
            }
        }