chat-downloader
chat-downloader copied to clipboard
[BUG] VideoUnavailable is raised when trailer is present and chat is disabled.
Basic information
- Program version: 0.1.10
- Python version: 3.10.2
- Operating system: Arch Linux x64, linux 5.15.25-1-lts
Describe the bug
VideoUnavailable is raised when trailer is present and chat is disabled. Affects both cli and python api.
Command/Code used
If running from the command line, provide the following:
- The command used (including the verbose tag,
-v):
$ chat_downloader "yGJ6jYRfqTk" --message_groups "all" --indent 2 --log=debug
- Output from the above command:
[DEBUG] Python version: 3.10.2 (main, Jan 15 2022, 19:56:27) [GCC 11.1.0]
[DEBUG] Program version: 0.1.10
[DEBUG] Initialisation parameters: {'headers': None, 'cookies': None, 'proxy': None}
[DEBUG] Created YouTubeChatDownloader session.
[INFO] Site: youtube.com
[DEBUG] Program parameters: {'url': 'yGJ6jYRfqTk', 'start_time': None, 'end_time': None, 'max_attempts': 15, 'retry_timeout': None, 'interruptible_retry': True, 'timeout': None, 'inactivity_timeout': None, 'max_messages': None, 'message_groups': ['all'], 'message_types': None, 'output': None, 'overwrite': True, 'sort_keys': True, 'indent': 2, 'format': 'youtube', 'format_file': None, 'chat_type': 'live', 'ignore': None, 'message_receive_timeout': 0.1, 'buffer_size': 4096}
[DEBUG] Starting new HTTPS connection (1): www.youtube.com:443
[DEBUG] https://www.youtube.com:443 "GET /watch?v=yGJ6jYRfqTk HTTP/1.1" 200 None
<too long, see response in file>
[ERROR] LIVE_STREAM_OFFLINE: This live event will begin in 15 hours.
[DEBUG] Session closed.
If the output is too long, you can attach a text file or remove output which does not constitute to the problem.
Expected behavior
ChatDisabled should be raised.
Additional context/information
VideoUnavailable tells us that the video is removed, while ChatDisabled tells us to retry.
In the player response, the playabilityStatus has the "errorScreen" key pair containing an embedded trailer which causes chat_downloader to assume an error, even though the status is simply LIVE_STREAM_OFFLINE.
"errorScreen": {
"ypcTrailerRenderer": {
"fullVideoMessage": {
"simpleText": "Trailer"
},
<embedded player response here>
...
Sure, I can fix that 👍 Do you have another example of a video I can test on?
Not that I know of, sadly.
In _get_initial_video_info(), I changed "if error_screen:" to also check for the playability status, and it seemed to fix the behavior and hasn't affected my other downloads. I think checking against LIVE_STREAM_OFFLINE may be the right move here, although I haven't done any comprehensive tests.
if not details['continuation_info']:
# Only raise an error if there is no continuation info. Sometimes you
# are able to view chat, but not the video (e.g. for very long livestreams)
playability_status = player_response_info.get(
'playabilityStatus') or {}
error_screen = playability_status.get('errorScreen')
if error_screen and playability_status.get('status') != 'LIVE_STREAM_OFFLINE': # There is a error screen visible
error_reasons = {
'reason': '',
'subreason': '',
}
This has been fixed in https://github.com/xenova/chat-downloader/commit/50b8ed2e32f098840b86ecb7c0518f9c101ba50f