Git Product home page Git Product logo

redditvideogenerator's Introduction

Reddit Video Generator

This project is further explained in this video

This code is meant only for educational reference and will not be maintained. Because of this, the repo is archived and is in a read-only state


This program generates a .mp4 video automatically by querying the top post on the r/askreddit subreddit, and grabbing several comments. The workflow of this program is:

  • Install dependencies
  • Make a copy of config.example.ini and rename to config.ini
  • Register with Reddit to create an application here and copy the credentials
  • Use the credentials from the previous step to update config.ini (lines 22 -> 24)

Now, you can run python main.py to be prompted for which post to choose. Alternatively, you can run python main.py <reddit-post-id> to create a video for a specific post.

redditvideogenerator's People

Contributors

felipelecot avatar kariuki-kithinji avatar mickyaflalo avatar mishalhossin avatar shifty-the-dev avatar theblckbird avatar traysimpson 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  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  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  avatar  avatar  avatar  avatar

redditvideogenerator's Issues

what should i do for this

when I run main.py
I get this error

line 7, in createVideo
outputDir = config["General"]["OutputDirectory"]

line 87, in
createVideo()

Selenium TimeoutException when getting screenshots

Traceback (most recent call last):
  File "C:\Users\Dromu\Documents\code\RedditVideoGenerator\main.py", line 89, in <module>
    createVideo()
  File "C:\Users\Dromu\Documents\code\RedditVideoGenerator\main.py", line 21, in createVideo
    screenshot.getPostScreenshots(fileName, script)
  File "C:\Users\Dromu\Documents\code\RedditVideoGenerator\screenshot.py", line 15, in getPostScreenshots
    script.titleSCFile = __takeScreenshot(filePrefix, driver, wait)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Dromu\Documents\code\RedditVideoGenerator\screenshot.py", line 22, in __takeScreenshot
    search = wait.until(EC.presence_of_element_located((method, handle)))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Dromu\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\selenium\webdriver\support\wait.py", line 95, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
Stacktrace:
RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8
WebDriverError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:180:5
NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:392:5
element.find/</<@chrome://remote/content/marionette/element.sys.mjs:134:16

I am getting this exception when selenium tries to get screenshots. I tried to run it multiple times but it all got the same thing. One thing that appeared when I tried it was the google login message:
image
aside from that I don't know what else can cause it. I just ran it and it just keeps appearing.

Selenium not working in the right way?

Before anyone says anything, im very new in python and linux, and I don't know how it should work. It gives me this error so, can someone help me? It seems to be related to some firefox driver but I'm not sure.

Exception ignored on calling ctypes callback function: <bound method EspeakDriver._onSynth of <pyttsx3.drivers.espeak.EspeakDriver object at 0x7ff4bcc15c30>>
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/pyttsx3/drivers/espeak.py", line 171, in _onSynth
    self._proxy.notify('finished-utterance', completed=True)
ReferenceError: weakly-referenced object no longer exists
Taking screenshots...
Traceback (most recent call last):
  File "/tmp/RedditVideoGenerator/main.py", line 87, in <module>
    createVideo()
  File "/tmp/RedditVideoGenerator/main.py", line 21, in createVideo
    screenshot.getPostScreenshots(fileName, script)
  File "/tmp/RedditVideoGenerator/screenshot.py", line 13, in getPostScreenshots
    driver, wait = __setupDriver(script.url)
  File "/tmp/RedditVideoGenerator/screenshot.py", line 34, in __setupDriver
    driver = webdriver.Firefox(options=options)
  File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/firefox/webdriver.py", line 199, in __init__
    super().__init__(command_executor=executor, options=options, keep_alive=True)
  File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py", line 286, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py", line 378, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py", line 440, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/errorhandler.py", line 245, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 1

Screenshot Cookie

I've managed to get my system all working, however whenever it goes to take screenshots I have to quickly manually click the cookie accept button every single time I want to create a video which can get tricky when it only gives you like a second until it starts to take all of the screenshots. Any ideas on what I could do?

Example of the screenshots it gives me:
2023-04-05-12c3715-t1_jeztj60
2023-04-05-12c3715-t1_jeztzxj

voiceover file can't be found

(noob) when I try to run the code, it gives the following error:

