This commit is contained in:
Benedetta 2024-03-25 15:13:36 +01:00
parent 83dc57e070
commit a7fc4ee2ce
2 changed files with 19 additions and 8 deletions

View file

@ -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)

11
jellyfin-fml/readme.md Normal file
View file

@ -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"
```