blackjack4494 / youtube-dlc

Command-line program to download various media from YouTube.com and other sites
https://blackjack4494.github.io/youtube-dlc/
The Unlicense
1.22k stars 13 forks source link

--trim-file-name is inconsistent, doesn't work sometimes #213

Open TomArrow opened 3 years ago

TomArrow commented 3 years ago

Checklist

Verbose log

$ youtube-dlc https://twitter.com/IamProvocateur_/status/1340117594938982400 -v
[debug] System config: []
[debug] User config: ['--embed-thumbnail', '--add-metadata', '--ignore-errors', '--write-description', '--write-info-json', '--write-annotations', '--embed-subs', '--include-ads', '--write-thumbnail', '--write-all-thumbnails', '--write-sub', '--write-auto-sub', '--all-subs', '--download-archive', '____youtubeDLdownloaded.txt', '--cookies', 'youtube.txt', '--trim-file-name', '40']
[debug] Custom config: []
[debug] Command-line args: ['https://twitter.com/IamProvocateur_/status/1340117594938982400', '-v']
[debug] Loading archive file '____youtubeDLdownloaded.txt'
[debug] Encodings: locale cp1252, fs utf-8, out cp1252, pref cp1252
[debug] youtube-dlc version 2020.10.09
[debug] Python version 3.8.6 (CPython) - Windows-7-6.1.7601-SP1
[debug] exe versions: ffmpeg 4.2.3, ffprobe git-2019-11-09-0f89a22
[debug] Proxy map: {}
[twitter] 1340117594938982400: Downloading guest token
[twitter] 1340117594938982400: Downloading JSON metadata
[twitter] 1340117594938982400: Downloading m3u8 information
[debug] Default format spec: bestvideo+bestaudio/best
[info] Writing video description to: Bah Humdrea - The small details in sound. Somebody put a broke running toilet in this room lol #Cyberpunk2077 #PS4share-1340117594938982400.description
WARNING: There are no annotations to write.
[info] Writing video description metadata as JSON to: Bah Humdrea - The small details in sound. Somebody put a broke running toilet in this room lol #Cyberpunk2077 #PS4share-1340117594938982400.info.json
ERROR: Cannot write metadata to JSON file Bah Humdrea - The small details in sound. Somebody put a broke running toilet in this room lol #Cyberpunk2077 #PS4share-1340117594938982400.info.json
Traceback (most recent call last):
  File "youtube_dlc\YoutubeDL.py", line 1931, in process_info
  File "youtube_dlc\utils.py", line 1828, in write_json_file
  File "tempfile.py", line 540, in NamedTemporaryFile
  File "tempfile.py", line 250, in _mkstemp_inner
FileNotFoundError: [Errno 2] No such file or directory: 'Bah Humdrea - The small details in sound. Somebody put a broke running toilet in this room lol #Cyberpunk2077 #PS4share-1340117594938982400.info.json.07n6ael_.tmp'
--

Description

Example URLs: https://twitter.com/leo777_j/status/1340318185959133185 https://twitter.com/News_Sense1/status/1340619358440046592 https://twitter.com/IamProvocateur_/status/1340117594938982400

For most URLs, the --trim-file-name flag seems to be helpful and solve the issue of Windows not being able to write the file. Unfortunately, in some rare cases, it still doesn't work. The three links above for example are not happy with --trim-file-name 50 for me, they require going down to 40 or 30. As you can see, the filename it is trying to write is also clearly longer than 50, it's 139 characters, with the video title part being 105 characters.

So I'm thinking there's some kind of inconsistency there.

pukkandan commented 3 years ago

This repo is no longer in development. Please use https://github.com/blackjack4494/yt-dlc instead