A simple Python package for downloading videos and playlists from YouTube
Project description
YouTube Monk
A YouTube video and playlist downloader made in Python.
Report Bug
·
Request Feature
Table of Contents
Important
This is my first project uploaded to Github. If you find a mistake or just anything you don't like, just let me know and I'll try to fix it.
About The Project
This little project began when I wanted to download a playlist from YouTube. For downloading single videos, I always use cobalt.tools, because it is ad-free and open-source, but it is still missing something... a playlist downloader. I tried a few other YT downloaders to download a playlist, but I wasn't happy with their functionality.
(cobalt website)
So I decided to make my own YT video and playlist downloader in Python.
Making the program
First, I downloaded a testing video and captured the network traffic from cobalt, because I wanted to know how do they download videos:
(the network traffic capture)
Based on that capture, I found out, that the user recieves the video as a stream of data from olly.imput.net/api
. Now I need to know how to make the request to their API to get the stream URL, so I looked into the JavaScript code, that was downloading the videos:
(some of the JavaScript code of the website)
Now that I know how to get the stream URL, I can recreate it in python:
response = json.loads(requests.post(self.api_url, headers=headers, data=json.dumps(data)).text)
if response['status'] == 'stream':
stream_url = response['url']
And capture the stream to a file:
def captureStream(self, stream_url, file_path):
with requests.get(stream_url, stream=True) as r:
r.raise_for_status()
with open(file_path, 'wb') as f:
for chunk in r.iter_content(chunk_size=8192):
f.write(chunk)
Then I just made some more functions.
To-do
- Make a python package work
- Upload the package to PyPi
- Make a cli app
- Make a js chrome extension
- Make an exe app
- Reorganize files
Getting Started
Now you have 3 options: download it as an exe file and run it on Windows without the need to install Python or you can download the Python file and run that or you can install it as a python library and use it in your code.
Getting the Windows executable
-
Download
yt_monk.exe
-
Run it on Windows
-
Windows might mark it as a , so just click on
More info
and then click onRun anyway
(I could try to fix that, but it is not my main goal now and also idk how to fix it)If you realy don't trust it (I get it), you can download the python code.
Getting the Python file
-
Download
yt_monk.py
andrequirements.txt
-
Install
requirements.txt
using pip:pip install -r requirements.txt
-
Run it using python:
python yt_monk.py
Getting the library
I am stil working on getting it uploaded to PyPi. That is it for now.
Usage
Here are some basic examples of using my code
Using as an application
When you run yt_monk.py
or yt_monk.exe
you will get prompted to enter the URL
You can enter video or playlist URL (the program will detect the URL type) or q
to quit the loop.
Using as a Python library
Import the library and define the downloader
object:
import yt_monk
downloader = yt_monk.YT_Downloader()
Downloading a video:
video_url = 'https://www.youtube.com/watch?v=9bZkp7q19f0'
downloader.downloadVideo(video_url)
Downloading a playlist:
playlist_url = 'https://www.youtube.com/playlist?list=PLZHQObOWTQDNU6R1_67000Dx_ZCJB-3pi'
downloader.downloadPlaylist(playlist_url)
License
Distributed under the MIT License. See LICENSE.txt
for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for yt_monk-0.1.1a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20c072e835b22f59cc9d9a36384ba722acdb740aa3f6d5a0e6a22175757dd7b5 |
|
MD5 | e61ceef1dd7e1c897ebd2d4254bd426d |
|
BLAKE2b-256 | d611d576622caeb580e29aed5b4dfe95cd8ed36d8dade0d30e216d6a01ea8a1d |