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

Update ytdl_hook.lua: Fix yt-dlp's Incomplete data received error which is rather non-critical to catch #12511

Closed
wants to merge 4 commits into from

Conversation

GunGunGun
Copy link

@GunGunGun GunGunGun commented Sep 28, 2023

Because Incomplete data received isn't critical, should only check if json is blank.

Currently if you open a playlist with MPV, it's throwing this error:

mpv https://www.youtube.com/playlist?list=PLVM1qRtVEeErISdPLpYEc53XEHU5m34cl
[ytdl_hook] ERROR: Incomplete data received
[ytdl_hook] youtube-dl failed: unexpected error occurred
Failed to recognize file format.

Read this before you submit this pull request:
https://github.com/mpv-player/mpv/blob/master/DOCS/contribute.md

Reading this link and following the rules will get your pull request reviewed
and merged faster. Nobody wants lazy pull requests.

Because `Incomplete data received` isn't critical, should only check if json is blank.
@Earnestly
Copy link

Can confirm this PR solves the very same issue I was experiencing recently; tested on commit f9234d8.

@christoph-heinrich
Copy link
Contributor

christoph-heinrich commented Sep 28, 2023

yt-dlp also returns non zero status codes for other non critical errors, but some of those cases can result in not all playlist entries getting listed, and the way it is now there is no feedback that there even is something that wasn't fully successful.

Have you looked at the specific status code? Maybe we can react differently to different status codes.

Edit: Apparently the current exit codes are this and here is a related issue yt-dlp/yt-dlp#2947. There doesn't seem to have been any progress 😞

Edit2: It's a already known issue on yt-dlp's side yt-dlp/yt-dlp#8206
Also if you ever want to get this in, please have a look at the contribution guidelines for what commits should look like.

@krasnh
Copy link

krasnh commented Sep 28, 2023

This solved the problem with YouTube playlists.

@GunGunGun
Copy link
Author

@christoph-heinrich

Have you looked at the specific status code? Maybe we can react differently to different status codes.

I debugged it quite a bit result.status = 1 in this case.

Full result logging if you want it:

[ytdl_hook] status: 1
[ytdl_hook] reason:
[ytdl_hook] stdout: {"id": "PLVM1qRtVEeErISdPLpYEc53XEHU5m34cl", "title": "Let's Play Symphony of War: Nephilim Saga", "availability": "public", "channel_follower_count": null, "description": "", "tags": [], "thumbnails": [{"url": "https://i.ytimg.com/vi/D0wjqctK9KQ/hqdefault.jpg?sqp=-[STRIPPED_CUZ_USELESS]....
[ytdl_hook]
[ytdl_hook] stderr: ERROR: Incomplete data received
[ytdl_hook]
[ytdl_hook] ERROR: Incomplete data received
[ytdl_hook] youtube-dl failed: unexpected error occurred

@christoph-heinrich
Copy link
Contributor

christoph-heinrich commented Sep 29, 2023

I debugged it quite a bit result.status = 1 in this case.

No surprise there, considering the exit codes I linked.

I still don't like that the error gets completely ignored now. We should at least print a warning with stderr and status when status~=0 but the json is still usable.

@GunGunGun
Copy link
Author

GunGunGun commented Sep 29, 2023

@christoph-heinrich

I still don't like that the error gets completely ignored now. We should at least print a warning with stderr and status when status~=0 but the json is still usable.

How about parsing the JSON first, I'll create a new commit and let's see if it's okay.

Actually I followed your idea and just print a warning instead.

Add warning about error code != 0 and JSON is parsed without errors.
@christoph-heinrich
Copy link
Contributor

@christoph-heinrich

I still don't like that the error gets completely ignored now. We should at least print a warning with stderr and status when status~=0 but the json is still usable.

How about parsing the JSON first, I'll create a new commit and let's see if it's okay.

Actually I followed your idea and just print a warning instead.

Hmm...

at least print a warning with stderr and status

> at least print a warning with stderr and status
@GunGunGun
Copy link
Author

@christoph-heinrich

at least print a warning with stderr and status

It's done.

@po5
Copy link
Contributor

po5 commented Sep 29, 2023

Read this before you submit this pull request:
https://github.com/mpv-player/mpv/blob/master/DOCS/contribute.md

Copy link
Contributor

@christoph-heinrich christoph-heinrich left a comment

Choose a reason for hiding this comment

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

https://github.com/mpv-player/mpv/blob/master/DOCS/contribute.md#write-good-commit-messages
https://github.com/mpv-player/mpv/blob/master/DOCS/contribute.md#always-squash-fixup-commits-when-making-changes-to-pull-requests

The PR template literally says

Read this before you submit this pull request:
https://github.com/mpv-player/mpv/blob/master/DOCS/contribute.md

Reading this link and following the rules will get your pull request reviewed
and merged faster. Nobody wants lazy pull requests.

player/lua/ytdl_hook.lua Outdated Show resolved Hide resolved
Co-authored-by: christoph-heinrich <christoph-heinrich@users.noreply.github.com>
@GunGunGun
Copy link
Author

@po5 @christoph-heinrich I see, I've read the guide and thanks!

@github-actions
Copy link

github-actions bot commented Oct 2, 2023

Download the artifacts for this pull request:

Windows

@Dudemanguy
Copy link
Member

Can you please squash your commits?

@christoph-heinrich
Copy link
Contributor

fwiw that specific playlist issue has already been fixed by yt-dlp. It may still make sense to allow parse-able jsons to continue, but I'm worried that it will end up leading to crashes because the json didn't contain fields that are assumed to exist by other parts of the ytdl_hook.

I don't know if such a scenario can actually happen, and technically there is always the possibility of them changing up their json structure, but it's a concern nonetheless.

@Dudemanguy
Copy link
Member

Dudemanguy commented Oct 7, 2023

Oh I had assumed it was another one of those "the ytdl_hook is outdated again" things. If there's no actually concrete issue this solves anymore, then I don't think we need this? All the concerns you raised are valid and if there's a use case then, we can revisit it later.

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

Successfully merging this pull request may close these issues.

None yet

7 participants