diff --git a/README.md b/README.md index e7e61d8..7afd1a3 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/spotify_downloader/README.md b/spotify_downloader/README.md new file mode 100644 index 0000000..e2e7936 --- /dev/null +++ b/spotify_downloader/README.md @@ -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. +

+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) +

+# 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 diff --git a/spotify_downloader/requirements.txt b/spotify_downloader/requirements.txt new file mode 100644 index 0000000..f5441ea --- /dev/null +++ b/spotify_downloader/requirements.txt @@ -0,0 +1 @@ +spotdl==2.2.2 diff --git a/spotify_downloader/spotify.py b/spotify_downloader/spotify.py new file mode 100644 index 0000000..4858e78 --- /dev/null +++ b/spotify_downloader/spotify.py @@ -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()