Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hashtag API: Parse header when getting the first page #3864

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ChunkyProgrammer
Copy link
Contributor

@ChunkyProgrammer ChunkyProgrammer commented Jun 6, 2023

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 ChunkyProgrammer requested a review from a team as a code owner June 6, 2023 23:39
@ChunkyProgrammer ChunkyProgrammer requested review from unixfox and removed request for a team June 6, 2023 23:39
@unixfox unixfox requested review from SamantazFox and removed request for unixfox June 7, 2023 20:25
@SamantazFox
Copy link
Member

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

@ChunkyProgrammer
Copy link
Contributor Author

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

It was mentioned in my PR to add hashtag pags to FreeTube FreeTubeApp/FreeTube#3483 (comment)

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

@efb4f5ff-1298-471a-8973-3d47447115dc

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.

@SamantazFox
Copy link
Member

Ah, I see, thanks!

src/invidious/helpers/serialized_yt_data.cr Outdated Show resolved Hide resolved
src/invidious/yt_backend/extractors.cr Outdated Show resolved Hide resolved
src/invidious/yt_backend/extractors.cr Outdated Show resolved Hide resolved
src/invidious/hashtag.cr Outdated Show resolved Hide resolved
@ChunkyProgrammer ChunkyProgrammer force-pushed the parse-hashtag-header-in-api branch 2 times, most recently from d6a93fb to 0fc1c70 Compare July 15, 2023 15:52
Copy link

github-actions bot commented Mar 7, 2024

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.

@ChunkyProgrammer
Copy link
Contributor Author

Updated and working again

Copy link

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.

@ChunkyProgrammer
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants