Overview
SimpleYouTubeAudioDownloader (SYTAD) is a simple Python3 script using pafy to download the best possible audio from YouTube videos or YouTube playlists.
It is intended for everyday-use, and is quicker and simpler to use than directly using pafy if all you really care about is downloading the audio from a YouTube video.
It also works on Android through QPython3.
Sample usage
The SimpleYouTubeAudioDownloader can be used
- Directly from the command line.
- Through a terminal user interface (TUI).
- Within python scripts.
Command line usage
To download YouTube videos:
py -m SYTAD url-1 url-2 ... url-n
where each url-x is either a video URL or ID.
To download from a YouTube playlist:
py -m SYTAD -p plurl
where plurl is either a playlist URL or ID.
Terminal user interface
To enter the terminal user interface, write
py -m SYTAD
Or simply run the SYTAD.py file from the terminal.
py SYTAD.py
This last option of course requires you to navigate to the folder containing SYTAD.py (or, if using Windows 8, open the terminal in the folder by shift + right-clicking in the folder).
SYTAD in scripts
First import SYTAD:
>>> import SYTAD
Downloading a YouTube video:
>>> id = 'dQw4w9WgXcQ' #YouTube video ID or URL
>>> video = SYTAD.video(id)
>>> video.download() # Optional parameters: folder, filetype
Downloading a list of YouTube videos:
>>> idList = ['dQw4w9WgXcQ', 'Rqz--Rf6IIo'] # List or tuple of video IDs or URLs
>>> videos = SYTAD.multipleVideos(idList)
>>> videos.downloadAll('D:\Example', 'ogg') # Optional parameters: folder, filetype
Download all videos from a YouTube playlist:
>>> plid = 'PLDFDE550C8A0544AE' # Playlist ID or URL
>>> playlist = SYTAD.playlist(plid)
>>> playlist.downloadAll(filetype = 'ogg') # Optional parameters: folder, filetype
Currently only m4a
and ogg
filetypes are supported. The default download folder is the standard download folder in your home directory.
Installation
If you have pip you can simply enter
$ [sudo] pip install SYTAD
If you do not have pip you can download the "SYTAD" folder and copy it to the .../Python3x/Lib/site-packages
folder.
If you do not have pafy, you can install pafy in a similar manner:
$ [sudo] pip install pafy
Or you can head to pafy on GitHub.