MythGetTrailers: Top 40 Trailer Downloader

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:


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/ /etc/cron.weekly


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:


Set the following variable to the highest resolution format you would like the script to download.  A listing of formats can be found at:


Change Log


  • Updated for new YouTube page
  • Now focuses on top 20 trailers and the “latest” trailers


  • Format bug fixed


  • Release


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!

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

29 Responses to “MythGetTrailers: Top 40 Trailer Downloader”

whizbo says:

Great script!
I added the youtube-dl -t option to make sane file names.

Benjamin Curtis says:

@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.

Nick says:

It seems broken as youtube removed the “fmt” option according to wikipedia.

Is there a way around this?

Benjamin Curtis says:

@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.

Benjamin Curtis says:

@Nick: Ricardo just updated youtube-dl. It’s not listed on his download page, but you can grab it from GitHub: I’ve also added a note in the main article.

Nick says:

@Benjamin Curtis: Thank you, the updated youtube-dl solved my issue :)

ilium007 says:

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 ?

ilium007 says:

Oh – great addon by the way ;)

Benjamin Curtis says:

@ilium007: Unfortunately, there is no way to make the default keypress play with trailers. You would have to edit the theme to force it.

ilium007 says:

ahh ok – no probs

Bigtoerag says:

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

: 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.

Benjamin Curtis says:

@Bigtoerag: You most likely don’t have the requirements installed: and Thanks.

Bigtoerag says:

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?

Benjamin Curtis says:

@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.

Bigtoerag says:

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

Youtubedl returns:
@mythtv:/usr/bin# youtube-dl “”
: No such file or directory

Thanks for the feedback I will get youtubedl working first then revisit this.

Benjamin Curtis says:

@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.

Darus says:

You an error in your script. $MAXFORMAT is never referenced in the script, $FORMAT is used instead, but it is not defined.

chris says:

I’m getting this error when I run the script. Any ideas?

ERROR: unable to download video (format may not be available)

Hell-G says:

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:

Benjamin Curtis says:

@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?

Hell-G says:

I’m using youtube-dl version 2010.12.09 on mythbuntu 10.10. Let me know, if you need more info.

Karvanoppa says:

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?

Benjamin Curtis says:

@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.

Benjamin Curtis says:

v0.03 updated with fixes above. Thanks.

Karvanoppa says:

Thanks for update, but download link is broken.

Benjamin Curtis says:

@Karvanoppa: Doh. Updated.

Scott says:

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 and it works now.

Kevin Schlichter says:

Hey, Benjamin, thanks for the script. It’s a really great feature in MythTV that I’m glad I can finally use. The link in v.3 is no longer valid. I’ve updated it with and it looks like I’m getting 14 trailers now.

Tony says:

Quite a few months ago youtube seems to have made some further changes. Any chance of updating it again?

Following the hottest hardware and software for today's digital junkie.

Off the wall articles and interviews from the technology sector.

The latest happenings in the technology industry.

Techviews Random Bits News Tools

Help us out, become a fan!

We provide tools such as the Registry Changer and MythMediaMonitor along with current news and reviews free of charge to our audience. To help keep us going, please take a brief moment to follow us on any of the networks you have an account on.

We've detected an Ad-Blocker

It appears as though you are using an ad blocking program. Sites like are only able to provide content for free with support from our sponsors.

Please consider disabling your ad blocking program on our site. Thank you.