diff --git a/main.py b/main.py index 10be90b..4aa0a4b 100755 --- a/main.py +++ b/main.py @@ -19,9 +19,6 @@ def main(): def get_obj(): reddit_obj = get_subreddit_threads() - for comment in (reddit_obj["comments"]): - if len(comment["comment_body"]) > 250: - reddit_obj["comments"].remove(comment) return reddit_obj reddit_object = get_obj() diff --git a/reddit/subreddit.py b/reddit/subreddit.py index ff19334..c2a59df 100755 --- a/reddit/subreddit.py +++ b/reddit/subreddit.py @@ -58,9 +58,10 @@ def get_subreddit_threads(): content["comments"] = [] for top_level_comment in submission.comments: - content["comments"].append( - {"comment_body": top_level_comment.body, "comment_url": top_level_comment.permalink, - "comment_id": top_level_comment.id, }) + if len(top_level_comment.body) <= 250: + content["comments"].append( + {"comment_body": top_level_comment.body, "comment_url": top_level_comment.permalink, + "comment_id": top_level_comment.id, }) except AttributeError as e: pass diff --git a/video_creation/TTSwrapper.py b/video_creation/TTSwrapper.py index e239e81..0b50b15 100644 --- a/video_creation/TTSwrapper.py +++ b/video_creation/TTSwrapper.py @@ -54,10 +54,7 @@ class TTTTSWrapper: # TikTok Text-to-Speech Wrapper self.URI_BASE = 'https://api16-normal-useast5.us.tiktokv.com/media/api/text/speech/invoke/?text_speaker=' def tts(self, req_text: str = "TikTok Text To Speech", filename: str = 'title.mp3', random_speaker: bool = False): - if len(req_text) > 299: - return ValueError("Text too long must be under 299 characters") - if random_speaker: - req_text = req_text.replace("+", "plus").replace(" ", "+").replace("&", "and") + req_text = req_text.replace("+", "plus").replace(" ", "+").replace("&", "and") voice = self.randomvoice() if random_speaker else 'en_us_002' r = requests.post(f"{self.URI_BASE}{voice}&req_text={req_text}&speaker_map_type=0")