2019-06-11 11:59:24 +01:00
|
|
|
from spotframework.net.user import User
|
|
|
|
from spotframework.net.network import Network
|
2019-02-28 07:49:52 +00:00
|
|
|
import spotframework.io.csv as csvwrite
|
2019-05-14 12:39:17 +01:00
|
|
|
import spotframework.log.log as log
|
2019-02-28 07:49:52 +00:00
|
|
|
|
2019-05-14 12:39:17 +01:00
|
|
|
import sys
|
|
|
|
import datetime
|
|
|
|
import os
|
2019-03-04 21:31:32 +00:00
|
|
|
|
2019-02-28 07:49:52 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
|
2019-05-14 13:05:25 +01:00
|
|
|
try:
|
2019-05-08 22:41:47 +01:00
|
|
|
|
2019-08-02 12:02:24 +01:00
|
|
|
network = Network(User(os.environ['SPOTCLIENT'],
|
|
|
|
os.environ['SPOTSECRET'],
|
|
|
|
os.environ['SPOTACCESS'],
|
|
|
|
os.environ['SPOTREFRESH']))
|
2019-06-11 11:59:24 +01:00
|
|
|
playlists = network.get_user_playlists()
|
2019-03-04 22:45:58 +00:00
|
|
|
|
2019-05-14 13:05:25 +01:00
|
|
|
for playlist in playlists:
|
2019-06-11 11:59:24 +01:00
|
|
|
playlist.tracks = network.get_playlist_tracks(playlist.playlistid)
|
2019-02-28 07:49:52 +00:00
|
|
|
|
2019-05-14 13:05:25 +01:00
|
|
|
path = sys.argv[1]
|
2019-05-14 12:39:17 +01:00
|
|
|
|
2019-05-14 13:05:25 +01:00
|
|
|
datepath = str(datetime.datetime.now()).split(' ')[0].replace('-', '/')
|
|
|
|
|
|
|
|
totalpath = os.path.join(path, datepath)
|
|
|
|
pathdir = os.path.dirname(totalpath)
|
|
|
|
if not os.path.exists(totalpath):
|
|
|
|
os.makedirs(totalpath)
|
|
|
|
|
|
|
|
for play in playlists:
|
2019-06-11 11:59:24 +01:00
|
|
|
csvwrite.export_playlist(play, totalpath)
|
2019-05-14 13:05:25 +01:00
|
|
|
|
2019-06-11 11:59:24 +01:00
|
|
|
log.dump_log()
|
2019-05-14 13:05:25 +01:00
|
|
|
|
|
|
|
except:
|
2019-06-11 11:59:24 +01:00
|
|
|
log.dump_log()
|