Merge branch 'master' into patch-1

pull/181/head
Callum Leslie 3 years ago committed by GitHub
commit 93108c85d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,5 +6,7 @@ REDDIT_PASSWORD=""
# Valid options are "yes" and "no" for the variable below # Valid options are "yes" and "no" for the variable below
REDDIT_2FA="" REDDIT_2FA=""
# Enter a subreddit, e.g. "AskReddit" or "r/AskReddit" THEME=""
# Enter a subreddit, e.g. "AskReddit"
SUBREDDIT="" SUBREDDIT=""

@ -35,8 +35,7 @@ These videos on TikTok, YouTube and Instagram get MILLIONS of views across all p
3. Run `pip3 install -r requirements.txt` 3. Run `pip3 install -r requirements.txt`
4. Run `playwright install` and `playwright install-deps`. 4. Run `playwright install` and `playwright install-deps`.
5. Run `python3 main.py` 5. Run `python3 main.py`
6. ... 6. Enjoy 😎
7. Enjoy 😎
## Contributing & Ways to improve 📈 ## Contributing & Ways to improve 📈

@ -6,6 +6,8 @@ from video_creation.background import download_background, chop_background_video
from video_creation.voices import save_text_to_mp3 from video_creation.voices import save_text_to_mp3
from video_creation.screenshot_downloader import download_screenshots_of_reddit_posts from video_creation.screenshot_downloader import download_screenshots_of_reddit_posts
from video_creation.final_video import make_final_video from video_creation.final_video import make_final_video
from dotenv import load_dotenv
import os
print_markdown( print_markdown(
"### Thanks for using this tool! [Feel free to contribute to this project on GitHub!](https://lewismenelaws.com) If you have any questions, feel free to reach out to me on Twitter or submit a GitHub issue." "### Thanks for using this tool! [Feel free to contribute to this project on GitHub!](https://lewismenelaws.com) If you have any questions, feel free to reach out to me on Twitter or submit a GitHub issue."
@ -16,8 +18,9 @@ time.sleep(3)
reddit_object = get_subreddit_threads() reddit_object = get_subreddit_threads()
load_dotenv()
length, number_of_comments = save_text_to_mp3(reddit_object) length, number_of_comments = save_text_to_mp3(reddit_object)
download_screenshots_of_reddit_posts(reddit_object, number_of_comments) download_screenshots_of_reddit_posts(reddit_object, number_of_comments, os.getenv("THEME"))
download_background() download_background()
chop_background_video(length) chop_background_video(length)
final_video = make_final_video(number_of_comments) final_video = make_final_video(number_of_comments)

@ -0,0 +1,8 @@
[
{
"name": "USER",
"value": "eyJwcmVmcyI6eyJ0b3BDb250ZW50RGlzbWlzc2FsVGltZSI6MCwiZ2xvYmFsVGhlbWUiOiJSRURESVQiLCJuaWdodG1vZGUiOnRydWUsImNvbGxhcHNlZFRyYXlTZWN0aW9ucyI6eyJmYXZvcml0ZXMiOmZhbHNlLCJtdWx0aXMiOmZhbHNlLCJtb2RlcmF0aW5nIjpmYWxzZSwic3Vic2NyaXB0aW9ucyI6ZmFsc2UsInByb2ZpbGVzIjpmYWxzZX0sInRvcENvbnRlbnRUaW1lc0Rpc21pc3NlZCI6MH19",
"domain": ".reddit.com",
"path": "/"
}
]

@ -2,9 +2,10 @@ from playwright.sync_api import sync_playwright
from pathlib import Path from pathlib import Path
from rich.progress import track from rich.progress import track
from utils.console import print_step, print_substep from utils.console import print_step, print_substep
import json
def download_screenshots_of_reddit_posts(reddit_object, screenshot_num): def download_screenshots_of_reddit_posts(reddit_object, screenshot_num, theme):
"""Downloads screenshots of reddit posts as they are seen on the web. """Downloads screenshots of reddit posts as they are seen on the web.
Args: Args:
@ -20,9 +21,15 @@ def download_screenshots_of_reddit_posts(reddit_object, screenshot_num):
print_substep("Launching Headless Browser...") print_substep("Launching Headless Browser...")
browser = p.chromium.launch() browser = p.chromium.launch()
context = browser.new_context()
if theme.casefold() == "dark":
cookie_file = open('video_creation/cookies.json')
cookies = json.load(cookie_file)
context.add_cookies(cookies)
# Get the thread screenshot # Get the thread screenshot
page = browser.new_page() page = context.new_page()
page.goto(reddit_object["thread_url"]) page.goto(reddit_object["thread_url"])
if page.locator('[data-testid="content-gate"]').is_visible(): if page.locator('[data-testid="content-gate"]').is_visible():

Loading…
Cancel
Save