[GUIDE] XBMCbuntu + Deluge(YaRSS2&Execute) + Filebot AMC

Running FileBot from the console, Groovy / FileBot scripting, shell scripts, etc
Post Reply
User avatar
ashfallen0
Power User
Posts: 32
Joined: 14 Jan 2012, 10:44

[GUIDE] XBMCbuntu + Deluge(YaRSS2&Execute) + Filebot AMC

Post by ashfallen0 » 28 Apr 2013, 06:08

******* FOR i386/32 BIT USERS!**** 64 bit users: Get the appropriate Filebot .deb for your arch!

XBMCbuntu
I'm not going to get into specific details on the setup and installation of XBMCbuntu on your HTPC. Suffice it to say that you need to get the install complete, open a terminal and ssh into it from a remote computer.

Code: Select all

ssh +X 192.168.1.XXX
#^replace the IP with your HTPC's IP

Prep XBMCbuntu
Once you're logged in:

Code: Select all

sudo -s 
add-apt-repository ppa:team-xbmc/ppa
add-apt-repository ppa:deluge-team/ppa
add-apt-repository ppa:shiki/mediainfo
apt-get update
apt-get upgrade
apt-get install deluge deluged cifs-utils gdebi gedit samba mediainfo
exit
xhost +
# I add the xhost + as a wildcard so I can run gtk apps on other terminals, you can substitute "+" with your client IP.

Filebot
Download Filebot : http://www.filebot.net/download.php?mod ... &arch=i386

Code: Select all

sudo gdebi /home/*USER*/Downloads/filebot_3.6_i386.deb
#I just like gdebi, use something else if you want.

Check your libs with another of Rednoah's great scripts!: #run as user, not ROOT!

Code: Select all

filebot -script fn:sysinfo
You should get something very similar to this:
$filebot -script fn:sysinfo
FileBot 3.6 (r1600)
JNA Native: 3.5.0
MediaInfo: MediaInfoLib - v0.7.61
7-Zip-JBinding: OK
Extended Attributes: DISABLED
OpenJDK Runtime Environment 1.7.0_21
32-bit OpenJDK Server VM
Linux (i386)
Done ヾ(@⌒ー⌒@)ノ
$

If all that looks good, filebot is installed properly. #If not, google the error, I had to reinstall mediainfo to get it working once.

Next: Scripts and gimmicks! :D
Last edited by ashfallen0 on 28 Apr 2013, 08:02, edited 1 time in total.
Image PHPBB3 hates me.

User avatar
ashfallen0
Power User
Posts: 32
Joined: 14 Jan 2012, 10:44

[GUIDE] XBMCbuntu + Deluge(YaRSS2&Execute) + Filebot AMC

Post by ashfallen0 » 28 Apr 2013, 07:13

Scripts and Gimmicks!

Directory Structures:
#I have multiple drives for the os(raid 1), anime, tv, movies, music, torrent temp, and an external qnap running a squid proxy and log storage. For the sake of my use case and this guide directories are as follows:
AS USER!:

Code: Select all

mkdir 
/home/*USER*/mount
/home/*USER*/mount/torrent
/home/*USER*/mount/anime
/home/*USER*/mount/tv
/home/*USER*/mount/movies
/home/*USER*/mount/music
/home/*USER*/mount/log 
/home/*USER*/mount/torrent/.tmp
#now, these can just as easily be directories instead of drive roots, but IMUC they're drive roots. The reason is not the mount points, but their relationship structure.
Plug in whatever drives so that the computer mounts them. *should happen automagically in /media/*USER*/
In Terminal (ssh session)

Code: Select all

