randomly select subreddit & save it to respecive folder

pull/1433/head
SAIKAT KARMAKAR 3 years ago
parent ed3e5ffaed
commit 74fb1a305b

@ -14,7 +14,10 @@ from utils.voice import sanitize_text
from utils.posttextparser import posttextparser
from utils.ai_methods import sort_by_similarity
def choice_sub():
subs = ["announcements", "funny", "AskReddit", "gaming", "aww", "Music", "pics", "science", "worldnews", "videos", "todayilearned", "movies", "news", "Showerthoughts", "EarthPorn", "gifs", "IAmA", "food", "askscience", "Jokes", "LifeProTips", "explainlikeimfive", "Art", "books", "mildlyinteresting", "nottheonion", "DIY", "sports", "blog", "space", "gadgets"]
return choice(subs)
def get_subreddit_threads(POST_ID: str):
"""
@ -70,7 +73,7 @@ def get_subreddit_threads(POST_ID: str):
print_substep("Subreddit not defined. Using AskReddit.")
else:
#sub = settings.config["reddit"]["thread"]["subreddit"]
sub = choice(subs)
sub = choice_sub()
print_substep(f"Using subreddit: r/{sub} from TOML config")
subreddit_choice = sub
if (

@ -1 +1,66 @@
[]
[
{
"subreddit": "funny",
"id": "105r2ik",
"time": "1673135455",
"background_credit": "bbswitzer",
"reddit_title": "Rie Ota the Japanese suit actress for the kaiju BARAGON in a 2001 Godzilla movie lets out the most adorable roars whilst filming",
"filename": "Rie Ota the Japanese suit actress for the kaiju BARAGON in a 2001 Godzilla movie lets out the most adorable roars whilst filming.mp4"
},
{
"subreddit": "IAmA",
"id": "107vyy9",
"time": "1673361784",
"background_credit": "bbswitzer",
"reddit_title": "Virgin Orbit fails to reach orbit from first flight out of UK spaceport",
"filename": "Virgin Orbit fails to reach orbit from first flight out of UK spaceport.mp4"
},
{
"subreddit": "EarthPorn",
"id": "107ydf9",
"time": "1673362036",
"background_credit": "bbswitzer",
"reddit_title": "The bubbles at the bottom of my water glass look like a script of some kind",
"filename": "The bubbles at the bottom of my water glass look like a script of some kind.mp4"
},
{
"subreddit": "space",
"id": "107lbo1",
"time": "1673362241",
"background_credit": "bbswitzer",
"reddit_title": "Call me a racist if you want but south of the border is a sea of violence corruption and stupidity I wouldnt touch with a ten foot pole",
"filename": "Call me a racist if you want but south of the border is a sea of violence corruption and stupidity I wouldnt touch with a ten foot pole.mp4"
},
{
"subreddit": "sports",
"id": "107v82z",
"time": "1673362449",
"background_credit": "bbswitzer",
"reddit_title": "UN says ozone layer slowly healing hole to mend by 2066",
"filename": "UN says ozone layer slowly healing hole to mend by 2066.mp4"
},
{
"subreddit": "announcements",
"id": "107hyt6",
"time": "1673362685",
"background_credit": "bbswitzer",
"reddit_title": "Space hotels are a classic Sci-Fi trope But American hospitality giant Hilton recently signed a deal with Lockheed Martin and Voyager Space to build the solar systems first space hotel onboard Starlab a space station with NASA funding which is currently under development",
"filename": "Space hotels are a classic Sci-Fi trope But American hospitality giant Hilton recently signed a deal with Lockheed Martin and Voyager Space to build the solar systems first space hotel onboard Starlab a space station with NASA funding which is curre.mp4"
},
{
"subreddit": "gadgets",
"id": "10868e6",
"time": "1673362933",
"background_credit": "bbswitzer",
"reddit_title": "Over-40s on antibiotics nearly 50 per cent more likely to develop Crohns disease Researchers followed more than six million people in Denmark for more than 10 years and found that taking antibiotics was linked to an increase in risk of inflammatory bowel disease",
"filename": "Over-40s on antibiotics nearly 50 per cent more likely to develop Crohns disease Researchers followed more than six million people in Denmark for more than 10 years and found that taking antibiotics was linked to an increase in risk of inflammatory bo.mp4"
},
{
"subreddit": "funny",
"id": "1084xe7",
"time": "1673363191",
"background_credit": "bbswitzer",
"reddit_title": "The Woods Have Eyes Me 3D 2022",
"filename": "The Woods Have Eyes Me 3D 2022.mp4"
}
]

@ -26,6 +26,8 @@ from utils.thumbnail import create_thumbnail
from utils import settings
from utils.thumbnail import create_thumbnail
from reddit.subreddit import choice_sub
console = Console()
@ -183,7 +185,8 @@ def make_final_video(
title_thumb = reddit_obj["thread_title"]
filename = f"{name_normalize(title)[:251]}"
subreddit = settings.config["reddit"]["thread"]["subreddit"]
#subreddit = settings.config["reddit"]["thread"]["subreddit"]
subreddit = choice_sub()
if not exists(f"./results/{subreddit}"):
print_substep("The results folder didn't exist so I made it")

Loading…
Cancel
Save