invidious icon indicating copy to clipboard operation
invidious copied to clipboard

Hashtag API: Parse header when getting the first page

Open ChunkyProgrammer opened this issue 2 years ago • 8 comments

When requesting the first page of a hashtag (without continuations), YouTube will include a hashtag header that includes info such as the # of videos and # of channels in the hashtag.

This PR will parse those properties (it also creates separate structs for the hashtag page + header)

Before

{
  "results": [
    {
      "type": "video",
      ...
    }
  ]
}

After

Page 1:

{
  "type": "hashtagPage",
  "header": {
    "type": "hashtag",
    "title": "#cat",
    "url": "/hashtag/cat",
    "channelCount": 8100000,
    "videoCount": 1100000
  },
  "results": [
    {
      "type": "video",
      ...
    }
  ],
  "hasNextPage": true
}

Page 2:

{
  "type": "hashtagPage",
  "results": [
    {
      "type": "video",
      ...
    }
  ],
  "hasNextPage": true
}

Tests: go to : /api/v1/hashtag/cat?page=1 or /api/v1/hashtag/cat and see the header in the json response go to /api/v1/hashtag/cat?page=2 and no longer see the header on page 2

ChunkyProgrammer avatar Jun 06 '23 23:06 ChunkyProgrammer

Are these infos really useful? The numbers looks very approximated.

SamantazFox avatar Jul 01 '23 19:07 SamantazFox

Are these infos really useful? The numbers looks very approximated.

It was mentioned in my PR to add hashtag pags to FreeTube https://github.com/FreeTubeApp/FreeTube/pull/3483#issuecomment-1537138092

@efb4f5ff-1298-471a-8973-3d47447115dc any thoughts on this?

ChunkyProgrammer avatar Jul 04 '23 13:07 ChunkyProgrammer

Sorry for the delay. So i mentioned the possibility to add this because with the stats the user knows what they are getting into. A hashtag with low amount of approximate videos could make the user go through all of them and a high amount can make the user refrain from watching too much and falling into hours of watching videos.

Ah, I see, thanks!

SamantazFox avatar Jul 14 '23 16:07 SamantazFox

This pull request has been automatically marked as stale and will be closed in 30 days because it has not had recent activity and is much likely abandoned or outdated. If you think this pull request is still relevant and applicable, you just have to post a comment and it will be unmarked.

github-actions[bot] avatar Mar 07 '24 00:03 github-actions[bot]

Updated and working again

ChunkyProgrammer avatar Mar 08 '24 02:03 ChunkyProgrammer

This pull request has been automatically marked as stale and will be closed in 30 days because it has not had recent activity and is much likely abandoned or outdated. If you think this pull request is still relevant and applicable, you just have to post a comment and it will be unmarked.

github-actions[bot] avatar Jul 29 '24 01:07 github-actions[bot]

Code is still working, I also added some tests to the description

ChunkyProgrammer avatar Jul 29 '24 01:07 ChunkyProgrammer