sudo blkid >> /home/*USER*/UUID.txt
sudo gedit /etc/fstab /home/*USER*/UUID.txt
Add the following to your fstab:
#----------------------------------LOCAL BLOCK DEVICES----------------------------------------------------
UUID=D0948*****8DE676 /home/*USER*/mount/anime ntfs rw,auto,noexec,nosuid 0 0
UUID=40284A*****A3AE4 /home/*USER*/mount/tv ntfs rw,auto,noexec,nosuid 0 0
UUID=F21843*****3759F /home/*USER*/mount/movies ntfs rw,auto,noexec,nosuid 0 0
UUID=5E04C9*****9ABF9 /home/*USER*/mount/torrent ntfs rw,auto,noexec,nosuid 0 0
UUID=5E04C9*****9ABF9 /home/*USER*/mount/music ntfs rw,auto,noexec,nosuid 0 0
UUID=5E04C9*****9ABF9 /home/*USER*/mount/log ntfs rw,auto,noexec,nosuid 0 0
# NOTE: the UUID's will be different for your drives. Your Filesystems will be different too, reference only.

Code: Select all

sudo umount -a
sudo mount -a
#Causes system to remount volumes in their new homes.

Installing RSS for Deluge:
Download YaRSS2: https://bitbucket.org/bendikro/deluge-y ... /downloads
#download YaRSS2-1.2.1-py2.7.egg (the other is for M$ users)
In terminal (SSH) session:

Code: Select all

deluge
when the deluge gtk pops up, open options:
Downloads->
  • Download to: /home/*USER*/mount/torrent/.tmp
    Options: Make sure add torrents in paused state is UNchecked
Interface->
  • Classic Mode: UNCHECK!
    Add torrents Dialog: UNCHECK "always show" and "Bring dialog to focus"
Daemon->
  • Port: I leave as default, YMMV, just note the port.
    Connections: CHECK "Allow Remote Connections"
Plugins->I use:
  • Blocklist
    Execute
    YaRSS2
to add the PyEGG we downloaded earlier, click install plugin and choose the yarss2 egg.
You should see three new options on your left column. Execute, Blocklist, YaRSS2.
File--> Quit.
I'll come back to deluge in a moment.

NEXT: Actual Scritping, and less gimicks!
Image PHPBB3 hates me.

User avatar
ashfallen0
Power User
Posts: 32
Joined: 14 Jan 2012, 10:44

[GUIDE] XBMCbuntu + Deluge(YaRSS2&Execute) + Filebot AMC

Post by ashfallen0 » 28 Apr 2013, 08:01

Actual Scripting!

We left off with:
  • 1. XBMCbuntu with PPA's and upgrades!
    2. Filebot and all dependancies resolved!
    3. Deluge Prepped.
#I use several scripts for Logging/checkbacks/crashes. You can get away with the minimum of the filebot script, but I would suggest this setup:
Terminal (ssh session)

Code: Select all

cd ~
touch deluged_added.sh deluged_execute.sh deluged_startup.sh getlabels.py
chmod +x deluged_added.sh deluged_execute.sh deluged_startup.sh getlabels.py
gedit deluged_added.sh deluged_execute.sh deluged_startup.sh getlabels.py
#again I use gedit, you can use nano or vi/vim or whatever.
IN GEDIT:deluged_added.sh:

Code: Select all

#!/bin/bash
TORRENT_ID=$1
TORRENT_NAME=$2
TORRENT_PATH=$3

#My Variables:
NOW=$(date +"%m_%d_%Y")
CHECK=$(hostname)
LOG="/home/*USER*/mount/log/$CHECK.deluged_added.$NOW.log"

echo "Torrent Details"+$NOW+$TORRENT_NAME+$TORRENT_PATH+$TORRENT_ID  >> $LOG
#this will create a tab-deliniated, host and Date-stamped log file to see what all has been added, great for multiuser deluge installs. Also, this allows you to compare against the next script in case you miss files or a server crash.

IN GEDIT:deluged_execute.sh:

Code: Select all

#!/bin/bash
TORRENT_ID=$1
TORRENT_NAME=$2
TORRENT_PATH=$3

