avoid already finished threads from as requested from #225

pull/280/head
iaacornus 3 years ago
parent c85d1c77cb
commit 1f4c1835ac
No known key found for this signature in database
GPG Key ID: 281739AE7252598C

@ -3,6 +3,7 @@ import shutil
from dotenv import load_dotenv
import reddit.subreddit
from reddit.subreddit import get_subreddit_threads
from video_creation.background import download_background, chop_background_video
from video_creation.voices import save_text_to_mp3
@ -62,6 +63,10 @@ def main(subreddit_=None, background=None, filename=None, thread_link_=None):
download_background(background)
chop_background_video(length)
make_final_video(number_of_comments, filename)
with open("created_videos", "a", encoding="utf-8") as video_lists:
video_lists.write(reddit.subreddit.submission.title)
return True
print_substep(

@ -65,6 +65,10 @@ def get_subreddit_threads(subreddit_, thread_link_):
# If the user specifies that he doesnt want a random thread, or if
# he doesn't insert the "RANDOM_THREAD" variable at all, ask the thread link
while True:
with open("created_videos", "r", encoding="utf-8") as reference:
videos = list(reference.readlines())
if thread_link_ is not None:
thread_link = thread_link_
print_step("Getting the inserted thread...")
@ -87,6 +91,15 @@ def get_subreddit_threads(subreddit_, thread_link_):
threads = subreddit.hot(limit=25)
submission = list(threads)[random.randrange(0, 25)]
if submission.title in videos:
print_substep(
"[bold]There is already a video for thread: [cyan]"
+ f"{submission.title}[/cyan]. Finding another one.[/bold]"
)
continue
break
print_substep(f"Video will be: [cyan]{submission.title}[/cyan] :thumbsup:")
try:

Loading…
Cancel
Save