diff --git a/.github/workflows/autoblack.yml b/.github/workflows/autoblack.yml new file mode 100644 index 0000000..ba9cc36 --- /dev/null +++ b/.github/workflows/autoblack.yml @@ -0,0 +1,32 @@ +# GitHub Action that uses Black to reformat the Python code in an incoming pull request. +# If all Python code in the pull request is compliant with Black then this Action does nothing. +# Othewrwise, Black is run and its changes are committed back to the incoming pull request. +# https://github.com/cclauss/autoblack + +name: autoblack +on: + push: + branches: ["master"] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.9 + - name: Install Black + run: pip install black + - name: Run black --check . + run: black --check . + - name: If needed, commit black changes to the pull request + if: failure() + run: | + black . --line-length 101 + git config --global user.name 'autoblack' + git config --global user.email 'jasoncameron.all@gmail.com' + git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY + git checkout $GITHUB_HEAD_REF + git commit -am "fixup: Format Python code with Black" + git push diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0ca5c5d..f95531f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,30 +1,12 @@ -# GitHub Action that uses Black to reformat the Python code in an incoming pull request. -# If all Python code in the pull request is compliant with Black then this Action does nothing. -# Othewrwise, Black is run and its changes are committed back to the incoming pull request. -# https://github.com/cclauss/autoblack +name: Lint + +on: [pull_request] -name: autoblack -on: [pull_request, workflow_dispatch] jobs: - build: + lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - name: Set up Python 3.7 - uses: actions/setup-python@v1 + - uses: actions/checkout@v2 + - uses: psf/black@stable with: - python-version: 3.9 - - name: Install Black - run: pip install black - - name: Run black --check . - run: black --check . - - name: If needed, commit black changes to the pull request - if: failure() - run: | - black . --line-length 101 - git config --global user.name 'autoblack' - git config --global user.email 'jasoncameron.all@gmail.com' - git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY - git checkout $GITHUB_HEAD_REF - git commit -am "fixup: Format Python code with Black" - git push + options: "--line-length 101" diff --git a/reddit/subreddit.py b/reddit/subreddit.py index 8365d04..b64a52a 100644 --- a/reddit/subreddit.py +++ b/reddit/subreddit.py @@ -72,7 +72,7 @@ def get_subreddit_threads(POST_ID: str): threads = subreddit.hot(limit=25) submission = get_subreddit_undone(threads, subreddit) submission = check_done(submission) # double-checking - if submission is None: + if submission is None or not submission.num_comments: return get_subreddit_threads(POST_ID) # submission already done. rerun upvotes = submission.score ratio = submission.upvote_ratio * 100 diff --git a/utils/videos.py b/utils/videos.py index d050ab8..4a91e8c 100755 --- a/utils/videos.py +++ b/utils/videos.py @@ -34,11 +34,12 @@ def check_done( return redditobj -def save_data(filename: str, reddit_title: str, reddit_id: str, credit: str): +def save_data(subreddit: str, filename: str, reddit_title: str, reddit_id: str, credit: 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 subreddit: @param filename: @param reddit_id: @param reddit_title: @@ -48,6 +49,7 @@ def save_data(filename: str, reddit_title: str, reddit_id: str, credit: str): if reddit_id in [video["id"] for video in done_vids]: return # video already done but was specified to continue anyway in the config file payload = { + "subreddit": subreddit, "id": reddit_id, "time": str(int(time.time())), "background_credit": credit, diff --git a/video_creation/final_video.py b/video_creation/final_video.py index d514703..920f11b 100755 --- a/video_creation/final_video.py +++ b/video_creation/final_video.py @@ -116,7 +116,7 @@ def make_final_video( filename = f"{name_normalize(title)}.mp4" subreddit = settings.config["reddit"]["thread"]["subreddit"] - save_data(filename, title, idx, background_config[2]) + save_data(subreddit, filename, title, idx, background_config[2]) if not exists(f"./results/{subreddit}"): print_substep("The results folder didn't exist so I made it")