Skip to content

Commit c68c580

Browse files
Merge pull request #2060 from elebumm/develop
Update 3.3.0
2 parents 340762e + 6b474b4 commit c68c580

29 files changed

+214
-119
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939

4040
steps:
4141
- name: Checkout repository
42-
uses: actions/checkout@v3
42+
uses: actions/checkout@v4
4343

4444
# Initializes the CodeQL tools for scanning.
4545
- name: Initialize CodeQL

.github/workflows/autoblack.yml renamed to .github/workflows/fmt.yml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,35 @@
33
# Othewrwise, Black is run and its changes are committed back to the incoming pull request.
44
# https://github.com/cclauss/autoblack
55

6-
name: autoblack
6+
name: fmt
77
on:
88
push:
99
branches: ["develop"]
1010
jobs:
11-
build:
11+
format:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v1
15-
- name: Set up Python 3.7
16-
uses: actions/setup-python@v1
14+
- uses: actions/checkout@v4
15+
- name: Set up Python 3.10
16+
uses: actions/setup-python@v5
1717
with:
18-
python-version: 3.9
19-
- name: Install Black
20-
run: pip install black
21-
- name: Run black --check .
22-
run: black --check .
23-
- name: If needed, commit black changes to the pull request
18+
python-version: 3.10.14
19+
- name: Install Black & isort
20+
run: pip install black isort
21+
- name: Run black check
22+
run: black --check . --line-length 101
23+
- name: Run isort check
24+
run: isort . --check-only --diff --profile black
25+
- name: If needed, commit changes to the pull request
2426
if: failure()
2527
run: |
2628
black . --line-length 101
29+
isort . --profile black
2730
git config --global user.name github-actions
2831
git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com
2932
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
3033
git checkout $GITHUB_HEAD_REF
3134
git commit -am "fixup: Format Python code with Black"
3235
git push origin HEAD:develop
36+
37+

.github/workflows/lint.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ jobs:
66
lint:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v2
9+
- uses: actions/checkout@v4
1010
- uses: psf/black@stable
1111
with:
1212
options: "--line-length 101"
13+
- uses: isort/isort-action@v1
14+
with:
15+
configuration: "--check-only --diff --profile black"

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ fabric.properties
231231
# Android studio 3.1+ serialized cache file
232232
.idea/caches/build_file_checksums.ser
233233

234-
assets/
234+
assets/temp
235+
assets/backgrounds
235236
/.vscode
236237
out
237238
.DS_Store
@@ -244,4 +245,4 @@ video_creation/data/videos.json
244245
video_creation/data/envvars.txt
245246

246247
config.toml
247-
*.exe
248+
*.exe

Dockerfile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.10.9-slim
1+
FROM python:3.10.14-slim
22

33
RUN apt update
44
RUN apt-get install -y ffmpeg
@@ -9,8 +9,4 @@ ADD . /app
99
WORKDIR /app
1010
RUN pip install -r requirements.txt
1111

12-
# tricks for pytube : https://github.com/elebumm/RedditVideoMakerBot/issues/142
13-
# (NOTE : This is no longer useful since pytube was removed from the dependencies)
14-
# RUN sed -i 's/re.compile(r"^\\w+\\W")/re.compile(r"^\\$*\\w+\\W")/' /usr/local/lib/python3.8/dist-packages/pytube/cipher.py
15-
1612
CMD ["python3", "main.py"]

GUI/settings.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@
205205
<select name="background_choice" class="form-select" data-toggle="tooltip"
206206
data-original-title='Sets the background of the video'>
207207
<option value=" ">Random Video</option>
208-
{% for background in checks["background_choice"]["options"][1:] %}
208+
{% for background in checks["background_video"]["options"][1:] %}
209209
<option value="{{background}}">{{background}}</option>
210210
{% endfor %}
211211
</select>
@@ -618,4 +618,4 @@
618618
});
619619
</script>
620620

