Skip to content

Commit

Permalink
v3.3 release (SathyaBhat#59)
Browse files Browse the repository at this point in the history
* fix: user_id error & support for playlist url with or without userid

* prepare for release
  • Loading branch information
SathyaBhat authored Oct 20, 2019
1 parent b9d82fb commit ac14bb7
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 174 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ You can set defaults per user by creating a file at `~/.spotify_dl_settings`. Cr
- [Gowtham](https://github.com/HackToHell) for [create playlist in download](https://github.com/SathyaBhat/spotify-dl/pull/23) directory
- [alvierahman90](https://github.com/alvierahman90) for [config file support](https://github.com/SathyaBhat/spotify-dl/pull/42) and [Spotify playlist URL support](https://github.com/SathyaBhat/spotify-dl/pull/41)
- [Bibhas](https://github.com/iambibhas) for fixing [can only concatenate list (not "str") to list error](https://github.com/SathyaBhat/spotify-dl/issues/44)
- [Nikhil Nagaraju](https://github.com/nikhilnagaraju) for fixing support for playlist url with or without userid #58

## Issues, Feedback, Contact details
Feel free to raise any bugs/issues under Github issues. Pull requests are also more than welcome. You can reach me on twitter at [@sathyabhat](https://twitter.com/sathyabhat) or drop an email [[email protected]](mailto:[email protected])
157 changes: 0 additions & 157 deletions README.rst

This file was deleted.

1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
rm dist/*
pip3 install -r requirements.txt
python3 setup.py sdist
python3 setup.py bdist_wheel
twine upload dist/*
14 changes: 6 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

from setuptools import setup, find_packages

try:
import pypandoc
long_description = pypandoc.convert('README.md', 'rst')
except (IOError, ImportError):
long_description = open('README.rst', encoding="utf8").read()
with open('README.md') as f:
long_description = f.read()

with open('requirements.txt') as f:
requirements = f.read().splitlines()

version = '3.0.1'
version = '3.3.0'

setup(
name='spotify_dl',
Expand All @@ -24,9 +21,10 @@
include_package_data=True,
url='https://github.com/SathyaBhat/spotify-dl/',
license='MIT',
description='Downloads songs from Spotify My Music '
'or Spotify Playlist that you provide',
description='Downloads songs from a '
'Spotify Playlist that you provide',
long_description=long_description,
long_description_content_type='text/markdown',
entry_points={
'console_scripts': [
'spotify_dl=spotify_dl.spotify_dl:spotify_dl',
Expand Down
21 changes: 13 additions & 8 deletions spotify_dl/spotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,24 @@ def download_songs(info, download_directory, format_string, skip_mp3):
continue


def extract_user_and_playlist_from_uri(uri):
playlist_re = re.compile("spotify:user:[\w,.]+:playlist:[\w]+")
for playlist_uri in playlist_re.findall(uri):
def extract_user_and_playlist_from_uri(uri, sp):
playlist_re = re.compile("(spotify)(:user:[\w,.]+)?(:playlist:[\w]+)")
user_id = sp.current_user()['id']
for playlist_uri in ["".join(x) for x in playlist_re.findall(uri)]:
segments = playlist_uri.split(":")
user_id = segments[2]
log.info('List owner: ' + str(user_id))
playlist_id = segments[4]
log.info('List ID: ' + str(playlist_id))
if len(segments) >= 4:
user_id = segments[2]
playlist_id = segments[4]
log.info('List ID: ' + str(playlist_id))
else:
playlist_id = segments[2]
log.info('List ID: ' + str(playlist_id))
log.info('List owner: ' + str(user_id))
return user_id, playlist_id


def playlist_name(uri, sp):
user_id, playlist_id = extract_user_and_playlist_from_uri(uri)
user_id, playlist_id = extract_user_and_playlist_from_uri(uri, sp)
return get_playlist_name_from_id(playlist_id, user_id, sp)


Expand Down
2 changes: 1 addition & 1 deletion spotify_dl/spotify_dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def spotify_dl():
else:
raise Exception('Invalid playlist URL ')
if args.uri:
current_user_id, playlist_id = extract_user_and_playlist_from_uri(args.uri[0])
current_user_id, playlist_id = extract_user_and_playlist_from_uri(args.uri[0], sp)
else:
if args.user_id is None:
current_user_id = sp.current_user()['id']
Expand Down

0 comments on commit ac14bb7

Please sign in to comment.