overlay wait

pull/322/head
meisnate12 3 years ago
parent 57de771ca2
commit 470b1baf0f

@ -1,4 +1,4 @@
import glob, logging, os, plexapi, requests, shutil import glob, logging, os, plexapi, requests, shutil, time
from modules import builder, util from modules import builder, util
from modules.meta import Metadata from modules.meta import Metadata
from modules.util import Failed, ImageData from modules.util import Failed, ImageData
@ -463,6 +463,8 @@ class Plex:
with open(temp_image, "wb") as handler: with open(temp_image, "wb") as handler:
handler.write(og_image) handler.write(og_image)
shutil.copyfile(temp_image, os.path.join(overlay_folder, f"{item.ratingKey}.png")) shutil.copyfile(temp_image, os.path.join(overlay_folder, f"{item.ratingKey}.png"))
while util.is_locked(temp_image):
time.sleep(1)
new_poster = Image.open(temp_image) new_poster = Image.open(temp_image)
new_poster = new_poster.resize(overlay_image.size, Image.ANTIALIAS) new_poster = new_poster.resize(overlay_image.size, Image.ANTIALIAS)
new_poster.paste(overlay_image, (0, 0), overlay_image) new_poster.paste(overlay_image, (0, 0), overlay_image)

@ -420,3 +420,18 @@ def validate_filename(filename):
else: else:
mapping_name = sanitize_filename(filename) mapping_name = sanitize_filename(filename)
return mapping_name, f"Log Folder Name: {filename} is invalid using {mapping_name}" return mapping_name, f"Log Folder Name: {filename} is invalid using {mapping_name}"
def is_locked(filepath):
locked = None
file_object = None
if os.path.exists(filepath):
try:
file_object = open(filepath, 'a', 8)
if file_object:
locked = False
except IOError as message:
locked = True
finally:
if file_object:
file_object.close()
return locked

Loading…
Cancel
Save