Merge b27c9c8b8c
into c875389e9a
commit
455ba760c4
|
@ -13,6 +13,8 @@ import urllib.error
|
|||
import urllib.parse
|
||||
import urllib.request
|
||||
import webbrowser
|
||||
import certifi
|
||||
import ssl
|
||||
|
||||
logging.basicConfig(level=20, datefmt='%I:%M:%S', format='[%(asctime)s] %(message)s')
|
||||
|
||||
|
@ -36,7 +38,8 @@ class SpotifyAPI:
|
|||
try:
|
||||
req = urllib.request.Request(url)
|
||||
req.add_header('Authorization', 'Bearer ' + self._auth)
|
||||
res = urllib.request.urlopen(req)
|
||||
context = ssl.create_default_context(cafile=certifi.where())
|
||||
res = urllib.request.urlopen(req, context=context)
|
||||
reader = codecs.getreader('utf-8')
|
||||
return json.load(reader(res))
|
||||
except Exception as err:
|
||||
|
@ -190,11 +193,12 @@ def main():
|
|||
for track in playlist['tracks']:
|
||||
if track['track'] is None:
|
||||
continue
|
||||
f.write('{name}\t{artists}\t{album}\t{uri}\r\n'.format(
|
||||
f.write('{name}\t{artists}\t{album}\t{added_at}\t{uri}\r\n'.format(
|
||||
uri=track['track']['uri'],
|
||||
name=track['track']['name'],
|
||||
artists=', '.join([artist['name'] for artist in track['track']['artists']]),
|
||||
album=track['track']['album']['name']
|
||||
album=track['track']['album']['name'],
|
||||
added_at = track['added_at']
|
||||
))
|
||||
f.write('\r\n')
|
||||
logging.info('Wrote file: ' + args.file)
|
||||
|
|
Loading…
Reference in New Issue