sualfred 677 Posted May 16, 2018 Share Posted May 16, 2018 (edited) I faced a lot of broken trailer links in my movie collection these days so I decided to switch over to store the trailers locally in my media folders. To save a lot of time I've made this small bash script, which downloads the YT Trailer by fetching the TheMovieDB ID right out the existing movie nfo. Link: https://raw.githubusercontent.com/sualfred/personal_scripts/master/trailerdl/trailerdl.sh Requirements: Linux KnowHow A own TheMovieDB API (see https://developers.themoviedb.org/3 ) youtube-dl / curl / jq Adjustment of the paths inside of the script A clean folder structure without additional and unnecessary nfo's The trailers are going to be stored next to the movie with the prefix "-trailer". You will get a trailerdl.log after each run to check which movies don't have a YT ID or if the download has failed. Please visit https://themoviedb.org and edit or add new trailer links so other users can benefit. (I spent the last 2 hours adding 100< updated trailer url's) And before I forget it: The script is quick'n'dirty, but it's working. Feel free to adjust it if you want, but don't hope for support from my side -> Just sharing it. If you want to say thanks: A beer is appreciated Edited May 16, 2018 by sualfred 6 Link to comment Share on other sites More sharing options...
sualfred 677 Posted May 16, 2018 Author Share Posted May 16, 2018 Reworked the script to use the themoviedb API. Link to comment Share on other sites More sharing options...
vitaminb 0 Posted August 5, 2018 Share Posted August 5, 2018 thank you! works like a charm Link to comment Share on other sites More sharing options...
vze22jjw 1 Posted December 31, 2018 Share Posted December 31, 2018 I just ran across this and works great with minimal effort! Yes you need some linux skill, but with a firetv and no access to youtube trailers this is a great workaround. Respect! 1 Link to comment Share on other sites More sharing options...
neik 835 Posted January 1, 2019 Share Posted January 1, 2019 (edited) Danke, @@sualfred! Does this also work for series? Edited January 1, 2019 by neik 1 Link to comment Share on other sites More sharing options...
sualfred 677 Posted January 1, 2019 Author Share Posted January 1, 2019 Only for movies. Link to comment Share on other sites More sharing options...
nagetech 66 Posted January 5, 2019 Share Posted January 5, 2019 This script looks super handy! Is there a way to accomplish this in Windows? Link to comment Share on other sites More sharing options...
sualfred 677 Posted January 5, 2019 Author Share Posted January 5, 2019 Just use the Linux subsystem of windows: https://docs.microsoft.com/en-us/windows/wsl/install-win10 Link to comment Share on other sites More sharing options...
nagetech 66 Posted January 5, 2019 Share Posted January 5, 2019 Thanks for that share! I'm actually running Server 2012, would that still work? Link to comment Share on other sites More sharing options...
syralk 12 Posted January 13, 2019 Share Posted January 13, 2019 Thanks for that share! I'm actually running Server 2012, would that still work? Hi @@nagetech, I have a similar setup, emby are running in windows so the setup I did is 1. Share your drive in Windows for network accesss 2. Install Linux in Hyper-V 3. connect your share drive in linux 4. Run the scripts in Linux using your share windows access 5. then at the bottom of the script add curl --data '' "http://[emby_local_ip]:[emby_local_port]/Emby/Library/Refresh?api_key=[emby_api]" Link to comment Share on other sites More sharing options...
syralk 12 Posted April 22, 2019 Share Posted April 22, 2019 @@sualfred just to let you know I was able to edit your script to auto download TV Shows trailer https://raw.githubusercontent.com/syralk/trailer_show/master/trailerdl_shows.sh fell free to share or edit it 2 Link to comment Share on other sites More sharing options...
neik 835 Posted April 22, 2019 Share Posted April 22, 2019 Thanks a lot for sharing your work, very much appreciated. :-) Hoppefully I can give both a try in the next couple of days. Link to comment Share on other sites More sharing options...
mickmik 0 Posted June 11, 2019 Share Posted June 11, 2019 Thanks ! Really useful ! Link to comment Share on other sites More sharing options...
neik 835 Posted June 19, 2019 Share Posted June 19, 2019 Fyi, for all who want use the script with a flat folder structure, that does not work. I had to move my files to a more "complex" structure: /movies/moviename (year)/moviename.ext Thanks @@sualfred for clarifying this. :-) @@syralk, right know the script is downloading one trailer, would it be possible to download a trailer for each season? @@Luke, does Emby support multiple trailers (one for each season) at all? Link to comment Share on other sites More sharing options...
Luke 37008 Posted June 19, 2019 Share Posted June 19, 2019 Yes. Link to comment Share on other sites More sharing options...
syralk 12 Posted July 5, 2019 Share Posted July 5, 2019 Hi @@neik I think it could be possible I will do some testing and come back to you on this Fyi, for all who want use the script with a flat folder structure, that does not work.I had to move my files to a more "complex" structure: /movies/moviename (year)/moviename.extThanks @@sualfred for clarifying this. :-)@@syralk, right know the script is downloading one trailer, would it be possible to download a trailer for each season?@@Luke, does Emby support multiple trailers (one for each season) at all? 1 Link to comment Share on other sites More sharing options...
syralk 12 Posted August 1, 2019 Share Posted August 1, 2019 Hi @@neik I think it could be possible I will do some testing and come back to you on this Hi @@Luke I was working on the trailer download script to download the season trailer. So I can see the trailer if I put the trailer in ~/videos/Legion (2017)/trailers/video.mp4 but I cannot see the trailer if I put it on ~/videos/Legion (2017)/Season 1/trailers/video.mp4 I cannot see the button trailers appear in the screen of the specific Season 1 Do I miss something? Link to comment Share on other sites More sharing options...
Luke 37008 Posted August 1, 2019 Share Posted August 1, 2019 We haven't added support for that yet. Link to comment Share on other sites More sharing options...
syralk 12 Posted August 1, 2019 Share Posted August 1, 2019 We haven't added support for that yet. Ha ok This is the way how themoviedb.org works, so I tough to use the same way as well will it be possible to add it on the next update? Link to comment Share on other sites More sharing options...
Luke 37008 Posted August 1, 2019 Share Posted August 1, 2019 it's possible for the future. thanks. 1 Link to comment Share on other sites More sharing options...
RobsterUK 22 Posted November 20, 2019 Share Posted November 20, 2019 @@sualfred Just wanted to post my gratitude for this script. Works really well.I run my server on an XPENology (Synology) NAS. Wasn't able to get the script runing natively on there - it has an ash shell and the bash commands wouldn't run.But I installed a Debian docker container and got it up & running on there! I've also had to edit a few entries on TMDB so hope others benefit from that! 1 Link to comment Share on other sites More sharing options...
guardianali 12 Posted March 18, 2020 Share Posted March 18, 2020 I installed the windows 10 bash option. In an elevated powershell, i run the script but the below happens. V:\test>bash trailerdl.sh tee: //trailerdl.log: Permission denied tee: //trailerdl.log: Permission denied Movie Path: Movies/Arena tee: //trailerdl.log: Permission denied Processing file: Arena (1989).nfo tee: //trailerdl.log: Permission denied TheMovieDB: https://www.themoviedb.org/movie/44796 trailerdl.sh: line 93: jq: command not found trailerdl.sh: line 93: jq: command not found (23) Failed writing body tee: //trailerdl.log: Permission denied YouTube: n/a Link to comment Share on other sites More sharing options...
dhe 0 Posted March 29, 2020 Share Posted March 29, 2020 I run emby in a docker within unraid, will this script work? How should i set it up? Link to comment Share on other sites More sharing options...
plaidstallion 9 Posted October 31, 2020 Share Posted October 31, 2020 (edited) On 5/16/2018 at 9:51 AM, sualfred said: ... The script is quick'n'dirty, but it's working. Feel free to adjust it if you want, but don't hope for support from my side -> Just sharing it. If you want to say thanks: A beer is appreciated I really like this script. I have modified it to start a youtube-dl-server container in docker, download the file and the stop/rm the container. I have started to get it to work but it stops after the first successful trailer download. I don't see why though as there is the for i in "${PATHS[@]}" Also it seems to read the name of the movie from the name of the nfo file. My nfo files are "movie.nfo" but the folder names (the movie names) have (year) in them. Any ideas for another way to name the trailer appropriately? Really cool and thanks for the effort. If I get the re-write working I will post it for here for peeps. I have gotten a script that mostly works for me. I was not able to figure out how to use youtube-dl in a docker container as it stops after the first action. I left it in the comments though in case anyone wants to tinker with it. I am reading the name of the movie from the contents of the first nfo file it encounters in the directory instead of taking the name from the title of the *.nfo file itself. As I have multiple .nfo files in some directories and some are named movie.nfo, due to diffferent programs with their fingers in the metadata, I needed to make some adjustments. Another thing is I can't figure out how to format this string properly at line 89: if ! [ -f "$DIR/$OUTFILENAME-trailer.mp4" ] || [ $OVERWRITE = "true" ]; then I would like to have it proceed ONLY if it doesn't find ANY files in the current target $DIR that have *trailer* in the name. As there are spaces in the directory structure names, I am not quite sure how to format that with the variable and the glob. The script still works though as it will just take the next steps and then tell you there is already a file there by that name. It adds unnecessary run time to the script though. So I am posting this here in case anyone is interested in taking it to the next level. https://raw.githubusercontent.com/Plaidstallion/Personal-Scripts/main/youtube-trailer-downloader.sh Edited November 1, 2020 by plaidstallion Added content 1 Link to comment Share on other sites More sharing options...
K22R8CT 24 Posted June 1, 2022 Share Posted June 1, 2022 Handy script, thanks. I found one minor bug. To fix, replace: FILENAME=$(ls "$DIR" | egrep '\.nfo$' | sed s/".nfo"//g | sed "\/-trailer$/d") with: FILENAME=$(ls "$DIR" | egrep '\.nfo$' | sed s/"\.nfo"//g | sed "\/-trailer$/d") (escaped ".") You won't trigger it unless you happen to have a movie with the character string "nfo" in its title. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now