如何批量创建带有youtube-dl的youtube下载程序gui [英] How to create a youtube downloader gui with youtube-dl in batch

查看:203
本文介绍了如何批量创建带有youtube-dl的youtube下载程序gui的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以这是我目前所在的位置:

So here's where I am at currently:

cls
@echo off
title youtube downloader
:downloader
echo youtuber downloader!!!
pause
cls
echo please put the link:
set /p site=
echo Do you want to download %site% as mp3?
set /p choice
if %choice%== yes goto mp3
if %choice%== no goto mp4

:mp4
@echo off
cls
C:\Users\Andly\Documents\youtube-dl.exe %site%
echo ok
pause
end

:mp3
@echo off
cls
C:\Users\Andly\Documents\youtube-dl %site% --audio-format mp3
echo lol ok
pause
end

我很确定我可以在

echo please put the link:
set /p site=

^^^ 但是,当我放置一个网站时,它崩溃了!

^^^ However, it crashes right when I put a site!

有人知道我在做什么错吗?

Does anyone know what I am doing wrong?

推荐答案

输入链接中包含潜在有害字符的大多数问题都可以通过将输入内容括在双引号中来解决,正如我已经评论过的 .除此之外,在特殊情况下还需要考虑以下事实:在批处理文件中,任何%字符都需要加倍!

The majority of issues with potential poison characters in your input links, can be fixed by enclosing that input in doublequotes, as I already commented upon. Aside from that, a special case needs to account for the fact that in a batch file any % characters need to be doubled!

下面是一个简单的示例,该文件应解决包含毒字字符的链接所预期的大多数问题:

What follows is a simple example batch-file which should account for most of the issues anticipated with links containing poison characters:

@Echo Off
Title YouTube Downloader
SetLocal DisableDelayedExpansion
Echo YouTube Downloader!!!

:AskURI
Set "URI="
Set /P "URI=Please enter your YouTube link here>"
If Not Defined URI ClS & GoTo AskURI
Choice /M "Do you want to download as MP3"
If "%ErrorLevel%" == "1" (Call :GetDownload --audio-format mp3)Else Call :GetDownload
Echo Done
Pause
GoTo :EOF

:GetDownload
SetLocal EnableDelayedExpansion
"%UserProfile%\Documents\youtube-dl.exe" "!URI:%%=%%%%!" %*
Exit /B

如上面的示例使用choice.exe而不是不太可靠的Set /P方法,它绕过了代码中的一个问题,该问题使用了set /p choice而不是set /p choice=

As the example above uses choice.exe instead of the less robust, Set /P method, it bypasses an issue in your code, which used set /p choice instead of set /p choice=

这篇关于如何批量创建带有youtube-dl的youtube下载程序gui的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