Youtube-dl 无法读取批处理脚本中的各种设置
Youtube-dl cannot read various set on batch script
我创建了一个使用 youtube-dl 和 ffmpeg 定位的批处理脚本。我设置了好几组来放URL和Video/Audio ID。这是我简化的脚本
@echo off
cd /d %root%\YT
color 0a
title Youtube Downloader
setlocal enableDelayedExpansion
set q=^"
color 0a
:submenu
echo Please enter URL.
set /p f1="URL: "
echo Checking ID...
youtube-dl -F %f1%
ping localhost -n 2 >nul
goto menu
:menu
echo.
echo Script created by UrbaseR
echo ___________________________________________________________
echo.
echo MENU
echo ___________________________________________________________
echo OS Windows - %ComputerName%
echo.
echo M E N U
echo Press 1 to Download Best version
echo Press 2 to Download Custom version + convert
echo Press 3 to Exit
set /p you=">"
if %you%==1 goto 1
if %you%==2 goto 2
if %you%==3 goto 3
cls
echo *********************************
echo Sorry invalid number!
echo *********************************
ping localhost -n 2 >nul
goto menu
:1
echo Downloading...
youtube-dl -f best %f1%
echo.
echo Done
ping localhost -n 2 >nul
cls
goto submenu
:2
set /p id1="Insert Video ID: "
set /p id2="Insert Audio ID: "
echo Downloading Video..
youtube-dl -f %id1% -ciw -o "vid.%(ext)s" -v --write-sub %f1%
echo.
echo Video Done
ping localhost -n 2 >nul
echo Downloading Audio..
youtube-dl -f %id2% -ciw -o "aud.%(ext)s" -v %f1%
echo.
echo Audio Done
ping localhost -n 2 >nul
echo Converting Video
ffmpeg -i "vid.%(ext)s" -i "aud.%(ext)s" -c:v copy -c:a aac -strict experimental "input.mkv"
echo Converting Done
ping localhost -n 4 >nul
cls
goto submenu
:3
exit
第一个和第三个选项执行成功。第二个选项会出现这样的信息:
Usage: youtube-dl [OPTIONS] URL [URL...]
youtube-dl: error: You must provide at least one URL.
Type youtube-dl --help to see a list of all options.
注意:由于我卡在youtube-dl的第一阶段和第二阶段,ffmpeg可能无法运行(我还没有测试过)。
你能帮帮我吗?
重新修复脚本后大功告成。
@echo off
cd /d %root%\YT
color 0a
title Youtube Downloader
setlocal enableDelayedExpansion
set q=^"
color 0a
:submenu
echo Please enter URL.
set /p f1="URL: "
cls
echo Checking ID...
youtube-dl -F %f1%
ping localhost -n 2 >nul
goto menu
:menu
echo.
echo.
echo Script created by UrbaseR
echo ___________________________________________________________
echo.
echo MENU
echo ___________________________________________________________
echo OS Windows - %ComputerName%
echo.
echo M E N U
echo Press 1 to Download Best version (default ver)
echo Press 2 to Download Custom version + Convert
echo Press 3 to Exit
echo.
echo URL: %f1%
set /p you=">"
if %you%==1 goto 1
if %you%==2 goto 2
if %you%==3 goto 3
cls
echo *********************************
echo Sorry invalid number!
echo *********************************
ping localhost -n 2 >nul
goto menu
:1
echo Downloading...
youtube-dl -f best %f1%
echo.
echo Done
ping localhost -n 2 >nul
cls
goto submenu
:2
set /p id1="Insert Video ID: "
set /p id2="Insert Audio ID: "
set ida="v.data"
set idb="a.data"
set "f2="
set "f3="
cls
echo Downloading Video..
youtube-dl -f %id1% -ciw --o %ida% -v --write-sub %f1%
echo.
echo Video Done
ping localhost -n 2 >nul
cls
echo Downloading Audio..
youtube-dl -f %id2% -ciw -o %idb% -v %f1%
echo.
echo Audio Done
ping localhost -n 2 >nul
cls
echo Note Default title is: input.mkv
echo.
set /p f2="Enter Video Title: "
if not defined f2 set "f2=input"
set /p f3="Format Video: "
if not defined f3 set "f3=mkv"
echo Converting Video..
ffmpeg -i %ida% -i %idb% -c:v copy -c:a aac -strict experimental "%f2%.%f3%"
echo Converting Done
del /q %ida%
del /q %idb%
ping localhost -n 4 >nul
cls
goto submenu
:3
exit
请随意使用该脚本。
注意:请务必将 youtube-dl.exe 和 ffmpeg.exe 放在同一文件夹中,视频也会保存在同一文件夹中。
我创建了一个使用 youtube-dl 和 ffmpeg 定位的批处理脚本。我设置了好几组来放URL和Video/Audio ID。这是我简化的脚本
@echo off
cd /d %root%\YT
color 0a
title Youtube Downloader
setlocal enableDelayedExpansion
set q=^"
color 0a
:submenu
echo Please enter URL.
set /p f1="URL: "
echo Checking ID...
youtube-dl -F %f1%
ping localhost -n 2 >nul
goto menu
:menu
echo.
echo Script created by UrbaseR
echo ___________________________________________________________
echo.
echo MENU
echo ___________________________________________________________
echo OS Windows - %ComputerName%
echo.
echo M E N U
echo Press 1 to Download Best version
echo Press 2 to Download Custom version + convert
echo Press 3 to Exit
set /p you=">"
if %you%==1 goto 1
if %you%==2 goto 2
if %you%==3 goto 3
cls
echo *********************************
echo Sorry invalid number!
echo *********************************
ping localhost -n 2 >nul
goto menu
:1
echo Downloading...
youtube-dl -f best %f1%
echo.
echo Done
ping localhost -n 2 >nul
cls
goto submenu
:2
set /p id1="Insert Video ID: "
set /p id2="Insert Audio ID: "
echo Downloading Video..
youtube-dl -f %id1% -ciw -o "vid.%(ext)s" -v --write-sub %f1%
echo.
echo Video Done
ping localhost -n 2 >nul
echo Downloading Audio..
youtube-dl -f %id2% -ciw -o "aud.%(ext)s" -v %f1%
echo.
echo Audio Done
ping localhost -n 2 >nul
echo Converting Video
ffmpeg -i "vid.%(ext)s" -i "aud.%(ext)s" -c:v copy -c:a aac -strict experimental "input.mkv"
echo Converting Done
ping localhost -n 4 >nul
cls
goto submenu
:3
exit
第一个和第三个选项执行成功。第二个选项会出现这样的信息:
Usage: youtube-dl [OPTIONS] URL [URL...] youtube-dl: error: You must provide at least one URL.
Type youtube-dl --help to see a list of all options.
注意:由于我卡在youtube-dl的第一阶段和第二阶段,ffmpeg可能无法运行(我还没有测试过)。
你能帮帮我吗?
重新修复脚本后大功告成。
@echo off
cd /d %root%\YT
color 0a
title Youtube Downloader
setlocal enableDelayedExpansion
set q=^"
color 0a
:submenu
echo Please enter URL.
set /p f1="URL: "
cls
echo Checking ID...
youtube-dl -F %f1%
ping localhost -n 2 >nul
goto menu
:menu
echo.
echo.
echo Script created by UrbaseR
echo ___________________________________________________________
echo.
echo MENU
echo ___________________________________________________________
echo OS Windows - %ComputerName%
echo.
echo M E N U
echo Press 1 to Download Best version (default ver)
echo Press 2 to Download Custom version + Convert
echo Press 3 to Exit
echo.
echo URL: %f1%
set /p you=">"
if %you%==1 goto 1
if %you%==2 goto 2
if %you%==3 goto 3
cls
echo *********************************
echo Sorry invalid number!
echo *********************************
ping localhost -n 2 >nul
goto menu
:1
echo Downloading...
youtube-dl -f best %f1%
echo.
echo Done
ping localhost -n 2 >nul
cls
goto submenu
:2
set /p id1="Insert Video ID: "
set /p id2="Insert Audio ID: "
set ida="v.data"
set idb="a.data"
set "f2="
set "f3="
cls
echo Downloading Video..
youtube-dl -f %id1% -ciw --o %ida% -v --write-sub %f1%
echo.
echo Video Done
ping localhost -n 2 >nul
cls
echo Downloading Audio..
youtube-dl -f %id2% -ciw -o %idb% -v %f1%
echo.
echo Audio Done
ping localhost -n 2 >nul
cls
echo Note Default title is: input.mkv
echo.
set /p f2="Enter Video Title: "
if not defined f2 set "f2=input"
set /p f3="Format Video: "
if not defined f3 set "f3=mkv"
echo Converting Video..
ffmpeg -i %ida% -i %idb% -c:v copy -c:a aac -strict experimental "%f2%.%f3%"
echo Converting Done
del /q %ida%
del /q %idb%
ping localhost -n 4 >nul
cls
goto submenu
:3
exit
请随意使用该脚本。
注意:请务必将 youtube-dl.exe 和 ffmpeg.exe 放在同一文件夹中,视频也会保存在同一文件夹中。