Giter Club home page Giter Club logo

reddit-shorts-bot's Introduction

Reddit-Shorts-Bot

A program to upload auto generated videos from Reddit threads to YouTube via the YouTube Data API v3

This is an improved version of a prior project where I had slightly modified the RedditVideoMakerBot to enable automatic uploading. The major improvement is that no alterations have to be made to the source code of the RedditVideoMakerBot, so this program can still be used even as that repository is updated further, provided the current directory structure is kept.

Requirements

A clone of the RedditVideoMakerBot repository is required as it will be doing the video generation

Furthermore needed are following packages:

  • oauth2client
  • google-api-python-client
  • httplib2
  • python-dotenv
  • tomli

These are also listed in requirements.txt and can be installed with pip install -r requirements.txt

Setup

  1. Clone the RedditVideoMakerBot repository
  2. Follow the installation guide for the RedditVideoMakerBot
  3. Test the RedditVideoMakerBot to make sure it works
  4. Rename .envTEMPLATE to .env and specify the path to your clone of RedditVideoMakerBot within
    • Create a project in the Google Cloud using the YouTube Data API v3 1
    • Rename client_secretsTEMPLATE.json to client_secrets.json and configure the marked fields with the information from your Google Cloud project
  5. Run the program, on first usage, you will be asked to authorize the project by Google for a Google (YouTube) account

sidenote: the o-auth token created in step 6 of will expire every so often, meaning when this happens you will be prompted to reauthorize your google account

Usage

Navigate to your clone of the repository and in the command line execute :

$ python main.py

The standard title of the uploaded video will be r/[SUBREDDIT]: THREAD_TITLE. For example r/AskReddit: What profession do you find unhealthy. If you want to specify a title other than the auto generated one you can specify it like this:

$ python main.py "title"

Make sure to use quotation marks ("This is a title") if you want to include spaces in your title

Occasionally after successful video creation the upload / verification process will fail, in this case you can re-call the program like this:

$ python main.py --retry

to attempt to upload the latest video again, this will avoid having to go through the slow video creation process again.

Notes

The upload happens through the YouTube Data API v3, after setting your account up in the google cloud you have an API quota of 10,000 / Day. Uploading a video costs 1600 points, so in a day you can upload a maximum of 6 videos.

Footnotes

  1. The individual steps for 5. haven't been explained in detail as that would be complicated to follow. For a good explanation of the individual steps I recommend this video from 4:17 to 11:05. Once you have your client ID and client secret, you can configure your client_secrets.json like in the next substep. โ†ฉ

reddit-shorts-bot's People

Contributors

joensw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

reddit-shorts-bot's Issues

publishat feature.

In YouTube you can schedule videos to be uploaded at different times. Along with my other issue related to repeating the script multiple times, it would be cool if you could space the uploads apart using scheduling and be able to specify an amount of time between each video. You can read about how to implement it here. https://developers.google.com/youtube/v3/docs/videos#status.publishAt.
The way that I would implement it if I knew Python would be that the first upload is whatever the default the user chose is. For me that would be public. All subsequent repeats would be defaulted as private so that they could be scheduled. The fact that it has to be in ISO 8601 format may be a bit of an annoyance but it's not too hard to figure out. Let's say that the user has specified that they want their videos to be spaced apart by 30 minutes. You could add 1800000 milliseconds to the equivalent of getDate() (which grabs the number of milliseconds since January 1, 1970) from JavaScript in Python, if there is one. For each video you add another 1800000 milliseconds. Then convert that into ISO 8601 format somehow. Timezone might be an issue, unsure.

Dont upload when RVMB crashes / doesnt terminate correctly

Currently, if the Reddit Video Maker Bot doesn't run successfully, i.e. crashes or experiences errors that terminate it, it wont have produced a video but the program will continue to the upload process and upload the newest video that still exists.

  • If the results folder of RVMB is empty the program will crash because find_latest_list will return an empty list and the program will crash
  • If the results folder of RVMB isnt empty the program will upload the newest video that is still in there

Fix: implement mechanic to see if the video creation process was actually successful and if not terminate the program with an error message

Python Error When Running main.py With Python 3.10

Traceback (most recent call last): File "/home/user/Reddit-Shorts-Bot/main.py", line 95, in <module> main() File "/home/user/Reddit-Shorts-Bot/main.py", line 84, in main create_videos() File "/home/user/Reddit-Shorts-Bot/main.py", line 39, in create_videos proc = subprocess.run(cmd.as_posix()) File "/usr/local/lib/python3.10/subprocess.py", line 503, in run with Popen(*popenargs, **kwargs) as process: File "/usr/local/lib/python3.10/subprocess.py", line 971, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/local/lib/python3.10/subprocess.py", line 1863, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'python /home/user/RedditVideoMakerBot-master/main.py'

Incompatible with RedditVideoMakerBot's times_to_run feature.

When you use the bot and you have in the RedditVideoMakerBot settings a certain times_to_run it will run that many times but this will only upload one of those times. I think that the easiest fix would be to copy the feature from RedditVideoMakerBot and make it so that the whole script runs however many times you want. This would still leave a bug if someone also had a specific number of times_to_run more than 1 in RedditVideoMakerBot but hey, at least you could run it multiple times. I've tried to do this myself but I don't know Python so I haven't been successful. If it helps, here are where I've found code that involves the times_to_run feature in the RedditVideoMakerBot:

https://github.com/elebumm/RedditVideoMakerBot/blob/master/utils/.config.template.toml
https://github.com/elebumm/RedditVideoMakerBot/blob/master/main.py

OSError: [Errno 22] Invalid argument: 'C:\\Users\nakadashimiyako\\Documents\\RedditVideoMakerBot\\config.toml'

Traceback (most recent call last):
File "C:\Users\nakadashimiyako\Documents\Reddit-Shorts-Bot\main.py", line 95, in
main()
File "C:\Users\nakadashimiyako\Documents\Reddit-Shorts-Bot\main.py", line 76, in main
times_to_run = get_run_times()
File "C:\Users\nakadashimiyako\Documents\Reddit-Shorts-Bot\main.py", line 21, in get_run_times
with open(config_path, mode="rb") as fp:
OSError: [Errno 22] Invalid argument: 'C:\Users\nakadashimiyako\Documents\RedditVideoMakerBot\config.toml'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.