mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-10 06:54:21 +00:00
overlay wait
This commit is contained in:
parent
57de771ca2
commit
470b1baf0f
2 changed files with 18 additions and 1 deletions
|
@ -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.meta import Metadata
|
||||
from modules.util import Failed, ImageData
|
||||
|
@ -463,6 +463,8 @@ class Plex:
|
|||
with open(temp_image, "wb") as handler:
|
||||
handler.write(og_image)
|
||||
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 = new_poster.resize(overlay_image.size, Image.ANTIALIAS)
|
||||
new_poster.paste(overlay_image, (0, 0), overlay_image)
|
||||
|
|
|
@ -420,3 +420,18 @@ def validate_filename(filename):
|
|||
else:
|
||||
mapping_name = sanitize_filename(filename)
|
||||
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…
Reference in a new issue