From 274dd5e6f25c4ebc804c41f96dd07d7f9c0fdcc9 Mon Sep 17 00:00:00 2001 From: Peter Volkov Date: Thu, 2 Apr 2020 10:47:51 +0300 Subject: [PATCH] [twitch] Strip title to avoid download error #24575 Since we create filename from title, it's very easy to get following error: ERROR: unable to open for writing: [Errno 36] File name too long: ... This commit strips title to 210 bytes so we'll fit into FS's 255 bytes filesize limit. --- youtube_dl/extractor/twitch.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/twitch.py b/youtube_dl/extractor/twitch.py index 0db2dca41..95538b661 100644 --- a/youtube_dl/extractor/twitch.py +++ b/youtube_dl/extractor/twitch.py @@ -180,6 +180,8 @@ class TwitchItemBaseIE(TwitchBaseIE): def _extract_info(self, info): status = info.get('status') + # avoid filesystem's 255 bytes limit on filelength + title = info.get('title', '').encode()[:210].decode(errors='ignore') if status == 'recording': is_live = True elif status == 'recorded': @@ -188,7 +190,7 @@ class TwitchItemBaseIE(TwitchBaseIE): is_live = None return { 'id': info['_id'], - 'title': info.get('title') or 'Untitled Broadcast', + 'title': title or 'Untitled Broadcast', 'description': info.get('description'), 'duration': int_or_none(info.get('length')), 'thumbnail': info.get('preview'),