/plex-preroll-trailers

Simple and rough set of python script that download trailers for the upcoming/now playing movies in theathers and show it as a preroll video before watch movies in Plex.

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

Plex-Preroll-Trailers

Simple and rough set of python script that download trailers for the upcoming/now playing movies in theaters and show it as a preroll video before watch movies in Plex.

Why

For having a theaters-like experience when watching movies in Plex at home.

Requirements

The heart of the scripts is written in python, so they can work on all platform that have python installed. However there are 2 bash script for Linux/Ubuntu, but they are so simple that can be adapted for other OS.

pip install tmdbsimple
sudo -H pip install --upgrade youtube-dl
  • FFmpeg

How it works

The script download_preroll_trailers.py connect to TheMovieDB.org, select a user defined numbers of movies that, for your country, are in theaters or are upcoming, orders them by popularity and download from YouTube the trailers associated (retrieved from TheMovieDB API), write a JSON file with the filenames of the downloaded trailers.

The script mix_preroll_trailers.py load from the JSON file the filenames of the downloaded trailers, select randomly a user defined number of trailers to play within Plex and create a text file with the selected number of videos.

The script concat_preroll_trailers.sh takes the chosen videos from the text file and merge them with FFmpeg.

The script download_preroll_trailers.sh simply remove the old downloaded videos and execute the download_preroll_trailers.py.

Settings

Edit the config.ini file, see comments in file.

Usage

  • Clone and cd to the repository directory
  • sudo chmod +x *.sh
  • crontab -e for add the bash scripts to CRON. Personally i use:

0 3 * * fri path/to/download_preroll_trailers.sh # once a week download trailers

30 3 * * * /path/to/concat_preroll_trailers.sh # once a day mix the trailers that will be played into Plex.

  • Go to Plex Settings > Server > Extras click on the Show Advanced and into "Cinema Trailers pre-roll video" set /path/to/plex-preroll-trailers/preroll_trailers.mp4
  • Enable in the Plex clients the option to show trailer.