#My Variables:
NOW=$(date +"%m_%d_%Y")
CHECK=$(hostname)
LOG="/home/*USER*/mount/log/$CHECK.deluged_complete.$NOW.log"
LOG2="/home/*USER*/mount/log/$CHECK.deluged_filebot.$NOW.log"
TORRENT_LABEL=$(/home/*USER*/.config/deluge/getlabel.py $TORRENT_ID)

echo "Torrent Details"+$TORRENT_NAME+$TORRENT_PATH+$TORRENT_ID+$TORRENT_LABEL >> $LOG

filebot -script fn:amc --output "/home/*USER*/mount/" --action move --conflict override -non-strict --def "seriesFormat=tv/{n.replaceAll(\":\", replacement = \" -\")}/{n.replaceAll(\":\", replacement = \" -\")} - {'S'+s.pad(2)}E{e.pad(2)} - {t} [{hpi}][{resolution} {vc}-{ac}]" "animeFormat=anime/{n.replaceAll(\":\", replacement = \" -\")} - ({y})/{n.replaceAll(\":\", replacement = \" -\")} - {'S'+(episode.season ? s : 1).pad(2)}E{e.pad(2)} - {t} [{hpi}][{resolution} {vc}-{ac}]" "movieFormat=movies/{n.replaceAll(\":\", replacement = \" -\")} - ({y})/{n.replaceAll(\":\", replacement = \" -\")} - ({y}) - [{hpi}][{resolution} {vc}-{ac}]" "musicFormat=music/{n}/{fn}" --def music=y --def clean=y --def xbmc=localhost --def artwork=y "ut_dir=$TORRENT_PATH/$TORRENT_NAME" "ut_label=$TORRENT_LABEL" "ut_kind=multi" "ut_title=$TORRENT_NAME" >> $LOG2
#this actually initiates the filebot actions, getting, checking, scraping, renaming, moving, creating nfo, getting artwork, notify xbmc etc... This is where the customizing for yourself comes in. I could make a whole post on getting all that to work, but there is plenty of examples elsewhere by Rednoah an others on what works. This ALSO makes the counterpart log to the added log to compare in crash issues. Finally, it outputs the cmdline output to a second log for trace purposes, for when you know you finished an episode or movie, but it's not where it should be (i.e. The muppet show torrents are in DVD order, and TVDB has them in AIRDATE order, so 1 or 2 will come out as random shows from europe.)

IN GEDIT:deluged_startup.sh:

Code: Select all

#!/bin/bash

#Variables:
USER="*USER*" #Set Linux Mint, Ubuntu, or Debian user name here.
NOW=$(date +"%m_%d_%Y_%H_%M")
CHECK=$(hostname)
FILE="/home/*USER*/mount/log/$CHECK.deluged_debug.$NOW.log"

# Check if Deluge Demon is running, and start as necessary :D
if ps aux | grep "[d]eluged" > /dev/null
then
    exit 99
else
    sudo -u $USER -EH deluged -L debug -l "$FILE"
fi
IN GEDIT:getlabels.py:

Code: Select all

#!/usr/bin/python

import sys
from deluge.ui.client import client
from twisted.internet import reactor

# Set up the logger to print out errors
from deluge.log import setupLogger
setupLogger()

d = client.connect()

torrent_id = sys.argv[1]

def on_connect_success(result):
    def on_get_torrent_status(torrent):
        print torrent["label"]
        client.disconnect()
        reactor.stop()

    client.core.get_torrent_status(torrent_id, ["label"]).addCallback(on_get_torrent_status)

d.addCallback(on_connect_success)

def on_connect_fail(result):
        print result
        reactor.stop()

d.addErrback(on_connect_fail)

reactor.run()
#this bit will actively call the label info from deluge! You NEED to activate the labels plugin for this to work!

SAVE ALL AND EXIT GEDIT!!!!
Next: Placing scripts, crontab, cleanup.

*EDIT- I have a working script to pull labels from deluge, and have edited the scripts/guide to that effect.
Last edited by ashfallen0 on 28 Apr 2013, 20:14, edited 1 time in total.
Image PHPBB3 hates me.

