Plex Media Server scrobbler for trakt.tv


Without trying to be rude, but if you would have read this thread some more then you would know that there is no plugin yet. It's only a Python script which can be installed and started manually for now.

Great!! Thank you!!! Just installed the script and seems to work beautifully with iPad iPhone appletv & macmini clients :slight_smile:



no offense .. but i read the thread twice before i asked...
this thread is not clear about that...
it goes from a conversation about the script to installing a plugin into the plugins folder of plex to cleaning up the script again ...
the thread hints several times about the plugin being worked on ... but never stated the progress .. or even if he needs help testing it ...
so now you have answered my question clearly...
thanks for that ...
i will be waiting for the plugin to finish ....


I think this is quite clear.
There is a plugin in the dev branch but it cannot scrobble. If you wan't you could try to figure how how to parse the logfile from inside the script since it is the only thing left.

well i added the plugin to plex
but i get this error


2012-01-31 00:32:39,603 (-48c35730) :  CRITICAL (core:453) - Exception starting plug-in (most recent call last):<br />
  File "/mnt/cache/plex/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/core.py", line 441, in start<br />
    self.host.execute(self.init_code)<br />
  File "/mnt/cache/plex/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/code.py", line 652, in execute<br />
    exec(code) in self.environment<br />
  File "/mnt/cache/plex//Application Support/Plex Media Server/Plug-ins/Trakttv.bundle/Contents/Code/__init__.py", line 1, in <module><br />
    import logsucker<br />
  File "/mnt/cache/plex/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/code.py", line 712, in __import__<br />
    raise e<br />
ImportError: No module named ctypes



Which is weird as Ctypes is included in python from python 2.5


and i am running python 2.6.6


I don't understand why you would wan't to install that plugin since it won't work. It is a reason why it is in a dev branch and not the master.

But if you want to help out ignore the ctype error since that module shouln't be needed. When you manage to parse the log file just call the function watch_or_scrobble with item id and position in ms and it should make the cal to trakt.

The problem I have is that you don't have access to file open from inside the plugin and I haven't figured out how to parse without that function.

Sorry not a programmer …

just a guy looking for a plugin that is similar to the XBMC TRAKT plugin

where it can sync watched / unwatched movies/episodes

where it can update the collection and a few other things



I installed first the script but since it only seems to scroble and i can’t find any way to do the other things with it (no gui or webpage as far as i can find … doesn’t show up in Plex either) did i try installing the plugin hoping it would do the rest but that also didn’t work …



only looking for a full blown plugin that does everything …

with a collection of 3800 movies and 32000 TV episodes it is important for me to keep everything synced between all computers in the house and Trakt seemed the way to do that between Plex and Xbmc…



anyway will wait till the plugin is complete


Have you tried specifying the elevated plugin security policy in the info.plist?

<br />
<key>PlexPluginCodePolicy</key><br />
<string>Elevated</string><br />



That's often necessary to allow plugins to do more complicated stuff.



It is already "Elevated" https://github.com/tester22/Plex-Trakt-Scrobbler/blob/develop/Trakttv.bundle/Contents/Info.plist#L22, do you have any other idea since you have done some nice plugins?
I am not so used to working with the plugins.

Ok, tester22 I’ve been watching your code (the Plugin one) And i don’t understand which part is causing you troubles.

I’m guessing : I understand that you need the item_id, but I don’t see where you are getting it from ? Is it that the problem you’re facing ?

Why would you want to “parse” any log oO ?

Doesn’t Plex provide a function to get all the information about the current playing file ? Like its id ^^?

I’d like to get involved because it’s a good idea !



EDIT : So I think i’m not wrong, because this is what I found on the Log :