621-
{% endblock %}
621+
{% endblock %}

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ On macOS and Linux (debian, arch, fedora and centos, and based on those), you ca
5050
This can also be used to update the installation
5151

5252
4. Run `python main.py`
53-
5. Visit [the Reddit Apps page.](https://www.reddit.com/prefs/apps), and set up an app that is a "script". Paste any URL in redirect URL. Ex:google.com
53+
5. Visit [the Reddit Apps page.](https://www.reddit.com/prefs/apps), and set up an app that is a "script". Paste any URL in redirect URL. Ex:`https://jasoncameron.dev`
5454
6. The bot will ask you to fill in your details to connect to the Reddit API, and configure the bot to your liking
5555
7. Enjoy 😎
5656
8. If you need to reconfigure the bot, simply open the `config.toml` file and delete the lines that need to be changed. On the next run of the bot, it will help you reconfigure those options.
@@ -81,7 +81,7 @@ I have tried to simplify the code so anyone can read it and start contributing a
8181

8282
Please read our [contributing guidelines](CONTRIBUTING.md) for more detailed information.
8383

84-
### For any questions or support join the [Discord](https://discord.gg/WBQT52RrHV) server
84+
### For any questions or support join the [Discord](https://discord.gg/qfQSx45xCV) server
8585

8686
## Developers and maintainers.
8787

@@ -101,6 +101,8 @@ Freebiell (Freebie#3263) - https://github.com/FreebieII
101101

102102
Aman Raza (electro199#8130) - https://github.com/electro199
103103

104+
Cyteon (cyteon) - https://github.com/cyteon
105+
104106

105107
## LICENSE
106108
[Roboto Fonts](https://fonts.google.com/specimen/Roboto/about) are licensed under [Apache License V2](https://www.apache.org/licenses/LICENSE-2.0)

TTS/TikTok.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import base64
33
import random
44
import time
5-
from typing import Optional, Final
5+
from typing import Final, Optional
66

77
import requests
88

TTS/elevenlabs.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,38 @@
11
import random
22

3-
from elevenlabs import generate, save
3+
from elevenlabs import save
4+
from elevenlabs.client import ElevenLabs
45

56
from utils import settings
67

7-
voices = [
8-
"Adam",
9-
"Antoni",
10-
"Arnold",
11-
"Bella",
12-
"Domi",
13-
"Elli",
14-
"Josh",
15-
"Rachel",
16-
"Sam",
17-
]
18-
198

209
class elevenlabs:
2110
def __init__(self):
2211
self.max_chars = 2500
23-
self.voices = voices
12+
self.client: ElevenLabs = None
2413

2514
def run(self, text, filepath, random_voice: bool = False):
15+
if self.client is None:
16+
self.initialize()
2617
if random_voice:
2718
voice = self.randomvoice()
2819
else:
2920
voice = str(settings.config["settings"]["tts"]["elevenlabs_voice_name"]).capitalize()
3021

22+
audio = self.client.generate(text=text, voice=voice, model="eleven_multilingual_v1")
23+
save(audio=audio, filename=filepath)
24+
25+
def initialize(self):
3126
if settings.config["settings"]["tts"]["elevenlabs_api_key"]:
3227
api_key = settings.config["settings"]["tts"]["elevenlabs_api_key"]
3328
else:
3429
raise ValueError(
3530
"You didn't set an Elevenlabs API key! Please set the config variable ELEVENLABS_API_KEY to a valid API key."
3631
)
3732

38-
audio = generate(api_key=api_key, text=text, voice=voice, model="eleven_multilingual_v1")
39-
save(audio=audio, filename=filepath)
33+
self.client = ElevenLabs(api_key=api_key)
4034

4135
def randomvoice(self):
42-
return random.choice(self.voices)
36+
if self.client is None:
37+
self.initialize()
38+
return random.choice(self.client.voices.get_all().voices).voice_name

TTS/engine_wrapper.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@
1414
from utils.console import print_step, print_substep
1515
from utils.voice import sanitize_text
1616

17-
1817
DEFAULT_MAX_LENGTH: int = (
1918
50 # Video length variable, edit this on your own risk. It should work, but it's not supported
2019
)
2120

2221

2322
class TTSEngine:
24-
2523
"""Calls the given TTS engine to reduce code duplication and allow multiple TTS engines.
2624
2725
Args:

TTS/streamlabs_polly.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ def run(self, text, filepath, random_voice: bool = False):
4343
f"Please set the config variable STREAMLABS_POLLY_VOICE to a valid voice. options are: {voices}"
4444
)
4545
voice = str(settings.config["settings"]["tts"]["streamlabs_polly_voice"]).capitalize()
46+
4647
body = {"voice": voice, "text": text, "service": "polly"}
4748
headers = {"Referer": "https://streamlabs.com/"}
4849
response = requests.post(self.url, headers=headers, data=body)
50+
4951
if not check_ratelimit(response):
5052
self.run(text, filepath, random_voice)
5153

assets/title_template.png

50.3 KB
Loading

main.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@
77
from typing import NoReturn
88

99
from prawcore import ResponseException
10-
from utils.console import print_substep
10+
1111
from reddit.subreddit import get_subreddit_threads
1212
from utils import settings
1313
from utils.cleanup import cleanup
14-
from utils.console import print_markdown, print_step
14+
from utils.console import print_markdown, print_step, print_substep
15+
from utils.ffmpeg_install import ffmpeg_install
1516
from utils.id import id
1617
from utils.version import checkversion
1718
from video_creation.background import (
18-
download_background_video,
19-
download_background_audio,
2019
chop_background,
20+
download_background_audio,
21+
download_background_video,
2122
get_background_config,
2223
)
2324
from video_creation.final_video import make_final_video
2425
from video_creation.screenshot_downloader import get_screenshots_of_reddit_posts
2526
from video_creation.voices import save_text_to_mp3
26-
from utils.ffmpeg_install import ffmpeg_install
2727

28-
__VERSION__ = "3.2.1"
28+
__VERSION__ = "3.3.0"
2929

3030
print(
3131
"""
@@ -37,7 +37,6 @@
3737
╚═╝ ╚═╝╚══════╝╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
3838
"""
3939
)
40-
# Modified by JasonLovesDoggo
4140
print_markdown(
4241
"### Thanks for using this tool! Feel free to contribute to this project on GitHub! If you have any questions, feel free to join my Discord server or submit a GitHub issue. You can find solutions to many common problems in the documentation: https://reddit-video-maker-bot.netlify.app/"
4342
)

reddit/subreddit.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
import re
22

3-
from prawcore.exceptions import ResponseException
4-
5-
from utils import settings
63
import praw
74
from praw.models import MoreComments
85
from prawcore.exceptions import ResponseException
96

7+
from utils import settings
8+
from utils.ai_methods import sort_by_similarity
109
from utils.console import print_step, print_substep
10+
from utils.posttextparser import posttextparser
1111
from utils.subreddit import get_subreddit_undone
1212
from utils.videos import check_done
1313
from utils.voice import sanitize_text
14-
from utils.posttextparser import posttextparser
15-
from utils.ai_methods import sort_by_similarity
1614

1715

1816
def get_subreddit_threads(POST_ID: str):
@@ -106,7 +104,7 @@ def get_subreddit_threads(POST_ID: str):
106104
upvotes = submission.score
107105
ratio = submission.upvote_ratio * 100
108106
num_comments = submission.num_comments
109-
threadurl = f"https://reddit.com{submission.permalink}"
107+
threadurl = f"https://new.reddit.com/{submission.permalink}"
110108

111109
print_substep(f"Video will be: {submission.title} :thumbsup:", style="bold green")
112110
print_substep(f"Thread url is: {threadurl} :thumbsup:", style="bold green")

requirements.txt

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
boto3==1.26.142
2-
botocore==1.29.142
3-
gTTS==2.3.2
1+
boto3==1.34.127
2+
botocore==1.34.127
3+
gTTS==2.5.1
44
moviepy==1.0.3
5-
playwright==1.34.0
6-
praw==7.7.0
5+
playwright==1.44.0
6+
praw==7.7.1
77
prawcore~=2.3.0
8-
requests==2.31.0
9-
rich==13.4.1
8+
requests==2.32.3
9+
rich==13.7.1
1010
toml==0.10.2
11-
translators==5.7.6
11+
translators==5.9.2
1212
pyttsx3==2.90
13-
Pillow==9.5.0
14-
tomlkit==0.11.8
15-
Flask==2.3.3
13+
Pillow==10.3.0
14+
tomlkit==0.12.5
15+
Flask==3.0.3
1616
clean-text==0.6.0
17-
unidecode==1.3.6
18-
spacy==3.5.3
19-
torch==2.0.1
20-
transformers==4.29.2
17+
unidecode==1.3.8
18+
spacy==3.7.5
19+
torch==2.3.1
20+
transformers==4.41.2
2121
ffmpeg-python==0.2.0
22-
elevenlabs==0.2.17
23-
yt-dlp==2023.7.6
22+
elevenlabs==1.3.0
23+
yt-dlp==2024.5.27
24+
numpy==1.26.4

utils/.config.template.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ storymode_max_length = { optional = true, default = 1000, example = 1000, explan
3131
resolution_w = { optional = false, default = 1080, example = 1440, explantation = "Sets the width in pixels of the final video" }
3232
resolution_h = { optional = false, default = 1920, example = 2560, explantation = "Sets the height in pixels of the final video" }
3333
zoom = { optional = true, default = 1, example = 1.1, explanation = "Sets the browser zoom level. Useful if you want the text larger.", type = "float", nmin = 0.1, nmax = 2, oob_error = "The text is really difficult to read at a zoom level higher than 2" }
34+
channel_name = { optional = true, default = "Reddit Tales", example = "Reddit Stories", explanation = "Sets the channel name for the video" }
3435

3536
[settings.background]
3637
background_video = { optional = true, default = "minecraft", example = "rocket-league", options = ["minecraft", "gta", "rocket-league", "motor-gta", "csgo-surf", "cluster-truck", "minecraft-2","multiversus","fall-guys","steep", ""], explanation = "Sets the background for the video based on game name" }
@@ -44,7 +45,7 @@ background_thumbnail_font_color = { optional = true, default = "255,255,255", ex
4445

4546
[settings.tts]
4647
voice_choice = { optional = false, default = "tiktok", options = ["elevenlabs", "streamlabspolly", "tiktok", "googletranslate", "awspolly", "pyttsx", ], example = "tiktok", explanation = "The voice platform used for TTS generation. " }
47-
random_voice = { optional = false, default = true, example = true, type = "bool", options = [true, false,], explanation = "Randomizes the voice used for each comment" }
48+
random_voice = { optional = false, type = "bool", default = true, example = true, options = [true, false,], explanation = "Randomizes the voice used for each comment" }
4849
elevenlabs_voice_name = { optional = false, default = "Bella", example = "Bella", explanation = "The voice used for elevenlabs", options = ["Adam", "Antoni", "Arnold", "Bella", "Domi", "Elli", "Josh", "Rachel", "Sam", ] }
4950
elevenlabs_api_key = { optional = true, example = "21f13f91f54d741e2ae27d2ab1b99d59", explanation = "Elevenlabs API key" }
5051
aws_polly_voice = { optional = false, default = "Matthew", example = "Matthew", explanation = "The voice used for AWS Polly" }

utils/ai_methods.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import numpy as np
2-
from transformers import AutoTokenizer, AutoModel
32
import torch
3+
from transformers import AutoModel, AutoTokenizer
44

55

66
# Mean Pooling - Take attention mask into account for correct averaging

utils/cleanup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
2-
from os.path import exists
32
import shutil
3+
from os.path import exists
44

55

66
def _listdir(d): # listdir with full path

0 commit comments

Comments
 (0)