FYI: my bash amc startup script

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
TheBigGuy
Posts: 7
Joined: 21 Jun 2015, 05:21

FYI: my bash amc startup script

Post by TheBigGuy »

Many thanks to the author of FileBot, and other forum members for their scripting help.

I figured the least I could do would be to share my script. I thought I would post my bash amc.groovy startup script. It includes a couple of other features not included in the FileBot amc.groovy script. I really can't take credit for any of the scripting additions as I am a complete Linux newbie. i simply modified bash code I found at other sites online. So, i am really not competent to answer any detailed scripting questions. i just figured I would share, in the hope it might benefit someone looking for these added features.

#Line 2 - renames original nfo file to .info, so that the source information can be retained (not over-written) when .nfo file is scraped.
#Lines 3-16 This script joins all multipart avi files that are named cd1, cd2, CD1, CD2. Many avi movies downloaded from the newsgroups are slpit into 700MB sizes. It uses avimerge from the transcode package included in many Linux distros to automagically merge split avi files.
#Line 17 FileBot amc.groovy script paramaters to rename and download all movie and tv pics,nfo's, and subs. Scaped media is moved to respective Movie & TV folders when completed.

I run this script as my default post proccessing script with Sabnzbd for movies and TV series dowloaded from Newsgroups. I simply start the script manually for post processing torrents that i have downloaded. i prefer to use the Tixati bittorent client. Tixati does not include an option to automatically launch a post process script after torrent completion.

Any comments, or suggestions for script improvement appreciated:

Code: Select all

