diff --git a/README.md b/README.md index d545e36..1594ef9 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: @@ -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: @@ -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? @@ -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: diff --git a/spotdl.py b/spotdl.py index 22ad3ea..d6d5e3e 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,45 @@ 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") +print('') +if args.list: + grabList(file='list.txt') + exit() + 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('Enter a Spotify URL or Song Name: ') + command = raw_input('>> ') + print('') + grabSingle(raw_song=command, number=None) print('') - initializeInput(command) except KeyboardInterrupt: graceQuit()