Q's YouTube Trailer Scraper A simple shell script to search YouTube and download movie trailers based on contents of my Kodi library. Makes for a better, locally served "Cinema Experience/Vision" mode.

Category bbb14643fd v0.13 1 year ago
COPYING.WTFPL 12b36a3f6d Readme update 4 years ago
QYTTS.sh bbb14643fd v0.13 1 year ago
README.md 62c4403d34 v0.13 - option to auto fix dependencies 1 year ago

README.md

QYTTS

# QsYouTubeTrailerScraper - QYTTS v0.13

This script will scrape your Kodi library for movie titles, then search YouTube for it's trailer. It'll download the trailers to a specified directory, which is used by the Cinema Experience script for Kodi to load trailers. This way you can see the trailers for films you own, withought having to deal with all the buffering that comes from streaming.

I know there are other tools out there to get trailers for your library, but most were windows based. The ones that weren't would just grab trailers for any film, whether you have it or not.

This was designed for my original Raspberry Pi Model B, running OSMC. As such, it'll probably run on any Linux Kodi setup.


Changelog

  • v0.13 - added option to fix missing dependencies
  • v0.12 - various tweaks to fix some neglect
  • v0.11 - migrated away from GitHub because MIRCOS~1
  • v0.10 - filename handling fixed this time, honest
  • v0.9 - youtubedl filename handling corrected
  • v0.8 - scraper udated - again - YT needs to stop changing
  • v0.7 - fixed scraper, YT changes broke everything
  • v0.6 - updated base config for new version of Kodi database
  • v0.5 - produce list of failed film at end of script - run alphabetically
  • v0.4 - added quick dependency check
  • v0.3 - added better trailer detection
  • v0.2 - complete reworking of proof of concept version
  • v0.1 - proof of concept

Usage

Ensure all configuration options are set correctly, then just run the script as the same user that runs Kodi. No arguments needed, just make sure the Kodi user has write access to temp & trailer directories.


Dependencies

bash shell environment

SQLite3

  • install with "sudo apt-get install sqlite3"

youtube-dl

You can set a config option in the script to automatically try and fix dependencies, currently this is only for systems using APT as a package manager. This is off by default to avoid making unwanted changes to your system.


Known Issues

youtube-dl errors

It is IMPERATIVE that you use an up-to-date version of youtube-dl, as they are playing whack-a-mole with YouTube servers constantly. I have found that the version kept in some repos (namely raspbian) isn't always up to date. I highly recommend installing it direct from the developers as mentioned above. If you do run into any issues, running "youtube-dl -U" to update can often fix problems grabbing trailers.

Grabbing entire films

Due to the simplicity of this script, it will grab the first YouTube result after searching for the movie name + "trailer". In the case of some films - mostly older or independent films - the first result on youtube will be the complete film. To avoid this issue, there are 2 countermeasures - it will check the title of the YouTube video to ensure it contains the word "Trailer" (case insensitive). Secondly, after downloading it checks if it is larger than the maximum file size (default is 100MB), and if it is too large then deletes the file. Unfortunately I have no way to check file size before downloading, so looking at extra ways of avoiding unnecessary bandwidth usage...

YT updating their site

YouTube seem to be updating their search result page with increasing frequency, breaking my dirty-hack scraper. I may have to get more clever with extracting the YT video ID from their page...

If you encounter any other issues, please raise an issue on notabug or email (https://notabug.org/Category/QYTTS)

Copyright © 2015 Category categoryNOSPAM@quintendo.uk This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See the COPYING file for more details.