From 641cd8841ce0714417714393c46175a59f4b4cc6 Mon Sep 17 00:00:00 2001 From: CoasterFreakDE Date: Mon, 20 Jun 2022 23:09:33 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BE=EF=B8=8F=20Added=20skip=20for=20faile?= =?UTF-8?q?d=20videos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TTS/POLLY.py | 19 +++++++++++++++++++ video_creation/data/videos.json | 3 --- 2 files changed, 19 insertions(+), 3 deletions(-) delete mode 100644 video_creation/data/videos.json diff --git a/TTS/POLLY.py b/TTS/POLLY.py index da1fae0..529e509 100644 --- a/TTS/POLLY.py +++ b/TTS/POLLY.py @@ -1,3 +1,4 @@ +import json import os import random import re @@ -8,6 +9,8 @@ from moviepy.audio.AudioClip import concatenate_audioclips, CompositeAudioClip from moviepy.audio.io.AudioFileClip import AudioFileClip from requests.exceptions import JSONDecodeError +from utils.console import print_substep + voices = [ "Brian", "Emma", @@ -58,6 +61,22 @@ class POLLY: with open(filename, "wb") as f: f.write(voice_data.content) except (KeyError, JSONDecodeError): + def save_data(): + with open("./video_creation/data/videos.json", "r+") as raw_vids: + done_vids = json.load(raw_vids) + payload = { + "id": str(os.getenv("VIDEO_ID")), + "background_credit": str(os.getenv("background_credit")), + "reddit_title": str(os.getenv("VIDEO_TITLE")), + "filename": filename, + "status": "skipped" + } + done_vids.append(payload) + raw_vids.seek(0) + json.dump(done_vids, raw_vids, ensure_ascii=False, indent=4) + + save_data() + print_substep("Error while creating video. Skipping this thread... please restart.") if response.json()["error"] == "Text length is too long!": chunks = [m.group().strip() for m in re.finditer(r" *((.{0,499})(\.|.$))", req_text)] diff --git a/video_creation/data/videos.json b/video_creation/data/videos.json deleted file mode 100644 index 1610ea1..0000000 --- a/video_creation/data/videos.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - -] \ No newline at end of file