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

Retrieve a random comment of a given video #2

Open
Benjamin-Loison opened this issue Dec 21, 2023 · 2 comments
Open

Retrieve a random comment of a given video #2

Benjamin-Loison opened this issue Dec 21, 2023 · 2 comments

Comments

@Benjamin-Loison
Copy link

Benjamin-Loison commented Dec 21, 2023

I quite deeply investigated trying to do so but still do not achieve to do so. Let me explain my question below:

When considering the nextPageToken provided by YouTube Data API v3 CommentThreads: list endpoint (note that YouTube UI comments retrieval seems to rely on a YouTube Data API v3 superset page token) for video id tnTPaLOaHz8 with maxResults=96 I get:

"nextPageToken": "Z2V0X25ld2VzdF9maXJzdC0tQ2dnSWdBUVZGN2ZST0JJRkNJZ2dHQUFTQlFpZElCZ0JFZ1VJaVNBWUFCSUZDSWNnR0FBU0JRaWVJQmdBR0FBaURRb0xDTVR0akt3R0VORE5pbGM="
echo 'Z2V0X25ld2VzdF9maXJzdC0tQ2dnSWdBUVZGN2ZST0JJRkNJZ2dHQUFTQlFpZElCZ0JFZ1VJaVNBWUFCSUZDSWNnR0FBU0JRaWVJQmdBR0FBaURRb0xDTVR0akt3R0VORE5pbGM=' | base64 -d

gives:

get_newest_first--CggIgAQVF7fROBIFCIggGAASBQidIBgBEgUIiSAYABIFCIcgGAASBQieIBgAGAAiDQoLCMTtjKwGENDNilc

Hence:

echo 'CggIgAQVF7fROBIFCIggGAASBQidIBgBEgUIiSAYABIFCIcgGAASBQieIBgAGAAiDQoLCMTtjKwGENDNilc=' | base64 -d | protoc --decode_raw

results in:

1 {
  1: 512
  2: 0x38d1b717
}
2 {
  1: 4104
  3: 0
}
2 {
  1: 4125
  3: 1
}
2 {
  1: 4105
  3: 0
}
2 {
  1: 4103
  3: 0
}
2 {
  1: 4126
  3: 0
}
3: 0
4 {
  1 {
    1: 1703098052
    2: 182626000
  }
}

Note that I had to append = to make base64 not output base64: invalid input hence protoc Failed to parse input..

From my tests to get a random comment (denoted by an index) of a given video, 182626000 seems to be the value to change to force the wanted random comment index. While I know that protobuf is ambiguous I would really love to get a meaningful description of what stands behind this 182626000 to force the value that I want. Do you have any idea how to proceed?

My goal is to avoid a linear complexity in the number of comments of the video. For instance for a video with 100,000 comments I randomly generate 42,327 but would like to get the 42,327th comment without having to go through 424 pages of 100 results.

@menmob
Copy link
Owner

menmob commented Dec 26, 2023

This would be super cool to have, (truly) random comments would definitely be interesting data to have. I'll take a look in the next few days here, but I admittedly have not messed around with Innertube/Protobuf in a while, so we'll see if I get can anywhere.

BTW, I'm happy you are using this repo for your project, even if you do seem to be the only one haha.

Let me know if you found anything since you opened this issue, I know I'm a week late now 🙃

@Benjamin-Loison
Copy link
Author

No worries about being late, I have not made any progress and do not plan to do any concerning this very specific question due to priorities. The current heavy workaround that I have found consists in retrieving all comments of the given video and then sample randomly the one I am interested in.

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

No branches or pull requests

2 participants