The purpose of this software is to create a simple Python based Youtube downloader that takes a list of Youtube URLs in a text file as an input. It queries the Youtube API, gets the relevant information about the youtube URL(s) and downloads them in the designated folder.
Now you can retrieve the information about the youtube videos without downloading them. I have created a new command line flag called --information_output.
It can be of three types: txt json csv
youtube_downloader can download files from public youtube playlists. Now you can create playlists on Youtube and add that playlist in our download files list. The library will go and download available youtube videos as sound files.
This software uses PyPI module yt-dlp
Software was developed and tested on:
- Operating System: Ubuntu 22.04
- Python Version: Python 3.10.12
- yt-dlp Version: 2023.11.16
Inside the root folder, run the following command:
pip3 install -r requirements.txt
Suppose the list of urls are stored in list.txt, then you can execute this software using the following command: python3 main.py list.txt
The following commandline call shows how to get the information about the Youtube Video :
python3 main.py --file=list.txt --information=True --information_output=txt
Processing 1 of total URLs: 1
Please find the information about supplied Youtube URLs as a Dataframe
Folder 'output' created successfully.
Output successfully written to ./output/data_output.txt
{"error": "0", "message": "Succesfully converted into txt", "outputfile": "./output/data_output.txt"}
python3 main.py --file=list.txt --information=True --information_output=csv
Processing 1 of total URLs: 1
Please find the information about supplied Youtube URLs as a Dataframe
Folder 'output' already exists.
Output successfully written to ./output/data_output.json
{"error": "0", "message": "Succesfully converted into json", "outputfile": "./output/data_output.json"}
python3 main.py --file=list.txt --information=True --information_output=csv
Processing 1 of total URLs: 1
Please find the information about supplied Youtube URLs as a Dataframe
Folder 'output' already exists.
{"error": "0", "message": "Succesfully converted into csv", "outputfile": "./output/data_output.csv"}
Suppose the list of urls are stored in list.txt, it has the following syntax. It just contains one youtube url per line
https://www.youtube.com/watch?v=1y3TKv7Chk4
https://www.youtube.com/watch?v=bDMCwSP5nf0
We can use the same text file that contains list of youtube URLs. Let's suppose we call this list.txt, we can add playlist url as shown below:
https://www.youtube.com/watch?v=1y3TKv7Chk4 PL=>https://www.youtube.com/playlist?list=PLmt8QxZTX6rRZcnShk27RC0ZMMe3FMwSz https://www.youtube.com/watch?v=bDMCwSP5nf0
In order to denote a playlist URL, we need to add PL=> in front of the line.
$ python3 main.py list.txt
Processing URL: https://www.youtube.com/watch?v=1y3TKv7Chk4
Video information is {'title': 'Kim Wilde - Cambodia (1981) HD 0815007', 'description': 'HQ-Video. Kim Wilde - Cambodia (1981). Audio-CD-Sound versehen mit Video-Material aus TV-Show. Sound replaced by audio-cd-sound. Full song.', 'view_count': 81438995, 'comment_count': 9800}
Cleaned name: kim_wilde__cambodia_1981_hd_0815007
[youtube] Extracting URL: https://www.youtube.com/watch?v=1y3TKv7Chk4
[youtube] 1y3TKv7Chk4: Downloading webpage
[youtube] 1y3TKv7Chk4: Downloading ios player API JSON
[youtube] 1y3TKv7Chk4: Downloading android player API JSON
[youtube] 1y3TKv7Chk4: Downloading m3u8 information
[info] 1y3TKv7Chk4: Downloading 1 format(s): 251
[download] ./downloads//kim_wilde__cambodia_1981_hd_0815007.mp3 has already been downloaded
[download] 100% of 3.54MiB
Successfully Downloaded: https://www.youtube.com/watch?v=1y3TKv7Chk4
Downloaded status: ['kim_wilde__cambodia_1981_hd_0815007']
Sleeping for 5 seconds
Processing URL: https://www.youtube.com/watch?v=bDMCwSP5nf0
..
..
..
Processed 11 out of provided 11