r. 01, 2012 19:03:20 [888] DEBUG -  * key => 4193<br />
févr. 01, 2012 19:03:20 [888] DEBUG -  * identifier => com.plexapp.plugins.library<br />
févr. 01, 2012 19:03:20 [888] DEBUG -  * time => 47736<br />
févr. 01, 2012 19:03:20 [888] DEBUG -  * state => playing<br />
févr. 01, 2012 19:03:20 [888] DEBUG - Play progress on 4193 '(500) jours ensemble' - got played 47736 ms!


And according to your code "time" and and "key" are the values you juste need !
Again doenst Plex already provide a function for that ?
I'm going to look into that ;).



No Plex doesn't provide that info (http://forums.plexapp.com/index.php/topic/34402-tracklog-whos-watching-what/page__p__219312__hl__current+item__fromsearch__1#entry219312), in the proof of concept I get it using:

<br />
#Set the filename and open the file<br />
file = open(filename,'r')<br />
<br />
#Find the size of the file and move to the end<br />
st_results = os.stat(filename)<br />
st_size = st_results[6]<br />
file.seek(st_size)<br />
<br />
while 1:<br />
    where = file.tell()<br />
    line = file.readline()<br />
    if not line:<br />
        time.sleep(1)<br />
        file.seek(where)<br />
    else:<br />
        #print line, # already has newline<br />
        item_progress = None<br />
        item_id = None<br />
        try:<br />
            m = re.search('progress on (?P<last>\w*?)\s', line)<br />
            m2 = re.search('got played (?P<last>\w*?)\s', line)<br />
            Log("Progress on "+m.group(1)+" is "+m2.group(1)+" ms")<br />
            item_progress = m2.group(1)<br />
            item_id = m.group(1)<br />
        except: pass<br />
        <br />
<br />
<br />
        if item_progress != None and item_id != None:<br />
            status = watch_or_scrobble(item_id, item_progress)<br />
            <br />
            Log('Response: %s' % status['message'])<br />


Ok so you have another script workind BESIDE the actual plugin ?

And you would like to have that script inside your plugin !? Or by anyway getting “time” and “key” informations in your plugin ?



Yes the file script.py from master branch is working if you launch it from cli.
https://github.com/tester22/Plex-Trakt-Scrobbler

But I would like to convert it to a plugin since then it could be installed without any dependencies and would launch/exit just as PMS does.


How come you can't open the log file ?

Another thing I can't see the tab "application" in my Plex (using Aeron) therefore i can't have access to the preference of your plugin. Do you know why ?


Plex is using an isolated enviroment. Not all Python functions is available but there are a number of helper functions.

There must be a way with the tools they give ?

Have you already looked deep into that ?



When I have some time, I'll have a peak at your code and see if I have any brainstorms.

how do i add the following path to the config file? i am running this on unraid.





i am typing in the config file the following:





plexlog_path = ‘/mnt/disk1/plex/Plex Media Server/Logs/’



or





plexlog_path = “/mnt/disk1/plex/Plex Media Server/Logs/”



or





plexlog_path = /mnt/disk1/plex/Plex\ Media\ Server/Logs/



these paths work for the cd command. i keep getting the following in my log:





02/01/2012 09:25:25 PM: Plex Log file not found

02/01/2012 09:31:06 PM: Plex Log file not found

02/01/2012 09:32:55 PM: Plex Log file not found

02/01/2012 09:38:42 PM: Plex Log file not found

02/01/2012 09:40:50 PM: Plex Log file not found

02/01/2012 09:40:54 PM: Plex Log file not found

02/01/2012 09:44:13 PM: Plex Log file not found

02/01/2012 09:44:16 PM: Plex Log file not found

02/01/2012 09:46:30 PM: Plex Log file not found

02/01/2012 09:46:31 PM: Plex Log file not found



thanks for your help! i am new to linux and would love to get this working!

you are only specifying the directory, you need to add the filename.


this is mine from within unraid
plexlog_path = /mnt/cache/plex/Application Support/Plex Media Server/Logs/Plex Media Server.log

that works if only marking viewed is what you want