diff --git a/jellyfin-fml/main.py b/jellyfin-fml/main.py index bd25800..8ee91c0 100644 --- a/jellyfin-fml/main.py +++ b/jellyfin-fml/main.py @@ -8,7 +8,8 @@ def read_conf(): conf = tomllib.load(fp) return (conf['configuration']['mq_host'], conf['configuration']['mq_user'], - conf['configuration']['mq_password']) + conf['configuration']['mq_password'], + conf['configuration']['matrix_room']) def remaining_space_gb(): @@ -37,7 +38,7 @@ def pop(files): return None -def send_to_mq(mq_host, mq_user, mq_pass, space_rem, transcode_space): +def send_to_mq(mq_host, mq_user, mq_pass, matrix_room, space_rem, transcode_space): import pika import json creds = pika.PlainCredentials(mq_user, mq_pass) @@ -47,12 +48,11 @@ def send_to_mq(mq_host, mq_user, mq_pass, space_rem, transcode_space): space_rem = round(space_rem, 2) msg = f'Paperino, manca spazio su disco: {space_rem}|{transcode_space}' - ROOM_ID = '!KABwGlTSmXAbzCOhCX:goulash.lezzo.org' response = { 'content': msg, 'source_message_id': None, - 'room_id': ROOM_ID, + 'room_id': matrix_room, 'as_reply': False, 'as_markdown': False, } @@ -63,7 +63,7 @@ def send_to_mq(mq_host, mq_user, mq_pass, space_rem, transcode_space): conn.close() -def main(mq_host, mq_user, mq_pass): +def main(mq_host, mq_user, mq_pass, matrix_room): while True: space_rem = remaining_space_gb() @@ -72,7 +72,7 @@ def main(mq_host, mq_user, mq_pass): else: files = all_transcodes() total_space = sum(map(lambda t: t[2], files)) - send_to_mq(mq_host, mq_user, mq_pass, space_rem, total_space) + send_to_mq(mq_host, mq_user, mq_pass, matrix_room, space_rem, total_space) while remaining_space_gb() < 2.0: file = pop(files) @@ -84,5 +84,5 @@ def main(mq_host, mq_user, mq_pass): if __name__ == '__main__': - mq_host, mq_user, mq_pass = read_conf() - main(mq_host, mq_user, mq_pass) + mq_host, mq_user, mq_pass, matrix_room = read_conf() + main(mq_host, mq_user, mq_pass, matrix_room) diff --git a/jellyfin-fml/readme.md b/jellyfin-fml/readme.md new file mode 100644 index 0000000..9066eb6 --- /dev/null +++ b/jellyfin-fml/readme.md @@ -0,0 +1,11 @@ +# Configuration +example: +``` +user ~> cat /etc/jellyfin-fml.toml +[configuration] +mq_host = "example.org" +mq_user = "jellyfin-fml" +mq_password = "SUPA SECRET" +matrix_room = "!KABwGlTSmXAbzCOhCX:matrix.example.org" + +```