For all you MythTV users that have been using our MythMediaMonitor application, here is a useful new script for MythVideo.
The new versions of MythVideo allow users to configure random trailer playback prior to watching a movie. In it’s current form, users must manually download trailers and assign them to the media on their system, which many people never take the time to do.
This bash script re-purposes the trailers’ folder and synchronizes the 40 most popular movie trailers on YouTube, with selectable video formats. This allows users to watch a random sampling of new and popular trailers whenever movie viewing begins.
Requirements include youtube-dl and lynx, and we recommend running the script from cron on a weekly basis.
[UPDATE]: YouTube has updated their site, and you must be using the version of youtube-dl released on 12/09/2010 or later. Most distributions do not come with this version. It can be found here: https://github.com/rg3/youtube-dl/raw/master/youtube-dl
Usage/Installation
Installation is simple and straightforward. Simply extractmythgettrailers .sh anywhere on a system with access to your trailers directory. Open up the script in vi or your favorite text editor to edit the configuration, and then schedule it to run as often as you like with cron:
ln -s /bin/mythgettrailers.sh /etc/cron.weekly
Configuration
The following setup variables should be edited before running MythGetTrailers for the first time.
Set the following field to the same value as the trailer storage group in MythTV:
TRAILERDIR="/storage/video/mythvideo/MetaData/Trailers"
Set the following variable to the highest resolution format you would like the script to download. A listing of formats can be found at: http://en.wikipedia.org/wiki/YouTube#Quality_and_codecs
MAXFORMAT="22"
Change Log
v0.03
- Updated for new YouTube page
- Now focuses on top 20 trailers and the “latest” trailers
v0.02
- Format bug fixed
v0.01
- Release
Download
Please do not distribute MythGetTrailers outside of this site. Directing links here will ensure the latest version of MythGetTrailers is always in circulation.
Download the latest version: mythgettrailers.0.03.tar.gz
Remember to check out the rest of the site!
29 Responses to “MythGetTrailers: Top 40 Trailer Downloader”
Great script!
I added the youtube-dl -t option to make sane file names.
@whizbo: I’m not sure I would recommend using the -t option. As the videos change, and syncing occurs, it uses the YouTubeID to determine which old trailers to remove and which new ones to download. With the -t option, I believe the script will delete all the trailers and re-download every time it is run, instead of just syncing up.
It seems broken as youtube removed the “fmt” option according to wikipedia.
Is there a way around this?
@Nick: This is a problem with youtube-dl. I’ve contacted the developer to let him know. I will repost here as soon as I hear back.
@Nick: Ricardo just updated youtube-dl. It’s not listed on his download page, but you can grab it from GitHub: https://github.com/rg3/youtube-dl/raw/master/youtube-dl I’ve also added a note in the main article.
@Benjamin Curtis: Thank you, the updated youtube-dl solved my issue
Hi – the only way I can play trailers is to select ‘Info’ then choose Play with Trailers. I can not get Myth 0.24 to automatically play 2 random trailers as per my settings in Video Options in the Frontend. Any ideas ?
Oh – great addon by the way
@ilium007: Unfortunately, there is no way to make the default keypress play with trailers. You would have to edit the theme to force it.
ahh ok – no probs
Downloaded and setup in /bin for mythtv 0.24 but cannot get it to run.
I put in a trace echo to see it populates the $TRAILERDIR but after that in the for loop it throws a : No such file or directory
root@mythtv:/bin# mythgettrailers.sh
/media/mythtv/trailers/
: No such file or directory
The trailers directory exists and is writable and readable. I dont understand the logic of the script at all so any help appreciated.
@Bigtoerag: You most likely don’t have the requirements installed: http://rg3.github.com/youtube-dl/ and http://en.wikipedia.org/wiki/Lynx_%28web_browser%29 Thanks.
As mentioned I had them in in /bin
I have also tried in /usr/local/bin but the same issue. My path difinitely has the locations and I have chmod for execute to make sure.
ANy other Ideas or debugging to show missing dependencies?
@Bigtoerag: Sorry, didn’t realize by “setup in /bin” you mean the prereqs, too. Hmm.. Are you running in bash? Is there anything in the Trailer Directory already? Just trying to get a sense of the environment. Thanks.
I have done a little more digging and it appears to be youtubedl that returns the error.
Lynx tested with the link from the mythgetrailers script works fine and shows all the url’s
Taking one of those URL’s into youtubedl returns the error
For exmaple:
Lynx retunred http://www.youtube.com/watch?v=5HsSonHZFnI
Youtubedl returns:
@mythtv:/usr/bin# youtube-dl “http://www.youtube.com/watch?v=5HsSonHZFnI”
: No such file or directory
Thanks for the feedback I will get youtubedl working first then revisit this.
@Bigtoerag: Interesting. How did you install youtube-dl? Do you have python installed? Perhaps install youtube-dl using yum, then update to the version on their website.
You an error in your script. $MAXFORMAT is never referenced in the script, $FORMAT is used instead, but it is not defined.
I’m getting this error when I run the script. Any ideas?
ERROR: unable to download video (format may not be available)
Thanks for that great tool!!
I have got a little problem with the script. It manages to successfully download 38 trailers and then stops. It seems, that the error occurs, when switching to the second page of trailers. Any one else has this problem? I can reach the requested page manually in firefox.
This is the output i get:
WARNING: Falling back on generic information extractor.
[generic] trailers?s=trp&p=2: Downloading webpage
[generic] trailers?s=trp&p=2: Extracting information
ERROR: Invalid URL: http://www.youtube.com/trailers?s=trp&p=2
@Darus and @Chris: New version updated. This should work now.
@Hell-G: It seems to be working for me.. Is anyone else having this issue?
I’m using youtube-dl version 2010.12.09 on mythbuntu 10.10. Let me know, if you need more info.
i have 0.24 mythtv and youtube-dl 2011.12.08. Mayby youtube pages are change or something is wrong. This just downloading and downloadin… i have now over 75 files in my trailer folder and script not stop. It just not download only real movie trailers. I think it’s downloading every video it found from pages i think. There is many users made home videos etc… Can you check are this script up today?
@Karvanoppa: Looks like YT did just make a layout change. I’m running my tests now, but v0.3 will support the new layout, the top 20 trailers, and the “latest” trailers instead of the top 40. Will post it soon.
v0.03 updated with fixes above. Thanks.
Thanks for update, but download link is broken.
@Karvanoppa: Doh. Updated.
The link for trailers doesn’t have any videos.
The script runs, and exits with no message.
I change the url in the script to http://www.youtube.com/playlist?list=PL5F394CB9AB8A3519 and it works now.
Hey, Benjamin, thanks for the script. It’s a really great feature in MythTV that I’m glad I can finally use. The YouTube.com link in v.3 is no longer valid. I’ve updated it with http://www.youtube.com/user/trailers and it looks like I’m getting 14 trailers now.
Quite a few months ago youtube seems to have made some further changes. Any chance of updating it again?