gpt4 book ai didi

python - 通过命令行python批量上传视频到youtube

转载 作者:太空狗 更新时间:2023-10-29 20:25:15 32 4
gpt4 key购买 nike

我正在使用来自 youtube-upload 的脚本通过命令行将视频上传到我的 channel 。
如何运行代码来处理特定文件夹中的所有文件?
有一次我在网上看到一个例子,展示了如何使用相同的脚本将视频批量上传到 youtube,还从 csv excel 文件中获取标题、类别、描述和标签,每个都来自与另一个文件名对应的列柱子。我忘了保存这个例子,现在我似乎找不到它或自己创建它。

顺便说一句,我在windows 10环境下,使用命令行工具。

要上传单个视频,我正在使用这个脚本;

youtube-upload \
--title="A.S. Mutter"
--description="A.S. Mutter plays Beethoven" \
--category=Music \
--tags="mutter, beethoven" \
--recording-date="2011-03-10T15:32:17.0Z" \
--default-language="en" \
--default-audio-language="en" \
--client-secrets=client_secrets.json \
--credentials-file=client_secrets.json \
test.mp4

更新

csv 文件的列数与我在 youtube-upload 命令中的参数相同。比方说,只有title, description, category, tags 列,当然第一列是文件名,如果需要的话,我还会加上文件的位置。

最佳答案

:: == ASSUMPTIONS ==
:: - this script is in the same directory as your CSV file
:: - your CSV lines are in the following order:
:: file_name;title;description;category;tags;recording_date
:: - Your descriptions do not contain semicolons
@echo off

set video_folder="C:\path\to\your\video\folder"

:: If your videos and csv file are in the same directory, you don't need the pushd or popd
:: Also, I couldn't get line continuation to work inside of the for loop, so everything
:: MUST be all on the same line.
pushd %video_folder%
for /f "tokens=1-6 delims=;" %%A in (vids.csv) do (
youtube-upload --title="%%~B" --description="%%~C" --category="%%~D" --tags="%%~E" --recording-date="%%~F" --default-language="en" --default-audio-language="en" --client-secrets=client-secrets.json --credentials-file=client_secrets.json "%%~A"
)
popd
pause

关于python - 通过命令行python批量上传视频到youtube,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36962260/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com