Added spotify downloader (#195)

Co-authored-by: Ayush Bhardwaj <classicayush@gmail.com>
This commit is contained in:
sagar627 2020-10-24 17:22:34 +05:30 committed by GitHub
parent 957f7ab45c
commit e3db5f71f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 63 additions and 0 deletions

View File

@ -165,6 +165,7 @@ So far, the following projects have been integrated to this repo:
|[IMDBQuerier](IMDBQuerier)|[Burak Bekci](https://github.com/Bekci)
|[URL shortener](url_shortener)|[Sam Ebison](https://github.com/ebsa491)
|[2048](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/2048)|[Krunal](https://github.com/gitkp11)
|[Spotify Downloader](spotify_downloader)|[Sagar Patel](https://github.com/sagar627)|
|[Download Page as PDF](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Download-page-as-pdf)|[Jeremias Gomes](https://github.com/j3r3mias)

View File

@ -0,0 +1,32 @@
- Downloads music from YouTube as an MP3 file.
- Applies basic on metadata like track name, track number, album, genre and more.
<br><br>
You need to download ffmpeg to use this tool, download it from:
1. [MacOs](https://evermeet.cx/ffmpeg/)
2. [Windows](https://www.gyan.dev/ffmpeg/builds/)
3. [Linux](https://johnvansickle.com/ffmpeg/)
4. [Central Release Page](https://ffmpeg.org/download.html)
<br><br>
# Installation
```
pip install -r requirements.txt
```
OR
```
pip3 install -r requirements.txt
```
# Usage
To download a song run,
python3 spotify.py $trackUrl
python3 spotify.py https://open.spotify.com/track/08mG3Y1vljYA6bvDt4Wqkj?si=SxezdxmlTx-CaVoucHmrUA
To download an album run,
python3 spotify.py $albumUrl
python3 spotify.py https://open.spotify.com/album/2YMWspDGtbDgYULXvVQFM6?si=gF5dOQm8QUSo-NdZVsFjAQ
To download a playlist run,
python3 spotify.py $playlistUrl
python3 spotify.py https://open.spotify.com/playlist/37i9dQZF1DWXhcuQw7KIeM?si=xubKHEBESM27RqGkqoXzgQ

View File

@ -0,0 +1 @@
spotdl==2.2.2

View File

@ -0,0 +1,29 @@
import spotdl
import sys,os
def spotify():
if(len(sys.argv) <= 1):
print("try 'python3 spotify.py -h' for help")
return 1
elif(sys.argv[1] == '-h'):
print("To download a song run,\n python3 spotify.py $trackUrl\n\nTo download an album run,\n python3 spotify.py $albumUrl\n\nTo download a playlist run,\n python3 spotify.py $playlistUrl")
return 1
url = sys.argv[1]
if (url.find('track') > -1):
os.system(f'spotdl --song {url}')
else:
# Playlist
if (url.find('playlist') > -1):
os.system(f"spotdl -p {url} --write-to playlist.txt")
os.system(f"spotdl --list playlist.txt")
# Artist
if (url.find('artist') > -1):
os.system(f"spotdl --all {url} --write-to artist.txt")
os.system(f"spotdl --list artist.txt")
# album
if (url.find('album') > -1):
os.system(f"spotdl -a {url} --write-to album.txt")
os.system(f"spotdl --list album.txt")
if __name__ == "__main__":
spotify()