included last month in filter, added config for alarm
This commit is contained in:
parent
a379320de7
commit
a27280f5c6
22
alarm.py
22
alarm.py
@ -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,17 +33,23 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
if found:
|
if found:
|
||||||
|
|
||||||
date = datetime.datetime.now()
|
if os.path.exists(os.path.join(const.config_path, 'config.json')):
|
||||||
|
data = json.load_json(os.path.join(const.config_path, 'config.json'))
|
||||||
|
|
||||||
playlists = network.get_user_playlists()
|
date = datetime.datetime.now()
|
||||||
|
|
||||||
playlisturi = next((i.uri for i in playlists if i.name == date.strftime("%B %-y").lower()), os.environ['SPOTALARMURI'])
|
playlists = network.get_user_playlists()
|
||||||
|
|
||||||
network.play(playlisturi, network.get_device_id(os.environ['SPOTALARMDEVICENAME']))
|
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.set_shuffle(True)
|
network.play(playlisturi, network.get_device_id(data['alarm']['device_name']))
|
||||||
network.set_volume(os.environ['SPOTALARMVOLUME'])
|
|
||||||
network.next()
|
network.set_shuffle(True)
|
||||||
|
network.set_volume(data['alarm']['volume'])
|
||||||
|
network.next()
|
||||||
|
|
||||||
log.dump_log()
|
log.dump_log()
|
||||||
|
|
||||||
|
@ -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 = []
|
||||||
|
2
main.py
2
main.py
@ -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)
|
||||||
|
|
||||||
|
@ -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)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user