Porting the XBMC subtitles plugin as a PMS Metadata Agent

For XBMC there exist an Add-on that searches a bunch of different sites for subtitles. It would be great if it were possible to reuse and extend the OpenSubtitles Agent to support more sources…





Here is a link to the xbmc.script: http://github.com/amet/script.xbmc.subtitles/tree/master/script.xbmc.subtitles/resources/lib/services



I’ve started a bit on implementing support for undertexter.se but I’m a bit stuck, in the opensubtitles.org agent they are using p.openSubtitleHash, what other variables can be found for the “p” object?



I would like to have the whole filename to match with (i.e. Tron.Legacy.2010.BluRay.720p.DTS.x264-CHD) that will match the exactly right sub for me, is that some how possible?



What methods can I use in my agent, am I allowed to do import of other libs and what libs/methods are available?





  def update(self, metadata, media, lang):<br />
    HTTP.Headers['User-agent'] = 'plexapp.com v9.0'<br />
    <br />
    proxy = XMLRPC.Proxy(OS_API)<br />
    for i in media.items:<br />
      for p in i.parts:<br />
        token = proxy.LogIn('', '', 'en', OS_PLEX_USERAGENT)['token']<br />
        langList = [Prefs["langPref1"]]<br />
        if Prefs["langPref2"] != 'None':<br />
          langList.append(Prefs["langPref2"])<br />
        for l in langList:<br />
          Log('Looking for match for GUID %s and size %d' % (p.openSubtitleHash, p.size))<br />
          subtitleResponse = proxy.SearchSubtitles(token,[{'sublanguageid':l, 'moviehash':P.openSubtitleHash, 'moviebytesize':str(p.size)}])['data']

Ok, greks like I’m talking to myself here…



I’m pretty far in creating a subtitle agent, but have one issue… The files I download is packed with rar, in the XBMC script mentioned above they are using the following function


     xbmc.executebuiltin("XBMC.Extract(" + local_tmp_file + "," + tmp_sub_dir +")")



Arethere any good practice how to handle rar-archives in a PMS-agent?

You can find information about the media object in : /Users/YOUR_USER_HOME_DIRECTORY/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/2/Models



You can find in the framework bundle, all the object and methods you can use.



Hey erlis!

Thanks for working on this. It's long overdue Plex comes out with a nice subtitle-fetching add-on. Please, keep us posted on how this develops.

Any news?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.