#!/bin/bash
find "/home/big_guy/Downloads/Media/" . -name "*.nfo" -exec bash -c 'mv "$1" "$(sed "s/\.nfo$/.info/" <<< "$1")"' - '{}' \; ; 
for FIRST in ./*.cd1.avi; do
   NAME=$(basename "$FIRST" .cd1.avi)
   REST=("./$NAME".cd[^1].avi)
   avimerge -o "$NAME.avi" -i "$FIRST" "${REST[@]/#}" 
   rm "$FIRST"
   rm "${REST[@]/#}"
done ;
for FIRST in ./*.CD1.avi; do
   NAME=$(basename "$FIRST" .CD1.avi)
   REST=("./$NAME".CD[^1].avi)
   avimerge -o "$NAME.avi" -i "$FIRST" "${REST[@]/#}" 
   rm "$FIRST"
   rm "${REST[@]/#}"
done ;
java -jar /home/big_guy/FileBot/FileBot.jar -script fn:amc --output "/home/big_guy/Downloads/Scraped/" --action move -non-strict "/home/big_guy/Downloads/Media/" --def music=y subtitles=en artwork=y extras=y unsorted=y minFileSize=0 minLengthMS=0 root=y clean=y --def root=y  --def "ignore=[.](info)$"--def "exts=txt|jpg|jpeg|png|gif|xml|htm|html|log|md5|sfv|rtf|url|srv|srs|srr|nzb|par1|par2|sfv" "terms=sample|trailer"excludeList=amc.txt --def "movieFormat=Movies/{n} ({y})/{n} ({y}){'.cd'+pi}" --def "seriesFormat=TV/{n}/{n} - Season {s}/{n} - {S00E00} - {t}" 

#Line 1 - Bash Shebang - do not alter
#Line 2 - renames original nfo file to .info, so that the source information can be retained (not over-written). This line cane be removed if this feature is unwanted.
#Lines 3-16 This script joins all multipart avi files that are named cd1, cd2, CD1, CD2. It uses avimerge from the transcode package included in many Linux distros to merge split avi files.
#Line 17 FileBot amc.groovy script paramaters to rename and download all movie and tv pics,nfo's, and subs. Scaped media is moved to respective Movie & TV folders when completed.

#Renames all movie subtitles that have "eng" suffix appended.
#java -jar /home/big_guy/FileBot/FileBot.jar -script fn:replace --def "e=.eng.srt" "r=.srt" /home/big_guy/Downloads/Scraped/Movies/

#Save script as amc.sh - make script executable with chmod +x in terminal
TheBigGuy
Posts: 7
Joined: 21 Jun 2015, 05:21

Re: FYI: my bash amc startup script

Post by TheBigGuy »

My apologies i am not familiar with the forum functions to post code. My script was posted with word wrap enabled. The code should of course be on a single line where it was word wrapped.
TheBigGuy
Posts: 7
Joined: 21 Jun 2015, 05:21

Re: FYI: my bash amc startup script

Post by TheBigGuy »

I should mention the cd merge portion of the script also automatically deletes the multi part sources after the separate avi files are joined into a single avi. Remove the code below if you are concerned about having the source files deleted. Be very careful if you experiment with this code, as it may delete all other files in the base directory if you carelessly experiment with these commands:


rm "$FIRST"
rm "${REST[@]/#}"
User avatar
rednoah
The Source
Posts: 23953
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: FYI: my bash amc startup script

Post by rednoah »

I don't recommend using java -jar FileBot.jar to run filebot. You're bypassing a lot of potentially important config that is set via filebot.sh startup script. Always call filebot by calling filebot.sh please.
:idea: Please read the FAQ and How to Request Help.
TheBigGuy
Posts: 7
Joined: 21 Jun 2015, 05:21

Re: FYI: my bash amc startup script

Post by TheBigGuy »

Thank you for your advice. I have only recently started using Linux and FileBot. Steep learning curve for an old dog in his fifties migrating from Windows. Thank you so much for creating such a feature rich program. its capabilities are amazing.I only wish i had 1/100th of your scripting knowledge.
Thanks again
TheBigGuy
Posts: 7
Joined: 21 Jun 2015, 05:21

Re: FYI: my bash amc startup script

Post by TheBigGuy »

Thank you for your advice on how to launch my script rednoah. I have done as you suggested and am now starting via the filebot.sh script. I hope this is the correct manner (seems to work correctly).

Code: Select all

/home/big_guy/FileBot/filebot.sh -script fn:amc --output "/home/big_guy/Downloads/Scraped/" --action move -non-strict "/home/big_guy/Downloads/Media/" --def music=y subtitles=en artwork=y extras=y unsorted=y minFileSize=0 minLengthMS=0 root=y clean=y --def root=y  --def "ignore=[.](info)$"--def "exts=txt|jpg|jpeg|png|gif|xml|htm|html|log|md5|sfv|rtf|url|srv|srs|srr|nzb|par1|par2|sfv" "terms=sample|trailer"excludeList=amc.txt --def "movieFormat=Movies/{n} ({y})/{n} ({y}){'.cd'+pi}" --def "seriesFormat=TV/{n}/{n} - Season {s}/{n} - {S00E00} - {t}" 
TheBigGuy
Posts: 7
Joined: 21 Jun 2015, 05:21

Re: FYI: my bash amc startup script

Post by TheBigGuy »

Not sure how to post code without word wrap. Perhaps someone could gave me a tip on the correct procedure.

Also, I was hoping to have my renamed ".info" files automatically moved to the destination folders with all the other scraped media files. The ".info" files are currently being left in the original folder and I would prefer them to be moved with all the other associated media files. Sorry for the noob question, but method has been unclear to me.
User avatar
rednoah
The Source
Posts: 23953
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: FYI: my bash amc startup script

Post by rednoah »

Not sure if it's because it simply doesn't process .nfo files, or because it doesn't accept .info extensions. Either way, out of luck.
:idea: Please read the FAQ and How to Request Help.
TheBigGuy
Posts: 7
Joined: 21 Jun 2015, 05:21

Re: FYI: my bash amc startup script

Post by TheBigGuy »

Oh well, that's too bad. I will continue to move them manually for files that I want to retain the source info. Thank you for all your help, and for developing such a versatile program.
Post Reply