RedditVideoMakerBot icon indicating copy to clipboard operation
RedditVideoMakerBot copied to clipboard

REQUEST changing the name of the output file

Open reinkdesigns opened this issue 4 years ago • 17 comments

how would i go and change the name of the output file to match the title of the reddit post

reinkdesigns avatar Jun 02 '22 20:06 reinkdesigns

image

i see the script already knows what the post title is, so i have to imagine its not to hard to take that and assign it to the output file?

reinkdesigns avatar Jun 02 '22 20:06 reinkdesigns

I have created an edit that will make the final video's name the Reddit thread title. You can try it out on my fork: https://github.com/reoccurcat/RedditVideoMakerBot/tree/final_video_name_test There's probably enough demand that I could get a PR started to merge this into master to be honest.

reoccurcat avatar Jun 02 '22 21:06 reoccurcat

ok so i think i got it working by replacing

    final.write_videofile(
        f"assets/Final_Video.mp4", fps=30, audio_codec="aac", audio_bitrate="192k"
    )

with

    reddit = praw.Reddit(
        client_id=os.getenv("REDDIT_CLIENT_ID"),
        client_secret=os.getenv("REDDIT_CLIENT_SECRET"),
        user_agent="Accessing AskReddit threads",
        username=os.getenv("REDDIT_USERNAME"),
        password=os.getenv("REDDIT_PASSWORD"),
    )
    askreddit = reddit.subreddit(os.getenv("REDDIT_SUBREDDIT"))
    threads = askreddit.hot(limit=25)
    submission = list(threads)[random.randrange(0, 25)]
    
    final.write_videofile(
        f"assets/{submission}.mp4", fps=30, audio_codec="aac", audio_bitrate="192k"
    )

and adding

import praw
import os
import random

to the top of Video_creation\Final_video.py

but now i get an error that i think i know what needs to be done to fix, but im not sure how to do it. i know Windows doesnt like having "?' and some other symbols in its file name,s so how would i go about striping those symbols from the title name?

reinkdesigns avatar Jun 02 '22 21:06 reinkdesigns

I have created an edit that will make the final video's name the Reddit thread title. You can try it out on my fork: https://github.com/reoccurcat/RedditVideoMakerBot/tree/final_video_name_test There's probably enough demand that I could get a PR started to merge this into master to be honest.

i will take a look, was i on the right track by chance? im new to python and im taking the "cut and paste" approach and just moving parts of the code that work to other parts that i want to work

reinkdesigns avatar Jun 02 '22 21:06 reinkdesigns

i will take a look, was i on the right track by chance?

Yeah, you just took a little bit more complicated way of doing it, instead of just returning the name from the function that gets the subreddit. I'm going to push another commit pretty soon that will fix a lot more of the windows path issues with the characters though, because so far mine just strips off the question mark that's usually at the end

reoccurcat avatar Jun 02 '22 21:06 reoccurcat

yea i figured there was an easier way to do it, i just didnt know how

reinkdesigns avatar Jun 02 '22 21:06 reinkdesigns

I just pushed a commit that sanitizes the filename a bit better.

reoccurcat avatar Jun 02 '22 21:06 reoccurcat

ok cool, how do i download a commit?

reinkdesigns avatar Jun 02 '22 21:06 reinkdesigns

Try using this url. Disclaimer: this has some of my changes I've put into a pull request just recently (#171)

reoccurcat avatar Jun 02 '22 21:06 reoccurcat

image

getting error?

reinkdesigns avatar Jun 02 '22 21:06 reinkdesigns

You probably haven't installed yt-dlp yet, run pip install yt-dlp It got introduced in a new commit recently

reoccurcat avatar Jun 02 '22 21:06 reoccurcat

can i message you on discord to query you for a few tings?

reinkdesigns avatar Jun 02 '22 21:06 reinkdesigns

Yup, reoccurcat#0001, go ahead and shoot me a friend request

reoccurcat avatar Jun 02 '22 21:06 reoccurcat

image wooo all the issues coming back :D lol

reinkdesigns avatar Jun 02 '22 21:06 reinkdesigns

Make sure your .env is formatted like this:

REDDIT_CLIENT_ID=""
REDDIT_CLIENT_SECRET=""
REDDIT_USERNAME=""
REDDIT_PASSWORD=""

# Valid options are "yes" and "no" for the variable below
REDDIT_2FA=""

SUBREDDIT=""

reoccurcat avatar Jun 02 '22 21:06 reoccurcat

i've sovled this in a faster way with #139

kalanscr avatar Jun 03 '22 01:06 kalanscr

Now in main branch, this issue can be closed @CallumIO @reinkdesigns

kalanscr avatar Jun 05 '22 06:06 kalanscr