User avatar
ashfallen0
Power User
Posts: 32
Joined: 14 Jan 2012, 10:44

[GUIDE] XBMCbuntu + Deluge(YaRSS2&Execute) + Filebot AMC

Post by ashfallen0 » 28 Apr 2013, 09:03

Placing scripts, crontab, cleanup.

So now we need to place our handiwork and do a little hacking.

In Terminal (ssh session):

Code: Select all

cp deluged_added.sh /home/*USER*/.config/deluge/
cp deluged_execute.sh /home/*USER*/.config/deluge/
cp getlabels.py /home/*USER*/.config/deluge/
sudo cp deluged_startup.sh /etc/xbmc/live.d/
#scripts are placed, now some editing:

Code: Select all

sudo gedit /home/*USER*/.config/deluge/auth /etc/crontab
in AUTH: You will see this:

Code: Select all

localclient:5a-andalongstringofnumbershere63e:10
add:

Code: Select all

USER:PASSWORD:10
#make sure to change that to something else!!!! ;)
save and close auth.
In crontab add the following line:

Code: Select all

0 * * * * 	root	/etc/xbmc/live.d/deluged_startup.sh
save and close crontab
#This will run your deluge daemon startup script every hour. I know it looks like you're running this as root, but if you set your username in the script, it will change user to you to run the daemon. It will check to see if you are running the daemon already(as you), and if not start it back up. Now since the cron command happens on startup BEFORE the mount command, not seeing a debug log in your log folder ISN'T a bad thing. That's normal. If Deluged crashes, when that script is called by cron, it will then have the access to the directory and you will see a debug log appear. No news is good news!

Btw, to check if the crontab entry is working(give it an hour or 2):

Code: Select all

cat /var/log/syslog | grep xbmc

Code: Select all

sudo reboot


wait for reboot, and ssh back in again.
check deluge daemon:

Code: Select all

ps aux | grep deluged
Now BACK TO DELUGE!
#If you want, you can still use your xhost'ed gtk to run, but since we added ourselves to the auth file, if you install just deluge on your remote/client computer, you can run it that way. Option "A".(less network and resource baggage), else option "B"

OPTION A: If you choose to run the GTK on your remote/client computer, open it up, go into OPTIONS->Interface->Classic Mode: UNCHECK!
Close options, and you should see another icon next to the options that looks like a network icon, click that.
In the "Connection Manager" you should see something like 127.0.0.1 or localhost. Click the ADD button.
HOSTNAME: your HTPC's IP address.
USERNAME: whatever you put in the "auth" file
PASSWORD: whatever you put in the "auth" file
PORT: default or whatever you chose earlier.
Click ADD.
if everything is running smoothly at this point, you should see a new host in your connection manager with a nice checkmark if the GTK sees the daemon AND IF THE AUTH INFO IS CORRECT!!!!!*I really can't stress that enough*
Click "Connect", and go to "NEXT STEP:"

OPTION B: So you're using xhost'ed gtk. tidy, but limits your abilities later.

Code: Select all

deluge
in Connection Manager, open options [+] and check all 3 checkboxes. Since you are xhosting the session, localhost is which session you want, but you're limited to one connection.
Click "Connect", and go to "NEXT STEP:"

NEXT STEP: ;)
Open Options:
-->Execute:
Add Command: EVENT: Choose Torrent Added, in the space provided place

Code: Select all

/home/*USER/.config/deluge/deluged_added.sh
CLICK "+ADD"
Add Command: EVENT: Choose Torrent Complete, in the space provided place

Code: Select all

/home/*USER/.config/deluge/deluged_execute.sh
CLICK "+ADD"
CLICK APPLY, THEN OK
Choose File-> Quit and Shutdown Daemon
in terminal:

Code: Select all

deluged
Reconnect and make sure the execute options stuck.

CLEANUP:
In Terminal (ssh session)

Code: Select all

cd ~
mkdir /home/*user*/.config/userscripts
mv *.sh /home/*user*/.config/userscripts

