Unhardcode playlist filename on reload command
This commit is contained in:
parent
ca48a78ee6
commit
91983b446e
|
@ -6,7 +6,7 @@ import urllib.request
|
|||
import json
|
||||
import socket
|
||||
yt_api_key = 'get your own lol'
|
||||
filename = '/home/luke/mpv-playlist.m3u'
|
||||
playlist_filename = '/home/luke/mpv-playlist.m3u'
|
||||
mpv_socket = '/home/luke/socket-mpv'
|
||||
|
||||
SI_large_prefixes = { # Extend if necessary
|
||||
|
@ -199,14 +199,14 @@ def process_playlist(filename: str):
|
|||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
process_playlist(filename)
|
||||
process_playlist(playlist_filename)
|
||||
except BaseException as e:
|
||||
logging.error('Error processing: {}'.format(e))
|
||||
try:
|
||||
logging.info('Reloading playlist on mpv')
|
||||
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as sock:
|
||||
sock.connect(mpv_socket)
|
||||
sock.sendall(b'playlist-clear; loadlist /home/luke/mpv-playlist.m3u append\n')
|
||||
sock.sendall(f'playlist-clear; loadlist "{playlist_filename}" append\n'.encode())
|
||||
logging.info('mpv playlist reloaded!')
|
||||
except BaseException as e:
|
||||
logging.error('Error reloading playlist: {}'.format(e))
|
||||
|
|
Loading…
Reference in New Issue