included last month in filter, added config for alarm

This commit is contained in:
aj 2019-06-28 10:50:59 +01:00
parent a379320de7
commit a27280f5c6
4 changed files with 23 additions and 11 deletions

View File

@ -1,6 +1,8 @@
from spotframework.net.user import User from spotframework.net.user import User
from spotframework.net.network import Network from spotframework.net.network import Network
import spotframework.log.log as log import spotframework.log.log as log
import spotframework.net.const as const
import spotframework.io.json as json
import os import os
import datetime import datetime
@ -31,16 +33,22 @@ if __name__ == '__main__':
if found: if found:
if os.path.exists(os.path.join(const.config_path, 'config.json')):
data = json.load_json(os.path.join(const.config_path, 'config.json'))
date = datetime.datetime.now() date = datetime.datetime.now()
playlists = network.get_user_playlists() playlists = network.get_user_playlists()
playlisturi = next((i.uri for i in playlists if i.name == date.strftime("%B %-y").lower()), os.environ['SPOTALARMURI']) if data['alarm']['use_month']:
playlisturi = next((i.uri for i in playlists if i.name == date.strftime("%B %-y").lower()), data['alarm']['uri'])
else:
playlisturi = data['alarm']['uri']
network.play(playlisturi, network.get_device_id(os.environ['SPOTALARMDEVICENAME'])) network.play(playlisturi, network.get_device_id(data['alarm']['device_name']))
network.set_shuffle(True) network.set_shuffle(True)
network.set_volume(os.environ['SPOTALARMVOLUME']) network.set_volume(data['alarm']['volume'])
network.next() network.next()
log.dump_log() log.dump_log()

View File

@ -58,6 +58,10 @@ def update_recents_playlist(engine, data):
if 'playlists' in data['recents']: if 'playlists' in data['recents']:
recent_parts += data['recents']['playlists'] recent_parts += data['recents']['playlists']
if 'exclude' in data['recents']:
for exclusion in data['recents']['exclude']:
recent_parts.remove(exclusion)
processors = [DeduplicateByName(), SortReverseReleaseDate()] processors = [DeduplicateByName(), SortReverseReleaseDate()]
recent_tracks = engine.get_recent_playlist(boundary_date, recent_parts, processors) recent_tracks = engine.get_recent_playlist(boundary_date, recent_parts, processors)
@ -68,9 +72,9 @@ def update_recents_playlist(engine, data):
def go(): def go():
try: try:
if os.path.exists(os.path.join(const.config_path, 'playlists.json')): if os.path.exists(os.path.join(const.config_path, 'config.json')):
data = json.load_json(os.path.join(const.config_path, 'playlists.json')) data = json.load_json(os.path.join(const.config_path, 'config.json'))
to_execute = [] to_execute = []
not_found = [] not_found = []

View File

@ -7,7 +7,7 @@ import spotframework.io.json as json
if __name__ == '__main__': if __name__ == '__main__':
print('hello world') print('hello world')
# data = json.loadJson('.spot/playlists.json') # data = json.loadJson('.spot/config.json')
# print(data) # print(data)

View File

@ -58,7 +58,7 @@ class PlaylistEngine:
this_month = monthstrings.get_this_month() this_month = monthstrings.get_this_month()
last_month = monthstrings.get_last_month() last_month = monthstrings.get_last_month()
datefilter = AddedSince(boundary_date, recent_playlist_parts) datefilter = AddedSince(boundary_date, recent_playlist_parts + [last_month])
processors.append(datefilter) processors.append(datefilter)