Skip to main content
Topic: Youtube Downloader (Read 1120 times) previous topic - next topic

Youtube Downloader

Download Youtube content like it's nobody's business
With Youtube-DL https://ytdl-org.github.io/youtube-dl/index.html

youtube-dl is a command-line program to download videos from YouTube.com and a few more sites. It requires the Python interpreter (2.6, 2.7, or 3.2+), and it is not platform specific. We also provide a Windows executable that includes Python. youtube-dl should work in your Unix box, in Windows or in Mac OS X. It is released to the public domain, which means you can modify it, redistribute it or use it however you like.



I know I know there's a lot of plugins and other applications that do this already I knooooow but this is CLI which means you look like the guy from hackerman when you download a youtube vid.
In short this downloads webm content from a youtube url and converts it to mp4, other formats are available.
Another thing it does is convert to mp3, so you can supplement your sweet music library with youtube-goodies.

The actual interesting thing about this tool is that you can use it in scripts or other homemade software.
It's also possible to customize the filename the output, things like that.

Examples:
Convert to mp4:
Code: [Select]
youtube-dl https://www.youtube.com/watch?v=9gHn3JInKlc
Convert to mp3:
Code: [Select]
youtube-dl --extract-audio --audio-format mp3 --audio-quality 0 https://www.youtube.com/watch?v=XYjnWtXbbCg



/Download-Install\
https://yt-dl.org/downloads/2019.09.28/youtube-dl
More information on how to download and install this tool: https://ytdl-org.github.io/youtube-dl/download.html
There are also version available in default repos but in my experience these tend to be out of date.
The problem with out of date versions is that not all youtube link will work.



Existing forum posts related to youtube-dl, must read:
https://weboas.is/forum/index.php?topic=660
https://weboas.is/forum/index.php?topic=426



Re: Youtube Downloader

Reply #3
Another variation of the bot. This one emails the downloaded media to a specific email address.
https://pastebin.com/gzCbBQrH


Re: Youtube Downloader

Reply #4
C++ Example


https://mega.nz/file/zZJA3SYC#UxnpdmLOFye9cJ433VI1p-gDAoo96xZjg1G6EJCCuOg

https://i.imgur.com/57aOrXi.mp4

Code: [Select]
#include <iostream>
using namespace std;
string url;


int main() {
    cout << "ENTER A URL" << endl;
    cin >> url;
    system(("youtube-dl " "-x " "--audio-format " "mp3 "+ url).c_str());
    return 0;
}

Re: Youtube Downloader

Reply #5
.bat File

Code: [Select]
@echo off
set /p myVar="Enter a URL: "
youtube-dl -x --audio-format mp3 "%myVar%"

Re: Youtube Downloader

Reply #6
Bash Script

Code: [Select]
#!/bin/bash
echo "ENTER A URL";
read myInput;
youtube-dl -x --audio-format mp3 $myInput;

Re: Youtube Downloader

Reply #7
For Linux
begin.py
would look like
Code: [Select]
import discord
import sys
import subprocess
from subprocess import call
from discord.ext import commands
bot = commands.Bot(command_prefix='!')
 
@bot.command()
async def ayy(ctx, arg):
    await ctx.send("Please Wait...")
    text_file = open("URL.txt", "a") 
    text_file.write(arg+"\n")
    await ctx.send(arg + " was added!")
 
 
@bot.command()
async def go(ctx):
    await ctx.send("Loading...")
    subprocess.call('python3 ./YT.py', shell=True)
    await ctx.send("downloaded!")
 
@bot.command()
async def email(ctx):
    await ctx.send("Sending Email...")
    subprocess.call('python3 ./Send_Media.py', shell=True)
    await ctx.send("SENT!")
 
@bot.command()
async def gone(ctx):
    await ctx.send("Deleted...")
    subprocess.call('python3 ./DEL.py', shell=True)
bot.run('token')

On Windows
begin.py
would look like
Code: [Select]
import discord
import sys
import subprocess
from subprocess import call
from discord.ext import commands
bot = commands.Bot(command_prefix='!')
 
@bot.command()
async def ayy(ctx, arg):
    await ctx.send("Please Wait...")
    text_file = open("URL.txt", "a") 
    text_file.write(arg+"\n")
    await ctx.send(arg + " was added!")
 
 
@bot.command()
async def go(ctx):
    await ctx.send("Loading...")
    subprocess.call("YT.py", shell=True)
    await ctx.send("downloaded!")
 
@bot.command()
async def email(ctx):
    await ctx.send("Sending Email...")
    subprocess.call("Send_Media.py", shell=True)
    await ctx.send("SENT!")
 
@bot.command()
async def gone(ctx):
    await ctx.send("Deleted...")
    subprocess.call("DEL.py", shell=True)
bot.run('token')
 


Re: Youtube Downloader

Reply #9
Can even build this application using static ffmpeg libraries on Kali Linux

https://johnvansickle.com/ffmpeg/

Code: [Select]
import requests
import subprocess
from subprocess import call
from tkinter import *
import webbrowser
from tkinter import messagebox
window = Tk()
root = Tk()
frame = Frame(root)
frame.pack()
def OpenGithub():
    url = 'https://github.com/lalenguanegra/youtube-dl_MP3'
    webbrowser.open_new(url)
window.title("Sadie Socio's")
lbl = Button(window, text="youtube-dl", command=OpenGithub, width=30, height=10, font=("Arial Bold", 30))
def command():
    Toplevel(root)
root.title("")
canvas1 = Canvas(root, width = 150, height = 35)
canvas1.pack()
entry1 = Entry (root, justify='center')
def Entry():
        messagebox.showwarning("Please Wait...","Downloading...")
        a = entry1.get()
        with open(('URL.txt'), 'w') as f:
            f.write(a)
        call(['python3', './youtube-dl/youtube_dl/__main__.py', '--ffmpeg-location', './ffmpeg/ffmpeg', '-x', '--audio-format', 'mp3', '-a', './URL.txt'], shell=False)
canvas1.create_window(75, 25, width=337, window=entry1)



b1 = Button(root, text="MP3", command=Entry, height=1, width=8, font=("Arial Bold", 50))
window.geometry("500x100+300+300")
b1.pack()
lbl.pack()
b1.config(bg="#6600cc")
lbl.config(bg="#b3003b")

window.mainloop()