ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
131.2k stars 9.93k forks source link

Build Issue after last commit #31324

Closed atvcaptain closed 1 year ago

atvcaptain commented 1 year ago

Checklist

Verbose log

|   File "/home/oe1/atv64/build-enviroment/builds/openatv/release/et10000/tmp/work/mips32el-oe-linux/python-youtube-dl/gitAUTOINC+087ddc2371-r0/git/youtube_dl/casefold.py", line 1642, in <lambda>
|     _parse_unichr = lambda s: compat_chr(int(s, 16))
| ValueError: unichr() arg not in range(0x10000) (narrow Python build)
|     _parse_unichr = lambda s: compat_chr(int(s, 16))
| ValueError: unichr() arg not in range(0x10000) (narrow Python build)
| make: *** [Makefile:100: youtube-dl.bash-completion] Error 1

Description

with commit https://github.com/ytdl-org/youtube-dl/commit/a874871801b8b05d06e8ffe52bed94fdfc26611e youtube-dl.bash-completion stop build

dirkf commented 1 year ago

I wonder which Python build you have.

This is probably happening because your Python is built without wide character support. I wondered if that would still be a problem and it appears that you have helpfully provided the answer. There is a known solution, though:

--- old/youtube_dl/casefold.py
+++ new/youtube_dl/casefold.py
@@ -1639,7 +1639,11 @@
 1E921; C; 1E943; # ADLAM CAPITAL LETTER SHA
 '''

-_parse_unichr = lambda s: compat_chr(int(s, 16))
+def _parse_unichr(s):
+    try:
+        return compat_chr(int(s, 16))
+    except ValueError:
+        return ('\\U' + ('0000000' + s)[-8:]).decode('unicode-escape')

 _map = dict(
     (_parse_unichr(from_), ''.join(map(_parse_unichr, to_.split(' '))))
atvcaptain commented 1 year ago

this is my legacy build python 2.7 i use openembedded build System zeus, my build with py3.9/3.10 and 3.11 have np thx for quick fix

dirkf commented 1 year ago

The original version worked on my embedded 2.7.1 Python that was built 10+ years ago, so I hoped to get away without a work-around!

Actually there doesn't seem to be any significant performance difference between these three as measured by running time python test/test_compat.py: