Update subgen.py
This commit is contained in:
@@ -40,7 +40,7 @@ def receive_webhook():
|
|||||||
payload = json.loads(request.form['payload'])
|
payload = json.loads(request.form['payload'])
|
||||||
event = payload.get("event")
|
event = payload.get("event")
|
||||||
if ((event == "library.new" or event == "added") and procaddedmedia) or ((event == "media.play" or event == "played") and procmediaonplay):
|
if ((event == "library.new" or event == "added") and procaddedmedia) or ((event == "media.play" or event == "played") and procmediaonplay):
|
||||||
fullpath = None
|
|
||||||
if event == "library.new" or event == "media.play": # these are the plex webhooks!
|
if event == "library.new" or event == "media.play": # these are the plex webhooks!
|
||||||
print("Plex webhook received!")
|
print("Plex webhook received!")
|
||||||
metadata = payload.get("Metadata")
|
metadata = payload.get("Metadata")
|
||||||
@@ -59,29 +59,29 @@ def receive_webhook():
|
|||||||
print("file name with no extension: " + filenamenoextension)
|
print("file name with no extension: " + filenamenoextension)
|
||||||
print("event: " + event)
|
print("event: " + event)
|
||||||
|
|
||||||
if skipifinternalsublang in str(subprocess.check_output("ffprobe -loglevel error -select_streams s -show_entries stream=index:stream_tags=language -of csv=p=0 \"{}\"".format(fullpath), shell=True)):
|
if skipifinternalsublang in str(subprocess.check_output("ffprobe -loglevel error -select_streams s -show_entries stream=index:stream_tags=language -of csv=p=0 \"{}\"".format(fullpath), shell=True)):
|
||||||
print("File already has an internal sub we want, skipping generation")
|
print("File already has an internal sub we want, skipping generation")
|
||||||
return "File already has an internal sub we want, skipping generation"
|
return "File already has an internal sub we want, skipping generation"
|
||||||
elif os.path.isfile("{}.output.wav".format(fullpath)):
|
elif os.path.isfile("{}.output.wav".format(fullpath)):
|
||||||
print("WAV file already exists, we're assuming it's processing and skipping it")
|
print("WAV file already exists, we're assuming it's processing and skipping it")
|
||||||
return "WAV file already exists, we're assuming it's processing and skipping it"
|
return "WAV file already exists, we're assuming it's processing and skipping it"
|
||||||
elif len(glob.glob("{}/{}*subgen*".format(filepath, filenamenoextension))) > 0:
|
elif len(glob.glob("{}/{}*subgen*".format(filepath, filenamenoextension))) > 0:
|
||||||
print("We already have a subgen created for this file, skipping it")
|
print("We already have a subgen created for this file, skipping it")
|
||||||
return "We already have a subgen created for this file, skipping it"
|
return "We already have a subgen created for this file, skipping it"
|
||||||
|
|
||||||
if whisper_speedup:
|
if whisper_speedup:
|
||||||
print("This is a speedup run!")
|
print("This is a speedup run!")
|
||||||
print(whisper_speedup)
|
print(whisper_speedup)
|
||||||
finalsubname = "{0}/{1}.subgen.{2}.speedup.{3}".format(filepath, filenamenoextension, whisper_model, namesublang)
|
finalsubname = "{0}/{1}.subgen.{2}.speedup.{3}".format(filepath, filenamenoextension, whisper_model, namesublang)
|
||||||
else:
|
else:
|
||||||
print("No speedup")
|
print("No speedup")
|
||||||
finalsubname = "{0}/{1}.subgen.{2}.{3}".format(filepath, filenamenoextension, whisper_model, namesublang)
|
finalsubname = "{0}/{1}.subgen.{2}.{3}".format(filepath, filenamenoextension, whisper_model, namesublang)
|
||||||
|
|
||||||
gen_subtitles(fullpath, "{}.output.wav".format(fullpath), finalsubname)
|
gen_subtitles(fullpath, "{}.output.wav".format(fullpath), finalsubname)
|
||||||
|
|
||||||
if os.path.isfile("{}.output.wav".format(fullpath)):
|
if os.path.isfile("{}.output.wav".format(fullpath)):
|
||||||
print("Deleting WAV workfile")
|
print("Deleting WAV workfile")
|
||||||
os.remove("{}.output.wav".format(fullpath))
|
os.remove("{}.output.wav".format(fullpath))
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user