From 91983b446e2e61a18db7a7a77f2c947ac76d5467 Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Thu, 20 Jun 2024 20:56:18 +0930 Subject: [PATCH] Unhardcode playlist filename on reload command --- add_playlist_yt_titles.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/add_playlist_yt_titles.py b/add_playlist_yt_titles.py index 68d2703..6b5924b 100755 --- a/add_playlist_yt_titles.py +++ b/add_playlist_yt_titles.py @@ -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))