For STDOUT encoding detection errors, None is returned, which causes an error: "Argument 1 must be str, not none"
See original GitHub issueChecklist
- I’m reporting a bug unrelated to a specific site
- I’ve verified that I’m running yt-dlp version 2022.02.04. (update instructions)
- I’ve checked that all provided URLs are alive and playable in a browser
- I’ve checked that all URLs and arguments with special characters are properly quoted or escaped
- I’ve searched the bugtracker for similar issues including closed ones. DO NOT post duplicates
- I’ve read the guidelines for opening an issue
Description
Hello, the error occurs in the line “text = text.encode (encoding, ‘ignore’).decode(encoding)” of the “_format_text” function, because when determining the STDOUT encoding, there are cases of None type return (“Encoding [debugging]: cp1251 language, fs utf-8, out None, err None, prefix cp1251”). It would be good to define defaults in case of such errors.
Temporarily solved the problem using the following parameters: ‘no_color’: ‘True’, # Do not edit the color codes in the output ‘encoding’: ‘utf-8’, # BUG FIXED: [0 encode() argument 1 should be str, not No] (experimental)
Verbose log
2022-02-09 15:46:43.800 TYoutubeDl yt-dlp stack: .................SYS PLATFORM: win32
2022-02-09 15:46:43.806 TYoutubeDl yt-dlp stack: ...............PYTHON VERSION: 3.7.8 (tags/v3.7.8:4b47a5b6ba, Jun 28 2020, 07:55:33) [MSC v.1916 32 bit (Intel)]
2022-02-09 15:46:43.812 TYoutubeDl yt-dlp stack: .....................CORE DIR: C:\Program Files (x86)\APP\Client\mod_a4ea4b5a\yt-dlp\
2022-02-09 15:46:43.817 TYoutubeDl yt-dlp stack: ....................CORE FILE: yt-dlp
2022-02-09 15:46:43.823 TYoutubeDl yt-dlp stack: ..................CORE MODULE: yt_dlp
2022-02-09 15:46:43.829 TYoutubeDl yt-dlp stack: ...............DYNAMIC IMPORT: True
2022-02-09 15:46:43.835 TYoutubeDl yt-dlp stack: .........FULL PATH TO PACKAGE: C:\Program Files (x86)\APP\Client\mod_a4ea4b5a\yt-dlp\yt-dlp
2022-02-09 15:46:43.840 TYoutubeDl yt-dlp stack: ...................CLIENT DIR: C:\Program Files (x86)\APP\Client\mod_a4ea4b5a
2022-02-09 15:46:43.846 TYoutubeDl yt-dlp stack: .............CURRENT WORK DIR: C:\Program Files (x86)\APP\Client\mod_a4ea4b5a
2022-02-09 15:46:43.851 TYoutubeDl yt-dlp stack: ..................INTERPRETER: C:\Program Files (x86)\APP\Client\mod_a4ea4b5a\APP-client.exe
2022-02-09 15:46:43.857 TYoutubeDl yt-dlp stack: ...............LANG | COUNTRY: Russian | Russia
2022-02-09 15:46:43.863 TYoutubeDl yt-dlp stack: .................ACP | OEM CP: 1251 | 866
2022-02-09 15:46:43.868 TYoutubeDl yt-dlp stack: ...................DEF LOCALE: ('ru_RU', 'cp1251')
2022-02-09 15:46:43.874 TYoutubeDl yt-dlp stack: ..................TIME FORMAT: H:mm:ss
2022-02-09 15:46:43.879 TYoutubeDl yt-dlp stack: DECIMAL POINT | THOUSANDS SEP: "." | ""
2022-02-09 15:46:43.885 TYoutubeDl yt-dlp stack: >> True and True and True - "yt_dlp" And "yt_dlp.YoutubeDL" And "yt_dlp.version" in sys.modules?
2022-02-09 15:46:43.890 TYoutubeDl yt-dlp stack: PYTHON. Dynamic Import Module From File: C:\Program Files (x86)\APP\Client\mod_a4ea4b5a\yt-dlp\yt-dlp
2022-02-09 15:46:43.896 TYoutubeDl yt-dlp stack: PYTHON. Import Done: <module 'yt_dlp' from 'C:\\Program Files (x86)\\APP\\Client\\mod_a4ea4b5a\\yt-dlp\\yt-dlp\\yt_dlp\\__init__.py'>
2022-02-09 15:46:43.901 TYoutubeDl yt-dlp stack: >> True and True and True - "yt_dlp" And "yt_dlp.YoutubeDL" And "yt_dlp.version" in sys.modules?
2022-02-09 15:46:43.906 TYoutubeDl yt-dlp stack: ..................PYTHON DIRS: ['C:\\Program Files (x86)\\APP\\Client\\mod_a4ea4b5a', 'C:\\Program Files (x86)\\APP\\Client\\mod_a4ea4b5a\\yt-dlp\\yt-dlp', 'C:\\Program Files (x86)\\APP\\Client\\mod_a4ea4b5a\\pylibs\\python37.zip', 'C:\\Program Files (x86)\
2022-02-09 15:46:43.912 TYoutubeDl yt-dlp stack: \APP\\Client\\mod_a4ea4b5a\\pylibs\\DLLs', 'C:\\Program Files (x86)\\APP\\Client\\mod_a4ea4b5a\\pylibs\\lib', 'C:\\Program Files (x86)\\APP\\Client\\mod_a4ea4b5a', 'C:\\Users\\Ra10Bit-PC\\AppData\\Roaming\\Python\\Python37\\site-packages', 'C:\\Program Files
2022-02-09 15:46:43.917 TYoutubeDl yt-dlp stack: (x86)\\APP\\Client\\mod_a4ea4b5a\\pylibs']
2022-02-09 15:46:43.923 TYoutubeDl yt-dlp stack: ===CLASS APPDownload ENTER====
2022-02-09 15:46:43.930 TYoutubeDl yt-dlp stack: .............CURRENT WORK DIR: C:\Program Files (x86)\APP\Client\mod_a4ea4b5a
2022-02-09 15:46:47.364 TYoutubeDl yt-dlp stack: web_request: Get data failed: Timeout
2022-02-09 15:46:47.369 TYoutubeDl yt-dlp stack: INFO: get_url_domain (offline parser) -> "tiktok.com"
2022-02-09 15:46:47.375 TYoutubeDl yt-dlp stack: INFO: fill_auth_data -> Url domain "tiktok.com"
2022-02-09 15:46:47.381 TYoutubeDl yt-dlp stack: INFO: fill_auth_data -> Authorization data for "tiktok.com" not found in cache "C:\Users\Ra10Bit-PC\AppData\Roaming\APP\Data\cache". SKIPPED
2022-02-09 15:46:47.387 TYoutubeDl yt-dlp stack: ...............INFO FILE DIR: C:\Users\Ra10Bit-PC\AppData\Roaming\APP\Data\
2022-02-09 15:46:47.392 TYoutubeDl yt-dlp stack: ..............INFO FILE NAME: TaskInfo.info.json
2022-02-09 15:46:47.398 TYoutubeDl yt-dlp stack: ..............yt_dlp OPTIONS: {'verbose': 'True', 'logger': <__main__.APPDownload.getInfo.<locals>.ExtractInfoLogger object at 0x0C51B6B0>, 'writeinfojson': 'True', 'writethumbnail': 'True', 'ignoreerrors': 'True', 'restrictfilenames': 'True', 'noplaylist'
2022-02-09 15:46:47.404 TYoutubeDl yt-dlp stack: : 'True', 'nocheckcertificate': 'True', 'geo_bypass': 'True', 'check_formats': 'False', 'windowsfilenames': 'True'}
2022-02-09 15:46:47.779 TYoutubeDl yt-dlp stack: DEBUG: [debug] Encodings: locale cp1251, fs utf-8, out None, err None, pref cp1251
2022-02-09 15:46:47.785 TYoutubeDl yt-dlp stack: DEBUG: [debug] yt-dlp version 2022.02.04 [c1653e9ef] (zip)
2022-02-09 15:46:47.791 TYoutubeDl yt-dlp stack: DEBUG: [debug] Lazy loading extractors is forcibly disabled
2022-02-09 15:46:47.797 TYoutubeDl yt-dlp stack: DEBUG: [debug] Python version 3.7.8 (CPython 32bit) - Windows-10-10.0.19041-SP0
2022-02-09 15:46:48.857 TYoutubeDl yt-dlp stack: DEBUG: [debug] exe versions: avconv present, avprobe present, ffmpeg present (needs_adtstoasc), ffprobe present, phantomjs ., rtmpdump present
2022-02-09 15:46:48.863 TYoutubeDl yt-dlp stack: DEBUG: [debug] Optional libraries: sqlite
2022-02-09 15:46:48.870 TYoutubeDl yt-dlp stack: DEBUG: [debug] Proxy map: {}
2022-02-09 15:46:48.878 TYoutubeDl yt-dlp stack: DEBUG: Removing cache dir C:\Users\Ra10Bit-PC/.cache\yt-dlp .
2022-02-09 15:46:48.883 TYoutubeDl yt-dlp stack: DEBUG: .
2022-02-09 15:46:49.715 TYoutubeDl yt-dlp stack: DEBUG: [debug] [TikTok] Extracting URL: https://www.tiktok.com/@valeriyabearwolf/video/6998135551887002881
2022-02-09 15:46:49.721 TYoutubeDl yt-dlp stack: DEBUG: [TikTok] 6998135551887002881: Downloading video details
2022-02-09 15:46:50.246 TYoutubeDl yt-dlp stack: DEBUG: [debug] Sort order given by extractor: quality, codec, size, br
2022-02-09 15:46:50.252 TYoutubeDl yt-dlp stack: DEBUG: [debug] Formats sorted by: hasvid, ie_pref, quality, vcodec, acodec, filesize, fs_approx, tbr, vbr, abr, lang, res, fps, hdr:12(7), asr, proto, vext, aext, hasaud, source, id
2022-02-09 15:46:50.272 TYoutubeDl yt-dlp stack: ERR: [0;31mErr:[0m encode() argument 1 must be str, not none
2022-02-09 15:46:50.278 TYoutubeDl yt-dlp stack: ERR: traceback (most recent call last):
2022-02-09 15:46:50.284 TYoutubeDl yt-dlp stack: file "c:\program files (x86)\APP\client\mod_a4ea4b5a\yt-dlp\yt-dlp\yt_dlp\youtubedl.py", line 1381, in wrapper
2022-02-09 15:46:50.290 TYoutubeDl yt-dlp stack: return func(self, *args, **kwargs)
2022-02-09 15:46:50.295 TYoutubeDl yt-dlp stack: file "c:\program files (x86)\APP\client\mod_a4ea4b5a\yt-dlp\yt-dlp\yt_dlp\youtubedl.py", line 1465, in __extract_info
2022-02-09 15:46:50.301 TYoutubeDl yt-dlp stack: return self.process_ie_result(ie_result, download, extra_info)
2022-02-09 15:46:50.306 TYoutubeDl yt-dlp stack: file "c:\program files (x86)\APP\client\mod_a4ea4b5a\yt-dlp\yt-dlp\yt_dlp\youtubedl.py", line 1517, in process_ie_result
2022-02-09 15:46:50.312 TYoutubeDl yt-dlp stack: ie_result = self.process_video_result(ie_result, download=download)
2022-02-09 15:46:50.318 TYoutubeDl yt-dlp stack: file "c:\program files (x86)\APP\client\mod_a4ea4b5a\yt-dlp\yt-dlp\yt_dlp\youtubedl.py", line 2516, in process_video_result
2022-02-09 15:46:50.323 TYoutubeDl yt-dlp stack: info_dict, _ = self.pre_process(info_dict)
2022-02-09 15:46:50.329 TYoutubeDl yt-dlp stack: file "c:\program files (x86)\APP\client\mod_a4ea4b5a\yt-dlp\yt-dlp\yt_dlp\youtubedl.py", line 3329, in pre_process
2022-02-09 15:46:50.335 TYoutubeDl yt-dlp stack: info = self.run_all_pps(key, info)
2022-02-09 15:46:50.340 TYoutubeDl yt-dlp stack: file "c:\program files (x86)\APP\client\mod_a4ea4b5a\yt-dlp\yt-dlp\yt_dlp\youtubedl.py", line 3321, in run_all_pps
2022-02-09 15:46:50.346 TYoutubeDl yt-dlp stack: self._forceprint(key, info)
2022-02-09 15:46:50.352 TYoutubeDl yt-dlp stack: file "c:\program files (x86)\APP\client\mod_a4ea4b5a\yt-dlp\yt-dlp\yt_dlp\youtubedl.py", line 2704, in _forceprint
2022-02-09 15:46:50.357 TYoutubeDl yt-dlp stack: info_copy['formats_table'] = self.render_formats_table(info_dict)
2022-02-09 15:46:50.363 TYoutubeDl yt-dlp stack: file "c:\program files (x86)\APP\client\mod_a4ea4b5a\yt-dlp\yt-dlp\yt_dlp\youtubedl.py", line 3477, in render_formats_table
2022-02-09 15:46:50.368 TYoutubeDl yt-dlp stack: delim = self._format_screen('\u2502', self.styles.delim, '|', test_encoding=true)
2022-02-09 15:46:50.374 TYoutubeDl yt-dlp stack: file "c:\program files (x86)\APP\client\mod_a4ea4b5a\yt-dlp\yt-dlp\yt_dlp\youtubedl.py", line 901, in _format_screen
2022-02-09 15:46:50.379 TYoutubeDl yt-dlp stack: self._screen_file, self._allow_colors['screen'], *args, **kwargs)
2022-02-09 15:46:50.385 TYoutubeDl yt-dlp stack: file "c:\program files (x86)\APP\client\mod_a4ea4b5a\yt-dlp\yt-dlp\yt_dlp\youtubedl.py", line 892, in _format_text
2022-02-09 15:46:50.390 TYoutubeDl yt-dlp stack: text = text.encode(encoding, 'ignore').decode(encoding)
2022-02-09 15:46:50.396 TYoutubeDl yt-dlp stack: typeErr: encode() argument 1 must be str, not none
2022-02-09 15:46:50.402 TYoutubeDl yt-dlp stack:
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Python 3 TypeError: must be str, not bytes with sys.stdout.write()
In Python 2 implicitly assuming an encoding could cause a lot of problems; you could end up using the wrong encoding, or the...
Read more >rpl error "TypeError: encode() argument 1 must be str, not None"
locale library isn't able to find the default locale and hence failing. The issue can be fixed by setting the LANG environment variable...
Read more >Error installing packages to conda environment within ...
Hello, TypeError: LoadLibrary() argument 1 must be str, not None. I receive the above error code anytime I try to install a package...
Read more >codecs — Codec registry and base classes — Python 3.11.1 ...
The default error handler is 'strict' meaning that encoding errors raise ... In case a search function cannot find a given encoding, it...
Read more >IO tools (text, CSV, HDF5, …) — pandas 1.5.2 documentation
One -character string used to escape delimiter when quoting is QUOTE_NONE . commentstr, default None. Indicates remainder of line should not be parsed....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
yt-dlp normally detects the console’s supported encoding. The issue here is caused because python cannot detect it when being called from delphi (or other hooks?). So ascii is the “safe” fallback
I have fixed the error. But for maximum compat, yt-dlp falls back to ascii, not utf-8 in these cases. So if you know that you can handle utf-8, it is recommended to explicitly set the encoding