Это мой текущий шаблон вывода:
-o "A: / YouTube /% (загрузчик) s /% (upload_date) s /% (title) s -% (id) s.% (Ext) s"
Но вместо% (upload_date) ) s, отформатированный как ГГГГММДД Я хочу, чтобы имя папки было указано только после года загрузки. Я не могу понять, как это работает, пожалуйста, помогите мне!
youtube-dl doesn't have an year option (except for music videos, where it is %(release_year)s
).
so what we can do instead is let youtube-dl save the files with YYYYMMDD, and we can modify it later:
import os
YOUTUBE_DIR = "/path/to/youtube/videos"
uploaders = os.path.listdir(YOUTUBE_DIR)
for uploader in uploaders:
videofile = os.path.listdir(os.path.join(YOUTUBE_DIR, uploader))
yyyy = videofile[:4]
newname = yyyy + videofile[8:]
print("old path is: ", os.path.join(YOUTUBE_DIR, uploader, videofile))
print("new path is: ", os.path.join(YOUTUBE_DIR, uploader, newname))
# first run the script as-is, and if you're okay with the new names, uncomment the next line and run again to actually rename the files
#os.rename(os.path.join(YOUTUBE_DIR, uploader, videofile), os.path.join(YOUTUBE_DIR, uploader, newname))