Monitors a UPnP device, logs changes into a database and checks in episodes to trakt.tv
Monitors an UPnP device, logs changes into a database and checks in new episodes to trakt.tv.
UPnP devices are mounted into the file system (by means of djmount
), the content of the »Last Viewed« folder is checked against entries of a database. If new episodes are detected, they are added to the database and checked in to trakt.tv.
Made for OS X and Linux.
Install needed stuff (see Prerequisites), initialize the trakt.tv connection (see PyTrakt docu), watch something new and run
./upnptrakt.py
UPnPtrakt tracks your last viewed shows as indicated by your UPnP/DLNA devices. It parses the show, retrieves proper (meta) data from trakt.tv and fills up a database. New shows are checked in to trakt.tv.
upnptrakt.py
has quite a few features accessible while calling, just check ./upnptrakt.py --help
.
There's some stuff which has to be on your system in order for UPnPtrakt to work.
As I was unable to find a Python package for monitoring UPnP devices, UPnPtrakt relies on djmount to interface between the current host and all UPnP/DLNA devices in your network.
djmount
is both available in Homebrew and Ubuntu's packages repository. To install, either run (OS X)
brew install djmount
or (Ubuntu)
sudo apt-get install djmount
If your Linux flavor is not Ubuntu, there's probably a package for djmount around for your distro as well. If you're running Windows, I don't know (neither about djmount
nor about this stuff here running at all.)
This Python program uses quite a few packages. All of them can be installed via pip:
pip install guessit psutil simplejson
pip install trakt
Note: I changed the Python trakt interface for v0.2 of UPnPtrakt.
Use createLocalDb.py
to create the necessary SQLite3 database. Use --dropDB
to drop the databasse before recreating it.
Use the setup description of PyTrakt to setup your trakt connection. You need to register an app with trakt and use OAuth for the authentication in the Python library. Chose init()
with the store=True
option so that PyTrakt stores your credentials in ~\.pytrakt.json
. UPnPtrakt is designed to run this way.
Manually test mounting UPnP devices by calling
mkdir test
djmount test
ll test
umount test; rm -rf test
If you get an error you might need to load the FUSE kernel module first: modprobe fuse
)
Calling upnptrakt.py -h
should be pretty much self-explanatory. The default values are tuned for my personal case, you might need to customize them in the call to the script. Especially the --path-to-last-viewed
is probably different for your UPnP/DLNA server (or not, if you're running Serviio on a host named Andisk2…).
Let's get through the parameters, sorted by importance (and then through the flags):
djmount
(see Setup). Don't care too much about trailing / ending slashes. This should be taken care of automatically.Serviio (Andisk2)/Video/Last Viewed
.trakt-config.json
seriesWhitelist.json
episodes.db
djmount
will mount the UPnP network surroundings in..upnpDevices
(yes, it's hidden)Flags provided (all off by default):
djmount
, this flag gets rid of all djmount
process, unmounts the mount path (as provided by --mount-path
) and deletes the folder. Attention: ALL djmount
processes are killed! If you have some other folders in your system mounted with the tool, you might get some funny behavior there.After setting up all needed tools, creating and initial-filling your databse, you probably want to create a cronjob calling upnptrakt.py
every 20 minutes or so.