Merge branch 'master' into master
This commit is contained in:
6 files changed
+42
-11
No files matched your search
+5
-1
@@ -2,5 +2,9 @@ REDDIT_CLIENT_ID=""
|
||||
REDDIT_CLIENT_SECRET=""
|
||||
REDDIT_USERNAME=""
|
||||
REDDIT_PASSWORD=""
|
||||
|
||||
# Valid options are "yes" and "no" for the variable below
|
||||
REDDIT_2FA=""
|
||||
REDDIT_2FA=""
|
||||
|
||||
|
||||
SUBREDDIT=""
|
||||
@@ -33,18 +33,19 @@ These videos on TikTok, YouTube and Instagram get MILLIONS of views across all p
|
||||
1. Clone this repository
|
||||
2. Rename `.env.template` to `.env` and replace all values with the appropriate fields. To get Reddit keys (**required**), visit [the Reddit Apps page.](https://www.reddit.com/prefs/apps) TL;DR set up an app that is a "script". Copy your keys into the `.env` file, along with whether your account uses two-factor authentication.
|
||||
3. Run `pip3 install -r requirements.txt`
|
||||
4. Run `python3 main.py`
|
||||
5. ...
|
||||
6. Enjoy 😎
|
||||
4. Run `playwright install` and `playwright install-deps`.
|
||||
5. Run `python3 main.py`
|
||||
6. ...
|
||||
7. Enjoy 😎
|
||||
|
||||
## Contributing & Ways to improve 📈
|
||||
|
||||
In its current state, this bot does exactly what it needs to do. However, lots of improvements can be made.
|
||||
|
||||
I have tried to simplify the code so anyone can read it and start contibuting at any skill level. Don't be shy :) contribute!
|
||||
I have tried to simplify the code so anyone can read it and start contributing at any skill level. Don't be shy :) contribute!
|
||||
|
||||
- [ ] Allowing users to choose a reddit thread instead of being randomized.
|
||||
- [ ] Allowing users to choose a background that is picked instead of the Minecraft one.
|
||||
- [ ] Allowing users to choose between any subreddit.
|
||||
- [x] Allowing users to choose between any subreddit.
|
||||
- [ ] Allowing users to change voice.
|
||||
- [ ] Creating better documentation and adding a command line interface.
|
||||
@@ -1,6 +1,7 @@
|
||||
from utils.console import print_markdown
|
||||
import time
|
||||
from reddit.subreddit import get_askreddit_threads
|
||||
|
||||
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
|
||||
from video_creation.screenshot_downloader import download_screenshots_of_reddit_posts
|
||||
@@ -13,7 +14,7 @@ print_markdown(
|
||||
time.sleep(3)
|
||||
|
||||
|
||||
reddit_object = get_askreddit_threads()
|
||||
reddit_object = get_subreddit_threads()
|
||||
|
||||
length, number_of_comments = save_text_to_mp3(reddit_object)
|
||||
download_screenshots_of_reddit_posts(reddit_object, number_of_comments)
|
||||
|
||||
+22
-1
@@ -5,11 +5,14 @@ from dotenv import load_dotenv
|
||||
import os
|
||||
|
||||
|
||||
def get_askreddit_threads():
|
||||
|
||||
def get_subreddit_threads():
|
||||
|
||||
"""
|
||||
Returns a list of threads from the AskReddit subreddit.
|
||||
"""
|
||||
|
||||
|
||||
load_dotenv()
|
||||
|
||||
print_step("Getting AskReddit threads...")
|
||||
@@ -26,6 +29,7 @@ def get_askreddit_threads():
|
||||
passkey = os.getenv("REDDIT_PASSWORD")
|
||||
|
||||
content = {}
|
||||
|
||||
reddit = praw.Reddit(
|
||||
client_id=os.getenv("REDDIT_CLIENT_ID"),
|
||||
client_secret=os.getenv("REDDIT_CLIENT_SECRET"),
|
||||
@@ -37,6 +41,22 @@ def get_askreddit_threads():
|
||||
threads = askreddit.hot(limit=25)
|
||||
submission = list(threads)[random.randrange(0, 25)]
|
||||
print_substep(f"Video will be: {submission.title}")
|
||||
|
||||
if os.getenv("SUBREDDIT"):
|
||||
subreddit = reddit.subreddit(os.getenv("SUBREDDIT"))
|
||||
else:
|
||||
# ! Prompt the user to enter a subreddit
|
||||
try:
|
||||
subreddit = reddit.subreddit(
|
||||
input("What subreddit would you like to pull from? ")
|
||||
)
|
||||
except ValueError:
|
||||
subreddit = reddit.subreddit("askreddit")
|
||||
print_substep("Subreddit not defined. Using AskReddit.")
|
||||
|
||||
threads = subreddit.hot(limit=25)
|
||||
submission = list(threads)[random.randrange(0, 25)]
|
||||
print_substep(f"Video will be: {submission.title} :thumbsup:")
|
||||
try:
|
||||
|
||||
content["thread_url"] = submission.url
|
||||
@@ -55,4 +75,5 @@ def get_askreddit_threads():
|
||||
except AttributeError as e:
|
||||
pass
|
||||
print_substep("Received AskReddit threads successfully.", style="bold green")
|
||||
|
||||
return content
|
||||
+3
-1
@@ -27,13 +27,15 @@ pyee==8.1.0
|
||||
pyflakes==2.2.0
|
||||
Pygments==2.12.0
|
||||
python-dotenv==0.20.0
|
||||
|
||||
regex==2020.10.15
|
||||
|
||||
requests==2.27.1
|
||||
rich==12.4.4
|
||||
six==1.16.0
|
||||
toml==0.10.1
|
||||
tqdm==4.64.0
|
||||
typed-ast==1.4.1
|
||||
typed-ast==1.5.4
|
||||
typing_extensions==4.2.0
|
||||
update-checker==0.18.0
|
||||
urllib3==1.26.9
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
from random import randrange
|
||||
|
||||
from yt_dlp import YoutubeDL
|
||||
|
||||
from pathlib import Path
|
||||
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
|
||||
from moviepy.editor import VideoFileClip
|
||||
@@ -11,7 +13,6 @@ def get_start_and_end_times(video_length, length_of_clip):
|
||||
random_time = randrange(180, int(length_of_clip) - int(video_length))
|
||||
return random_time, random_time + video_length
|
||||
|
||||
|
||||
def download_background():
|
||||
"""Downloads the background video from youtube.
|
||||
|
||||
@@ -22,6 +23,7 @@ def download_background():
|
||||
print_step(
|
||||
"We need to download the Minecraft background video. This is fairly large but it's only done once."
|
||||
)
|
||||
|
||||
print_substep("Downloading the background video... please be patient.")
|
||||
|
||||
ydl_opts = {
|
||||
|
||||
Reference in new issue
Block a user