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

Channels: Fix "Youtube API returned error 400" #5059

Merged
merged 10 commits into from
Nov 8, 2024

Conversation

SamantazFox
Copy link
Member

@SamantazFox SamantazFox commented Nov 7, 2024

Closes #4029
Closes #5021
Closes #5029

Requires #5027 to be merged first.
Does NOT address #4477

This PR also adds sort option for shorts.

@SamantazFox SamantazFox requested a review from a team as a code owner November 7, 2024 22:06
@SamantazFox SamantazFox requested review from unixfox and removed request for a team November 7, 2024 22:06
@SamantazFox SamantazFox marked this pull request as draft November 7, 2024 22:21
@SamantazFox
Copy link
Member Author

Videos and livestreams work, but the rest is still broken. No error, though, that's progress!

@Despernal
Copy link

I can validate this does fix the issue with both subscriptions and livestreams showing now and applying the patch below in issue 4975

4975

which i know is a temp solution makes master branch work again for me.

I have a private instance on a residential ip.

I appreciate the hard work

acheong08 added a commit to acheong08/invidious that referenced this pull request Nov 8, 2024
@iBicha
Copy link
Contributor

iBicha commented Nov 8, 2024

Videos and livestreams work, but the rest is still broken. No error, though, that's progress!

Looks to me like there's some parser work to do.
E.g. on the response for channel shorts, I see the shorts are under
onResponseReceivedActions[1].reloadContinuationItemsCommand.continuationItems[i].richItemRenderer.content.shortsLockupViewModel

@Fijxu
Copy link
Contributor

Fijxu commented Nov 8, 2024

src/invidious/channels/videos.cr Outdated Show resolved Hide resolved
@SamantazFox
Copy link
Member Author

Looks to me like there's some parser work to do.

@iBicha Yes, I realized that late yesterday, but I had to go to sleep x)
I've added a commit for podcasts this morning, and I'm currently working on the shorts.

@SamantazFox

This comment was marked as outdated.

The 'lockupViewModel' structure is used in the channel "podcasts" tab
The 'shortsLockupViewModel' structure is used in the channel "shorts" tab
Fix the "newest" link not being bold when 'sort_by' uses the default value
Show 60 videos per page, rather than 30
@SamantazFox

This comment was marked as outdated.

@mtarnawa
Copy link

mtarnawa commented Nov 8, 2024

@SamantazFox - I also tested your changes and everything seems to be working fine again, thanks so much, keeping fingers crossed this gets merged soon.

On a side note - what's the issue with playlists? I haven't noticed any problems.

@SamantazFox
Copy link
Member Author

Here is my problem!
image

private def make_initial_videos_ctoken(ucid : String, sort_by = "newest")
object = {
"15:embedded" => {
"2:string" => "\n$00000000-0000-0000-0000-000000000000",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird, shouldn't this be an embedded with a 1:string in it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have absolutely no idea why this one is different like that, but that's what the official client sends, sooooo....

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this is interesting, they are the same!
the \n is basically a decimal 10, which is 1010 binary. That is a field number 1, and a wire type 2 (length-delimited)
then the $ is a decimal 36, which is exactly the length of 00000000-0000-0000-0000-000000000000.
So both objects end up being encoded into the same data.
I think having it like the other one (embedded object with a subfield number 1) would be better for clarity (and could also allow you to refactor / reuse code)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh, you're right! That's likely a weird bug of our parser Protodec.

having it like the other one (embedded object with a subfield number 1) would be better for clarity (and could also allow you to refactor / reuse code)

Yeah, that's indeed much less cryptic that way! However, I'll keep the two functions separate to not need an extra parameter and a string interpolation.

@SamantazFox
Copy link
Member Author

@syeopite It might be a good idea to add a verified field to that AuthorFallback structure, as these new lockupViewModel and shortLockupViewModel are very empty: I had to stub the author_verified field to false.

@SamantazFox SamantazFox marked this pull request as ready for review November 8, 2024 16:49
@SamantazFox SamantazFox requested a review from syeopite November 8, 2024 16:49
@SamantazFox SamantazFox added the in-testing This feature has been deployed and is being tested label Nov 8, 2024
Change explanation, courtesy of iBicha:
The \n is basically a decimal 10, which is 1010 binary. That is a field number
1, and a wire type 2 (length-delimited). Then the $ is a decimal 36, which is
exactly the length of 00000000-0000-0000-0000-000000000000.
So both objects end up being encoded into the same data.
Comment on lines +695 to +698
# Approximate to one minute, as "shorts" generally don't exceed that.
# NOTE: The actual duration is not provided by Youtube anymore.
# TODO: Maybe use -1 as an error value and handle that on the frontend?
duration = 60_i32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I would prefer using an error value instead of inventing a value so that it can be distinguished from videos with an actual duration. The front end could then just hide the duration when it is not available (in my mind not having the information on the page is better than making up a value).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly agree on using an error value, but the rest of our frontend is not prepared to handle that. Given the urgency of this patch, I'd prefer to take care of it later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Invidious frontend can't even handle null values most of the time 😅 meaning that we have to provide a value even if it doesn't make sense. There's a lot of technical debt that needs to be resolved eventually...

# Parses an InnerTube lockupViewModel into a SearchPlaylist.
# Returns nil when the given object is not a lockupViewModel.
#
# This structure is present since November 2024 on the "podcasts" and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small nitpick about the dates, the podcasts tab has been like that since at least February 2024 as that is when I created the YouTube.js PR to handle it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah lol. It seems that nobody uses them, as I couldn't find an issue related to that!

@SamantazFox SamantazFox added ready and removed in-testing This feature has been deployed and is being tested labels Nov 8, 2024
@SamantazFox SamantazFox merged commit 1480e00 into iv-org:master Nov 8, 2024
9 checks passed
@SamantazFox SamantazFox deleted the channels-fix branch November 8, 2024 22:48
@UltraBlackLinux

This comment was marked as resolved.

@cephi-sui

This comment was marked as resolved.

@UltraBlackLinux

This comment was marked as resolved.

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