Coder Social home page Coder Social logo

giacomo-b / reddit-compilation-maker Goto Github PK

View Code? Open in Web Editor NEW
31.0 2.0 5.0 24 KB

Make compilations by aggregating videos from multiple subreddits

License: GNU General Public License v3.0

Python 100.00%
video reddit python youtube download downloader mp4 mp4-video download-videos reddit-scraper reddit-api automatic moviepy moviepy-library

reddit-compilation-maker's Introduction

Reddit Compilation Maker

Reddit Compilation Maker is a Python tool created to automatically create compilations from subreddits content. Can be used to synthesize the trending videos into compilations, automate content generation for social media, and much more.

Requirements

This program relies on bulk-downloader-for-reddit, which in turn needs ffmpeg to work correctly.

You also need numpy and moviepy.

Installing ffmpeg

  • On Linux: run sudo apt install ffmpeg
  • On Windows:
    • Download the installer from here or here and run it
    • Add ffmpeg to your Path:
      • Go to Environment Variables
      • Select Path -> Edit -> New and add C:\FFmpeg\bin (or wherever you installed ffmpeg at the previous step)
  • On MacOS:
    • Install Homebrew
    • Run brew install ffmpeg

Installing numpy and moviepy

Run python -m pip install numpy moviepy

How to use

Selecting the target subreddits for your compilations

Just edit settings.py to include all the subreddits you want. To make the script more flexible, topics allows to keep track of multiple topics. This means that the final output will mix videos from all the subreddits provided for each topic.

Each topics element is a dictionary with the following format:

{
    "name": "MyTopic",
    "subreddits": [ {"name":  "first-sub", "sort": "top", "time":  "week", "limit": 10},
                    {"name": "second-sub", "sort": "hot", "time": "month", "limit": 20} ],
    "MAX_CLIP_TIME":    60.0,  # seconds
    "MAX_SUBCLIP_TIME": 20.0,  # seconds
}

In the example above, the script will generate a compilation "MyTopic" containing videos from "first-sub" and "second-sub" (add as many as you wish).

The videos will be selected by taking the first 10 and 20 posts of each subreddit, sorted by "top of the last week" in the first case and "hot in the last month" in the second case.

Videos longer than MAX_SUBCLIP_TIME will be discarded, and a single compilation won't be longer than MAX_CLIP_TIME. If the total duration of the videos is longer than MAX_CLIP_TIME, multiple compilations are generated.

Feel free to add as many compilation topics as you want by populating topics with more dictionaries in settings.py.

Running the script

Run python main.py from the command line.

Additional options

About sort and time

These options are taken from the original bulk-downloader-for-reddit repo:

  • sort: accepts hot, top, new, rising, controversial and relevance
  • time: accepts hour, day, week, month, year and all

Videos order inside the compilation

Note that videos are currently being sorted by order inside each compilation video. This suited my use case, but you can change it in main.py.

reddit-compilation-maker's People

Contributors

giacomo-b avatar giacomo-bn avatar kiliangui 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

Watchers

 avatar  avatar

reddit-compilation-maker's Issues

Errors

These are the errors that I get, can someone maybe help me fix it? (I ran it in CMD)

C:\Users\Xander>python C:\Users\Xander\RedditCompiler/main.py

Initializing downloads for topic GTA...

python: can't open file 'C:\Users\Xander\bulk-downloader-for-reddit\script.py': [Errno 2] No such file or directory

Initializing YouTube postprocessing for topic GTA...

Traceback (most recent call last):
File "C:\Users\Xander\RedditCompiler\main.py", line 28, in
videos = find_valid_mp4_videos(topic["subreddits"], dirname=DOWNLOAD_DIR)
File "C:\Users\Xander\RedditCompiler\videoUtils.py", line 47, in find_valid_mp4_videos
for filename in os.listdir(os.path.join(dirname, sub["name"])):
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'downloads\gtaonline'

Automatically add credits (video URL) in .txt

Hello,

first, thank you for this great sharing !

I would like to create a .txt file automatically with the URLs of the videos in my compilation.
Example :

credits.txt
https://www.reddit.com/r/Unexpected/comments/mv12wm/when_mom_finds_your_gummys/
https://www.reddit.com/r/Unexpected/comments/mwt19x/shit_duck/
...

I know a little bit about how to automatically create .txt file and write to it with python but i have no idea how to get the url of the videos i just download in a python script.

Thanks in advance :p

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.