如何使用带有批处理文件的youtube-dl下载MP3? [英] How to download MP3 using youtube-dl with a batch file?

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

问题描述

这是我上一个问题的延续:

This is a continuation on my previous question:

如何创建youtube批量下载带有youtube-dl的gui

我发现了视频的下载方式,这意味着我可以使用记事本以某种方式输入命令行.这是我当前的代码:

I have found out how the downloading of the video works, which means I could somehow enter the command line using Notepad. Here is my current code:

cls
@echo off
title youtube downloader

:downloader
echo youtuber downloader!!!
pause
cls
set "site="
set /p "site=Please enter youtube link here> "
If Not Defined site cls & goto downloader
echo Do you want to download "%site%" as mp3?
pause
set /p choice=
if %choice%== yes goto mp3
if %choice%== no goto mp4
s
:mp4
@echo off
cls
C:\Users\Andly\Documents\youtube-dl.exe %site%
echo ok
end

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

我需要MP3音频格式的帮助,而且我知道我能够使用该应用程序访问命令行.但是,当我选择以MP3格式下载时,它只会崩溃.

I need help with the audio format in MP3, and I know I'm able to access command line with the app. However, when I choose to download as MP3, it just crashes.

有人知道为什么会这样吗?

Does anyone know why this happens?

我的youtube-dl文件也位于C:\Users\Username\Document\youtube-dl-中(我使用C:\Users\Username\Document\youtube-dl.exe),但是当我在mp4中尝试该文件时它仍然可以工作,是的,我已经尝试了C:\Users\Username\Document\youtube-dl\youtube-dl.

Also my youtube-dl file is in C:\Users\Username\Document\youtube-dl-(I use C:\Users\Username\Document\youtube-dl.exe), but it still works when I tried it in mp4, and yes I have tried C:\Users\Username\Document\youtube-dl\youtube-dl.

推荐答案

好! 我希望它是完整的! 因此,在其他项目(例如我的白痴测试游戏)的帮助下,我创建"了代码;不重要.

ALRIGHT! It is complete, i hope! So, the code i "created" with help from other projects like my idiot test game; not important.

所以,这是我用来从youtube下载mp3视频的代码.

So, this is the code I made for downloading mp3 videos off youtube.

cls
@echo off
title youtube downloader

:downloader
echo youtuber downloader!!!
pause
set "site="
set /p "site=Please enter youtube link here> "
If Not Defined site cls & goto downloader
echo Do you want to download "%site%" as an audio file?
pause
set /p choice=
if %choice%== "yes" goto audio
if %choice%== "no" goto video


:audio
@echo off
echo lol ok
C:\Users\NAME\Documents\youtube-dl\youtube-dl.exe %site% -x --audio-format best --ffmpeg-location C:\Users\NAME\Documents\youtube-dl\ffmeg\bin
exit

:video
@echo off
C:\Users\NAME\Documents\youtube-dl.exe %site%
exit

这是它的工作方式: 首先,使用批处理文件启动下载程序.这些文件首先询问他们要下载该站点的哪个视频.使用set "site="命令.然后询问是否要下载此音频文件,这是我下载最多的文件.因此,它将获取链接,然后转到音频或视频.然后,它将使用命令+视频链接.

So this is how it works: First, the downloader is started using the batch file. The files first asks what video of the site they want to download. Using the set "site=" command. Then I ask if I want to download this is as an audio file, which is what I download the most. So, it takes the link, and goes to either audio or video. Then, it will use the command + the video link.

C:\Users\NAME\Documents\youtube-dl\youtube-dl.exe %site% -x --audio-format best --ffmpeg-location C:\Users\NAME\Documents\youtube-dl\ffmeg\bin

基本上采用youtube-dl.exe,并告诉它使用现有的最佳音频格式下载网站,然后将其链接到ffmpeg位置,该位置位于我的youtube-dl文件夹中,我必须将其链接到二进制文件夹或"bin". Ffmpeg是可以帮助更改视频和音频文件类型的工具. ffmpeg的替代方法是avconv.

basically takes the youtube-dl.exe and tells it to download the site, using the best audio format available, then links it to the ffmpeg location, which is in my youtube-dl folder, which I will have to link to the binary folder, or "bin". Ffmpeg is a tool that can help change the file types for videos and audios. An alternative to ffmpeg is avconv.

接下来是视频

C:\Users\NAME\Documents\youtube-dl.exe %site%

youtube-dl无需任何工具即可自动下载为视频,因此,如果您只打算下载mp4,请使用以下命令:

youtube-dl automatically downloads as video without any tool, so if you intend only to download mp4, just use this:

@echo off
title youtube downloader
    :downloader
    echo youtuber downloader!!!
    pause
    set "site="
    set /p "site=Please enter youtube link here> "
    If Not Defined site cls & goto downloader
    echo Downloading %site% ...
    C:\Users\NAME\Documents\youtube-dl.exe %site%
    exit

视频将下载到批处理文件文件夹中,因此我将批处理文件放入桌面的文件夹中,并将文件隐藏起来,这样看起来就不会那么混乱了.然后,将批处理放到我的开始窗口中(在Windows中).

The video will download in the batch file folder, so I would put the batch in a folder in desktop, and make the file hidden so it would look less disordered. Then I'd put the batch in my start(in windows).

对不起,但最后它将打开youtube-dl文件夹(对不起)

Sorry, but in the end, it will open the youtube-dl folder(sorry)

我不是一批专业人士,我从未参加过任何课程,但是我希望您从我的迷你项目中学到了一些东西!

I am not a pro at batch, I have never took any courses, but I hope you learned something from my mini project!

推荐人: 我的旧项目 youtube-dl的文档链接 我的电脑 YouTube 我的孩子梦想成为一名黑客(进展不顺利)

Refrences: my old projects youtube-dl's documentation link my computer youtube my kid dream to be a hacker(it's not going well)

这篇关于如何使用带有批处理文件的youtube-dl下载MP3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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