raise IOError(("MoviePy error: the file %s could not be found!\n"
OSError: MoviePy error: the file Voiceovers/2023-02-20-116opqc-title.mp3 could not be found!
Please check that you entered the correct path.

I already installed dependencies, created a copy of config.ini and modified VLCPath, OutputDirectory and BackgroundDirectory. I'd be more than grateful for help.

Can u help me with the code?

[0] How is everyone feeling about Donald Trump officially being under arrest ? 9776 4.5 hours ago
[1] Citizens of NATO aligned countries. How do you feel now that Finland has officially joined the alliance? 1042 5.3 hours ago
[2] What is your IRL superpower? 578 23.0 hours ago
[3] What is 100% worth the money? 527 24.1 hours ago
Input :1
Exception ignored on calling ctypes callback function: <bound method EspeakDriver._onSynth of <pyttsx3.drivers.espeak.EspeakDriver object at 0x7a02bc3f6ee0>>
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/pyttsx3/drivers/espeak.py", line 171, in _onSynth
self._proxy.notify('finished-utterance', completed=True)
ReferenceError: weakly-referenced object no longer exists
Creating video for post: Citizens of NATO aligned countries. How do you feel now that Finland has officially joined the alliance?
Url: https://www.reddit.com/r/AskReddit/comments/12bpnl6/citizens_of_nato_aligned_countries_how_do_you/
Traceback (most recent call last):
File "/home/yevgen/RedditVideoGenerator/main.py", line 87, in
createVideo()
File "/home/yevgen/RedditVideoGenerator/main.py", line 17, in createVideo
script = reddit.getContent(outputDir, postOptionCount)
File "/home/yevgen/RedditVideoGenerator/reddit.py", line 28, in getContent
return __getContentFromPost(selectedPost)
File "/home/yevgen/RedditVideoGenerator/reddit.py", line 62, in __getContentFromPost
if(content.addCommentScene(markdown_to_text.markdown_to_text(comment.body), comment.id)):
File "/home/yevgen/RedditVideoGenerator/videoscript.py", line 35, in addCommentScene
frame.audioClip = self.__createVoiceOver(commentId, text)
File "/home/yevgen/RedditVideoGenerator/videoscript.py", line 48, in __createVoiceOver
audioClip = AudioFileClip(file_path)
File "/usr/local/lib/python3.9/dist-packages/moviepy/audio/io/AudioFileClip.py", line 70, in init
self.reader = FFMPEG_AudioReader(filename, fps=fps, nbytes=nbytes,
File "/usr/local/lib/python3.9/dist-packages/moviepy/audio/io/readers.py", line 51, in init
infos = ffmpeg_parse_infos(filename)
File "/usr/local/lib/python3.9/dist-packages/moviepy/video/io/ffmpeg_reader.py", line 270, in ffmpeg_parse_infos
raise IOError(("MoviePy error: the file %s could not be found!\n"
OSError: MoviePy error: the file Voiceovers/2023-04-05-12bpnl6-jexwbq5.mp3 could not be found!
Please check that you entered the correct path.

Can u help me with the code?

I allways get this error and I dont quite understand what i have to change. This is the output when i run main.py:
C:\Users\user\AppData\Local\Programs\Python\Python311\python.exe C:\Users\user\Downloads\RedditVideoGenerator-master\main.py
[0] What movies come to mind when you think of great soundtracks? 1364 14.9 hours ago
[1] What's an American tradition you actually love? 475 17.7 hours ago
[2] What’s the first sign that a movie is going to be bad? 1612 6.0 hours ago
[3] What is something you hope to witness in your lifetime? 263 12.5 hours ago
Input: 2
Traceback (most recent call last):
File "C:\Users\user\Downloads\RedditVideoGenerator-master\main.py", line 87, in
createVideo()
File "C:\Users\user\Downloads\RedditVideoGenerator-master\main.py", line 17, in createVideo
script = reddit.getContent(outputDir, postOptionCount)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\Downloads\RedditVideoGenerator-master\reddit.py", line 35, in getContent
return __getContentFromPost(selectedPost)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\Downloads\RedditVideoGenerator-master\reddit.py", line 62, in __getContentFromPost
content = VideoScript(submission.url, submission.title, submission.id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\Downloads\RedditVideoGenerator-master\videoscript.py", line 22, in init
self.titleAudioClip = self.__createVoiceOver("title", title)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\Downloads\RedditVideoGenerator-master\videoscript.py", line 48, in __createVoiceOver
audioClip = AudioFileClip(file_path)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\moviepy\audio\io\AudioFileClip.py", line 70, in init
self.reader = FFMPEG_AudioReader(filename, fps=fps, nbytes=nbytes,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\moviepy\audio\io\readers.py", line 51, in init
infos = ffmpeg_parse_infos(filename)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 270, in ffmpeg_parse_infos
raise IOError(("MoviePy error: the file %s could not be found!\n"
OSError: MoviePy error: the file Voiceovers/2023-04-02-129k7ok-title.mp3 could not be found!
Please check that you entered the correct path.

Process finished with exit code 1

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.