Skip to content

Commit

Permalink
Merge pull request elebumm#796 from elebumm/develop
Browse files Browse the repository at this point in the history
FIX: lmao
  • Loading branch information
callumio authored Jul 2, 2022
2 parents a9e6895 + f9c7521 commit 6447a22
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions utils/videos.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import json
import os
import time
from os import getenv

from praw.models import Submission
Expand Down Expand Up @@ -31,3 +33,28 @@ def check_done(
print_step("Getting new post as the current one has already been done")
return None
return redditobj


def save_data(filename: str, reddit_title: str, reddit_id: str):
"""Saves the videos that have already been generated to a JSON file in video_creation/data/videos.json
Args:
filename (str): The finished video title name
@param filename:
@param reddit_id:
@param reddit_title:
"""
with open("./video_creation/data/videos.json", "r+", encoding="utf-8") as raw_vids:
done_vids = json.load(raw_vids)
if reddit_id in [video["id"] for video in done_vids]:
return # video already done but was specified to continue anyway in the .env file
payload = {
"id": reddit_id,
"time": str(int(time.time())),
"background_credit": str(os.getenv("background_credit")),
"reddit_title": reddit_title,
"filename": filename,
}
done_vids.append(payload)
raw_vids.seek(0)
json.dump(done_vids, raw_vids, ensure_ascii=False, indent=4)

0 comments on commit 6447a22

Please sign in to comment.