NEXT: XBMC
Last edited by ashfallen0 on 28 Apr 2013, 20:18, edited 1 time in total.
Image PHPBB3 hates me.

User avatar
ashfallen0
Power User
Posts: 32
Joined: 14 Jan 2012, 10:44

[GUIDE] XBMCbuntu + Deluge(YaRSS2&Execute) + Filebot AMC

Post by ashfallen0 » 28 Apr 2013, 09:37

XBMC and the HOME STRETCH!
#I would use a usb keyboard to your htpc to do the last parts. ;)

In XBMC:
#I don't know which skin is your preference, so I'm going to use MAJOR headings
--------------TV----------------
Choose Videos: FILES
Choose ADD VIDEOS
Choose BROWSE
Choose HOME FOLDER
Choose MOUNT
Choose TV
Choose "OK" # it should say TV under "Choose a name for this folder" already, if not change it!
Choose "OK"
"SET CONTENT"
FOLDER CONTAINS: Choose TV shows, "RIGHT" to THE TVDB, hit "ENTER" and Choose OK
#IF XBMC asks to scan that source, you can, or do it later.

--------------MOVIES----------------
Choose ADD VIDEOS
Choose BROWSE
Choose HOME FOLDER
Choose MOUNT
Choose MOVIES
Choose "OK" # it should say MOVIES under "Choose a name for this folder" already, if not change it!
Choose "OK"
"SET CONTENT"
FOLDER CONTAINS: Choose MOVIES, "RIGHT" to THE THE MOVIE DATABASE, hit "ENTER" and Choose OK
#If you stick with the naming scheme I used earlier in the filebot script, make sure to choose " Movies are in separate folders that match the movie title"
##IF XBMC asks to scan that source, you can, or do it later.

--------------ANIME----------------
Choose ADD VIDEOS
Choose BROWSE
Choose HOME FOLDER
Choose MOUNT
Choose ANIME
Choose "OK" # it should say ANIME under "Choose a name for this folder" already, if not change it!
Choose "OK"
"SET CONTENT"
FOLDER CONTAINS: Choose TV shows, "RIGHT" to "GET MORE" and install "ANIDB", once installed choose that, hit "ENTER" and Choose OK

--------------MUSIC----------------
Choose MUSIC: FILES
Choose ADD SOURCE
Choose BROWSE
Choose HOME FOLDER
Choose MOUNT
Choose MUSIC
Choose "OK" # it should say MUSIC under "Choose a name for this folder" already, if not change it!
Choose "OK"
:!: Press "C" to bring up the context menu for the music source you just added, and select "Scan items to Library" they won't show up without that!!!!

------DONE!!!!!------

PS. I know some of you are thinking, what about config of YaRSS2 and Blocklist? Well those plugins are well documented elsewhere. :mrgreen:

PPS. Unplug your keyboard after updating the library, and I would suggest one reboot just to catch the kinks.

PPPS. :lol: The reason I pointed out the remote GTK function is so that even your M$ and @pple users in the house can install the deluge gtk and connect. They can use the credentials you use, or you can add credentials for them(in the auth file). Once you add that, they can set deluge to be the default client for Magnets and Torrents. When they add new content, it gets downloaded on the HTPC, Renamed, Sorted, and reported to XBMC!

And FINALLY,
So that I (hopefully don't get alot of fire) can make sure everything works ok for you all out there, Make ABSOLUTELY SURE to change all the instances of *USER* to YOUR USERNAME!!!!!!


I hope this guide helps anyone out. It took ALOT of RTFM and GOOGLE, and a GREAT DEAL of insight from Rednoah to make it work for me. I did this whole setup when my old htpc tanked in about 4 hours; YMMV depending on download/equipment speeds.

--Ash
Image PHPBB3 hates me.

Post Reply