lock on tautulli send entry
This commit is contained in:
parent
6c30a47ce5
commit
cd0870d0b3
|
@ -34,32 +34,39 @@ def load_tautulli():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
plexpy = load_tautulli()
|
plexpy = load_tautulli()
|
||||||
|
send_entry_lock = asyncio.Lock()
|
||||||
|
|
||||||
async def send_entry(bot, room, entry):
|
async def send_entry(bot, room, entry):
|
||||||
if "art" in entry:
|
global send_entry_lock
|
||||||
global plexpy
|
async with send_entry_lock:
|
||||||
if plexpy:
|
if "art" in entry:
|
||||||
pms = plexpy.pmsconnect.PmsConnect()
|
global plexpy
|
||||||
(image0, image1) = pms.get_image(entry["art"], 600, 300)
|
if plexpy:
|
||||||
matrix_uri = await bot.upload_and_send_image(room, image0, "", True, image1)
|
pms = plexpy.pmsconnect.PmsConnect()
|
||||||
|
pms_image = pms.get_image(entry["art"], 600, 300)
|
||||||
|
if not pms_image:
|
||||||
|
return
|
||||||
|
|
||||||
if matrix_uri is not None:
|
(blob, content_type) = pms_image
|
||||||
await bot.send_image(room, matrix_uri, "")
|
matrix_uri = await bot.upload_and_send_image(room, blob, "", True, content_type)
|
||||||
|
|
||||||
fmt_params = {
|
|
||||||
"title": entry["title"],
|
|
||||||
"year": entry["year"],
|
|
||||||
"audience_rating": entry["audience_rating"],
|
|
||||||
"directors": ", ".join(entry["directors"]),
|
|
||||||
"actors": ", ".join(entry["actors"]),
|
|
||||||
"summary": entry["summary"],
|
|
||||||
"tagline": entry["tagline"],
|
|
||||||
"genres": ", ".join(entry["genres"])
|
|
||||||
}
|
|
||||||
|
|
||||||
await bot.send_html(room,
|
if matrix_uri is not None:
|
||||||
msg_template_html.format(**fmt_params),
|
await bot.send_image(room, matrix_uri, "")
|
||||||
msg_template_plain.format(**fmt_params))
|
|
||||||
|
fmt_params = {
|
||||||
|
"title": entry["title"],
|
||||||
|
"year": entry["year"],
|
||||||
|
"audience_rating": entry["audience_rating"],
|
||||||
|
"directors": ", ".join(entry["directors"]),
|
||||||
|
"actors": ", ".join(entry["actors"]),
|
||||||
|
"summary": entry["summary"],
|
||||||
|
"tagline": entry["tagline"],
|
||||||
|
"genres": ", ".join(entry["genres"])
|
||||||
|
}
|
||||||
|
|
||||||
|
await bot.send_html(room,
|
||||||
|
msg_template_html.format(**fmt_params),
|
||||||
|
msg_template_plain.format(**fmt_params))
|
||||||
|
|
||||||
msg_template_html = """
|
msg_template_html = """
|
||||||
<b>{title} -({year})- Rating: {audience_rating}</b><br>
|
<b>{title} -({year})- Rating: {audience_rating}</b><br>
|
||||||
|
|
Loading…
Reference in New Issue