0

This is a continuation on my previous question:

How to create a youtube downloader gui with youtube-dl in batch

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

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?

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.

Mofi
  • 38,783
  • 14
  • 62
  • 115
Andly Kwan
  • 51
  • 7
  • 3
    `end` isn't a valid batch command; you're thinking of `exit`. Also, "crash" implies that your computer becomes unusable, which I seriously doubt. It's far more likely that the script aborts with an error for some reason. Run the script from the command line instead of double-clicking it. What is the error that you get? – SomethingDark Dec 21 '19 at 05:39
  • i was thinking C# hahaha oops! – Andly Kwan Dec 22 '19 at 10:06

1 Answers1

1

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

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

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

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.

Next is video

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

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

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).

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!

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

Andly Kwan
  • 51
  • 7