From 8f812a1410f871fe012118ef0aadbdabafb04e13 Mon Sep 17 00:00:00 2001 From: Ritiek Malhotra Date: Wed, 3 May 2017 11:44:55 +0530 Subject: [PATCH 1/8] Initiate list from command-line --- spotdl.py | 67 ++++++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/spotdl.py b/spotdl.py index 22ad3ea..ab29c6e 100644 --- a/spotdl.py +++ b/spotdl.py @@ -13,39 +13,6 @@ import argparse import pathlib #import spotipy.util as util -# Python 3 compatibility -if version_info > (3,0): - raw_input = input - -eyed3.log.setLevel("ERROR") - -os.chdir(path[0]) - -if not os.path.exists("Music"): - os.makedirs("Music") -open('list.txt', 'a').close() - -spotify = spotipy.Spotify() - -# Set up arguments -parser = argparse.ArgumentParser() -parser.add_argument("-n", "--no-convert", help="skip the conversion process and meta-tags", action="store_true") -parser.add_argument("-m", "--manual", help="choose the song to download manually", action="store_true") -args = parser.parse_args() - -if args.no_convert: - print("-n, --no-convert skip the conversion process and meta-tags") -if args.manual: - print("-m, --manual choose the song to download manually") - -def initializeInput(command): - if command == 'list': - grabList(file='list.txt') - elif command == 'exit': - graceQuit() - else: - grabSingle(raw_song=command, number=None) - def getInputLink(links): while True: try: @@ -220,6 +187,7 @@ def grabList(file): except ValueError: pass print('Total songs in list = ' + str(len(lines)) + ' songs') + print('') # Count the number of song being downloaded number = 1 for raw_song in lines: @@ -243,14 +211,43 @@ def graceQuit(): print('Exitting..') exit() +# Python 3 compatibility +if version_info > (3,0): + raw_input = input + +eyed3.log.setLevel("ERROR") + +os.chdir(path[0]) + +if not os.path.exists("Music"): + os.makedirs("Music") +open('list.txt', 'a').close() + +spotify = spotipy.Spotify() + +# Set up arguments +parser = argparse.ArgumentParser() +parser.add_argument("-n", "--no-convert", help="skip the conversion process and meta-tags", action="store_true") +parser.add_argument("-m", "--manual", help="choose the song to download manually", action="store_true") +parser.add_argument("-l", "--list", help="download songs present in list.txt", action="store_true") +args = parser.parse_args() + +if args.no_convert: + print("-n, --no-convert skip the conversion process and meta-tags") +if args.manual: + print("-m, --manual choose the song to download manually") +if args.list: + grabList(file='list.txt') + exit() +print('') + while True: for temp in os.listdir('Music/'): if temp.endswith('.m4a.temp'): os.remove('Music/' + temp) - print('') try: command = raw_input('>> Enter a song/cmd: ') print('') - initializeInput(command) + grabSingle(raw_song=command, number=None) except KeyboardInterrupt: graceQuit() From c42d4704380f49eca7aa29a071ad89bd2de182f7 Mon Sep 17 00:00:00 2001 From: Ritiek Malhotra Date: Wed, 3 May 2017 11:45:57 +0530 Subject: [PATCH 2/8] Change order of print statement --- spotdl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spotdl.py b/spotdl.py index ab29c6e..8a9ff8d 100644 --- a/spotdl.py +++ b/spotdl.py @@ -236,10 +236,10 @@ if args.no_convert: print("-n, --no-convert skip the conversion process and meta-tags") if args.manual: print("-m, --manual choose the song to download manually") +print('') if args.list: grabList(file='list.txt') exit() -print('') while True: for temp in os.listdir('Music/'): From 0f8a6ea200f454a44e7707b500120bd0fa75b3bc Mon Sep 17 00:00:00 2001 From: Ritiek Malhotra Date: Wed, 3 May 2017 11:55:31 +0530 Subject: [PATCH 3/8] Change input prompt --- spotdl.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spotdl.py b/spotdl.py index 8a9ff8d..981aa2d 100644 --- a/spotdl.py +++ b/spotdl.py @@ -246,7 +246,9 @@ while True: if temp.endswith('.m4a.temp'): os.remove('Music/' + temp) try: - command = raw_input('>> Enter a song/cmd: ') + print('Enter a Spotify URL or Song Name: ') + print('') + command = raw_input('>> ') print('') grabSingle(raw_song=command, number=None) except KeyboardInterrupt: From a55134df5e8a8783cf53ef9149bee5675383568e Mon Sep 17 00:00:00 2001 From: Ritiek Malhotra Date: Wed, 3 May 2017 12:05:38 +0530 Subject: [PATCH 4/8] Improve interface --- spotdl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spotdl.py b/spotdl.py index 981aa2d..d6d5e3e 100644 --- a/spotdl.py +++ b/spotdl.py @@ -247,9 +247,9 @@ while True: os.remove('Music/' + temp) try: print('Enter a Spotify URL or Song Name: ') - print('') command = raw_input('>> ') print('') grabSingle(raw_song=command, number=None) + print('') except KeyboardInterrupt: graceQuit() From d40494eae537764f82d697541ac0349fe0ad39e4 Mon Sep 17 00:00:00 2001 From: Ritiek Malhotra Date: Wed, 3 May 2017 12:13:34 +0530 Subject: [PATCH 5/8] Update instructions on using list.txt --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d545e36..1f81a4d 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ That's how your Music library will look like! - This version supports both Python2 and Python3. -- Note: `play` and `lyrics` commands have been deprecated in `remake` brach since they were not of much use and created unnecessary clutter. You can still get them back by using `old` branch though. +- Note: `play` and `lyrics` commands have been deprecated in the current brach since they were not of much use and created unnecessary clutter. You can still get them back by using `old` branch though. ### Debian, Ubuntu, Linux & Mac: @@ -111,11 +111,11 @@ the nights avicci 21 guns green day ``` -- Now just run the script and type `list`, it will automatically start downloading the songs you provided in `list.txt`. +- Now pass `--list` or `-l` to the script, i.e `sudo python spotdl.py --list` and it will start downloading songs mentioned in `list.txt`. -- You can stop downloading songs by hitting `ctrl+c`, the script will automatically resume from the song where you stopped it the next time you want to download the songs using `list` command. +- You can stop downloading songs by hitting `ctrl+c`, the script will automatically resume from the song where you stopped it the next time you want to download the songs present in `list.txt`. -- To download all songs in your playlist, just select all the songs `ctrl+a` in Spotify desktop app, copy them `ctrl+c` and paste `ctrl+v` in `list.txt`. +- To download all songs in your playlist, just select all the songs `ctrl+a` in Spotify desktop app, copy them `ctrl+c` and paste `ctrl+v` in `list.txt` and then use `--list` argument. ## Disclaimer: From aed4c99336d9f2e3963e9ed6af6590ba6f4ee36b Mon Sep 17 00:00:00 2001 From: Ritiek Malhotra Date: Wed, 3 May 2017 12:15:26 +0530 Subject: [PATCH 6/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1f81a4d..8e57d04 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ For example: - Just like before, it will again convert the song to an mp3 but since we used a Spotify HTTP link, the script is guaranteed to fetch the correct meta-tags and album-art. -- Just type `exit` to exit out of the script. +- Just hit `ctrl+c` to exit out of the script. #### What if we want to download multiple songs at once? From 4c6a1034903ddda3477b7dbf7ccfaa9a7a3fc5ab Mon Sep 17 00:00:00 2001 From: Ritiek Malhotra Date: Wed, 3 May 2017 12:16:42 +0530 Subject: [PATCH 7/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8e57d04..1594ef9 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Now to run the script type: - Launch the script using the above command as mentioned for your OS. -- For available options, run `sudo python spotdl.py --help`. +- For available options, run `sudo python spotdl.py --help` (or for windows run `python.exe spotdl.py --help`. #### Downloading by Name: From bd2f99f8af9204d13eb91f8abc5c0884c95df1f6 Mon Sep 17 00:00:00 2001 From: Ritiek Malhotra Date: Wed, 3 May 2017 12:20:38 +0530 Subject: [PATCH 8/8] Add list.txt and last_albumart.jpg --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 7e809eb..74459fb 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ Music/ +last_albumart.jpg +list.txt