[Tutorial] Downloading Music/Videos from the net

griimnak

You're a slave to the money then you die
Jul 20, 2013
955
794
In this day and age, videos are scrubbed from the net so fast that it's becoming increasingly necessary to download/save them.
Unfortunately with most large scale sites, it's not as simple as just finding an mp4 link and hitting CTRL+S to save it.

In this thread, I'll share a few personal tricks and tools I use to download videos and music from various sources around the internet.


The big sites
Ever use youtube-dl before?
Well these days, there's a more efficient and active fork called YT-DLP which you can grab .
This will cover most mainstream social media sites including but not limited to, youtube, twitter, tiktok, bitchute, vimeo.

Usage:
Firstly, I suggest reading through for options that suit your preferences.

Basic usage:
This will download a video in it's original format.
Bash:
$ yt-dlp 'videourl'

My preferred usage:
This will attempt to download the video in the best quality offered if available, and merge the final output into an mp4 file.
(Demonstrating with a random tiktok link)
Bash:
$ yt-dlp --format "bestvideo+bestaudio[ext=m4a]/bestvideo+bestaudio/best" --merge-output-format mp4 --output testvid.%(ext)s 'https://www.tiktok.com/@nastyatyman/video/7071925639011503361?is_copy_url=1&is_from_webapp=v1'



.mp4 and m3u8/.ts
Moving on, what about sites that yt-dlp doesn't cover?

Most sites delivering content themselves today deliver them via raw mp4 or .m3u8/.ts stream.
All we need is browser devtools and ffmpeg which you can grab here:

In this example, I'll be using a random CNN video.
First step, find the m3u8 steam master url in devtools:
7HGCeuD.png

Once you have the url, just paste it into ffmpeg as shown below.

My preferred usage:
Bash:
$ ffmpeg -i 'https://clips-media-lln.warnermediacdn.com/cnn/clips/2022-03/714523-b746d3ba589a40489a9ecb011d1f3612/ts/media-1/stream.m3u8' -codec copy desiredfilename.mp4

voila.

Wrapping up
I wrote a crappy lil wrapper that I personally use for mp3 and mp4 conversion with thumbnail embedding, so I'll leave it here if anyone finds use in it.
Python:
import os
import time

print('''                      __       __   ___ 
                    /'__`\    /\ \ /\_ \
   ___ ___   _____ /\_\_\ \   \_\ \\\//\ \ 
 /' __` __`\/\ '__`\/_/_\_\_  /'_` \ \ \ \
 /\ \/\ \/\ \ \ \_\ \/\ \_\ \/\ \_\ \ \_\ \_
 \ \_\ \_\ \_\ \ ,__/\ \____/\ \___,_\/\____\
  \/_/\/_/\/_/\ \ \/  \/___/  \/__,_ /\/____/
       mp3dl   \ \_\  youtube-dl wrapper script for
                \/_/         mp3 conversion.
''')

mode = input('Choose mode: "music" or "video": ')
url = None

if mode == 'video':
    while True:
        url = input('[viddl] Paste YouTube, Twitter, Tiktok, Anime or Bitchute video url: ')
        os.system('yt-dlp --retries infinite --format "bestvideo+bestaudio[ext=m4a]/bestvideo+bestaudio/best" --merge-output-format mp4 "{}" --embed-thumbnail --postprocessor-args "-id3v2_version 3" -o videos/{}.%(ext)s'.format(url, time.time()))

elif mode == 'music':
    while True:
        url = input('[mp3dl] Paste YouTube or Soundcloud url: ')
        os.system('yt-dlp --sleep-interval 1 -ciw --retries infinite -f bestaudio "{}" --extract-audio --audio-format mp3 --embed-thumbnail --postprocessor-args "-id3v2_version 3" -o music/%(title)s.%(ext)s'.format(url))

else:
    exit('{} is not a valid mode, type "music" or "video"'

Hopefully this helps you in this digital age of information.
If you have anything to add to this post, feel free to leave a reply and I'll be sure to add edit it in, cheers!
 

Macemore

Circumcised pineapples
Aug 26, 2011
1,681
819
Nice writeup, thanks! My question is this superior to using a free browser plugin to save the video? I archive things instinctively and just use a browser plugin that works for most sites.
 

griimnak

You're a slave to the money then you die
Jul 20, 2013
955
794
Nice writeup, thanks! My question is this superior to using a free browser plugin to save the video? I archive things instinctively and just use a browser plugin that works for most sites.
Thanks man and yeah, I've tried a few extentions/gui apps myself but I personally feel like the quality & control doing it this way is better. I'm pretty picky and want everything to have thumbnails embedded and be in mp4 format, the yt-dlp options satisfy that need easily.

When I download albums from music.youtube.com I use:
Bash:
--sleep-interval 1 -ciw --retries infinite -f bestaudio --extract-audio --audio-format mp3 --embed-thumbnail --postprocessor-args "-id3v2_version 3"

When I download HD video content I use:
Bash:
--format "bestvideo+bestaudio[ext=m4a]/bestvideo+bestaudio/best" --merge-output-format mp4 --embed-thumbnail --postprocessor-args "-id3v2_version 3"
 

Macemore

Circumcised pineapples
Aug 26, 2011
1,681
819
Thanks man and yeah, I've tried a few extentions/gui apps myself but I personally feel like the quality & control doing it this way is better. I'm pretty picky and want everything to have thumbnails embedded and be in mp4 format, the yt-dlp options satisfy that need easily.

When I download albums from music.youtube.com I use:
Bash:
--sleep-interval 1 -ciw --retries infinite -f bestaudio --extract-audio --audio-format mp3 --embed-thumbnail --postprocessor-args "-id3v2_version 3"

When I download HD video content I use:
Bash:
--format "bestvideo+bestaudio[ext=m4a]/bestvideo+bestaudio/best" --merge-output-format mp4 --embed-thumbnail --postprocessor-args "-id3v2_version 3"
Thanks dude this is awesome! Sounds like you're doing it the right way, especially with embedded thumbnails.
 

DDDDec

Tongue Boxing Champion 2023
May 30, 2017
405
248
thanks!!! haha i do the same by using extensions, will try this way out so i can get thumbnails for when i upload them.
 

TesoMayn

Boredom, it vexes me.
Oct 30, 2011
1,482
1,482
I prefer using over just ffmpeg, as it has support for many sites, so you don't need to search for the HLS URL, and if you need to, you use use hls:// or hlsvarient:// (replace the http(s)://)
 

Users who are viewing this thread

Top