diff --git a/.gitignore b/.gitignore index db01a5f..af28267 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ dist/ *.pyc *.egg-info/ __pycache__/ +*.mp3 \ No newline at end of file diff --git a/README.md b/README.md index 6df98ae..31d233d 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ It should work with OS X, Linux, Windows. ### Installation ___ 1. Install scdl `pip3 install scdl` -2. Setup your path and your auth_token in `$HOME/.config/scdl/scdl.cfg` +2. (Optional) Setup your path and your auth_token in `$HOME/.config/scdl/scdl.cfg` ### Authentication: diff --git a/scdl/scdl.py b/scdl/scdl.py index ce60f7c..2e0ed55 100755 --- a/scdl/scdl.py +++ b/scdl/scdl.py @@ -131,7 +131,7 @@ def get_item(track_url): item = client.get('/resolve', url=track_url) except Exception as e: print("Could not resolve url " + track_url) - print(e.message, e.args) + print(e) sys.exit(0) return item @@ -142,8 +142,11 @@ def parse_url(track_url): """ arguments = docopt(__doc__, version='0.1') item = get_item(track_url) + if not item: return + elif isinstance(item, soundcloud.resource.ResourceList): + download_all(item) elif item.kind == 'track': print("Found a track") download_track(item) @@ -287,6 +290,21 @@ def download_playlist(playlist): download_track(mp3_url) +def download_all(tracks): + """ + Download all song of a page + Not recommended + """ + print("NOTE: This will only download the songs of the page.(49 max)") + print("I recommend you to provide an user link and a download type.") + count = 0 + for track in tracks: + count += 1 + print("") + print('Track n°%d' % (count)) + download_track(track) + + def download_track(track): """ Downloads a track