Youtube-dl无法读取批处理脚本上的各种设置

我创建了一个批处理脚本,该脚本与youtube-dl和ffmpeg一起放置。我设置了几个设置来放置URL和视频/音频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

第一个和第三个选项成功执行。第二个选项将显示如下消息:

  

用法:youtube-dl [OPTIONS] URL [URL ...]   youtube-dl:错误:您必须提供至少一个网址。

     

输入youtube-dl --help以查看所有选项的列表。

注意:由于我停留在youtube-dl的第一阶段和第二阶段,ffmpeg可能无法正常工作(我尚未对其进行测试)。

你能帮我吗?

twlwen 回答:Youtube-dl无法读取批处理脚本上的各种设置

重新修复后,脚本已完成。

@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位于同一文件夹中,视频也将保存在同一文件夹中。

本文链接:https://www.f2er.com/3096634.html

大家都在问