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
@ChunkyProgrammer ChunkyProgrammer force-pushed the parse-hashtag-header-in-api branch from e23e4b6 to 6c8f9a6 Compare June 6, 2023 23:44
@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
@ChunkyProgrammer ChunkyProgrammer force-pushed the parse-hashtag-header-in-api branch 2 times, most recently from 13761c9 to c64e2f1 Compare July 16, 2023 20:27
@ChunkyProgrammer ChunkyProgrammer marked this pull request as draft August 27, 2023 20:51
@ChunkyProgrammer ChunkyProgrammer force-pushed the parse-hashtag-header-in-api branch from fd8cf49 to 0cc0670 Compare September 7, 2023 04:14
@ChunkyProgrammer ChunkyProgrammer marked this pull request as ready for review September 7, 2023 04:54
@ChunkyProgrammer ChunkyProgrammer force-pushed the parse-hashtag-header-in-api branch from 3594b4f to 6197b84 Compare September 7, 2023 04:58
@ChunkyProgrammer ChunkyProgrammer force-pushed the parse-hashtag-header-in-api branch from 6197b84 to 30a8768 Compare September 19, 2023 00:12
@ChunkyProgrammer ChunkyProgrammer force-pushed the parse-hashtag-header-in-api branch from 30a8768 to 6fbcd13 Compare October 16, 2023 04:32
@ChunkyProgrammer ChunkyProgrammer force-pushed the parse-hashtag-header-in-api branch from 6fbcd13 to 6bf7d1e Compare December 7, 2023 14:40
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.

@github-actions github-actions bot added the stale label Mar 7, 2024
@ChunkyProgrammer ChunkyProgrammer force-pushed the parse-hashtag-header-in-api branch from 6bf7d1e to da0f0a0 Compare March 8, 2024 01:19
@ChunkyProgrammer
Copy link
Contributor Author

Updated and working again

@github-actions github-actions bot removed the stale label Mar 8, 2024
@ChunkyProgrammer ChunkyProgrammer force-pushed the parse-hashtag-header-in-api branch from 8117a49 to 2098a24 Compare April 29, 2024 19:37
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.

@github-actions github-actions bot added the stale label Jul 29, 2024
@ChunkyProgrammer ChunkyProgrammer force-pushed the parse-hashtag-header-in-api branch from 2098a24 to 7a24f45 Compare July 29, 2024 01:45
@ChunkyProgrammer
Copy link
Contributor Author

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

@github-actions github-actions bot removed the stale label Jul 29, 2024
@ChunkyProgrammer ChunkyProgrammer force-pushed the parse-hashtag-header-in-api branch from 7a24f45 to 26f852f Compare August 13, 2024 19:11
@ChunkyProgrammer ChunkyProgrammer force-pushed the parse-hashtag-header-in-api branch from 26f852f to 6218eb2 Compare August 24, 2024 22:03
@ChunkyProgrammer ChunkyProgrammer force-pushed the parse-hashtag-header-in-api branch from 4ae86e6 to 58d294f Compare October 1, 2024 02:02
@ChunkyProgrammer ChunkyProgrammer force-pushed the parse-hashtag-header-in-api branch from 58d294f to 29c0036 Compare October 30, 2024 16:56
@ChunkyProgrammer ChunkyProgrammer force-pushed the parse-hashtag-header-in-api branch from 29c0036 to f530817 Compare November 17, 2024 18:19
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