Plugin won't show up

I am busy with creating a plugin for Break.com



I am quite new with python and plugins and it all went pretty good untill I came to the xml and xpath section.



Can anyone please tell me what i am doing wrong and why the plugin won’t showup in plex any more?



This is what I brought up so far…



from PMS import *<br />
from PMS.Objects import *<br />
from PMS.Shortcuts import *<br />
<br />
VIDEO_TITLE = 'Break.com'<br />
VIDEO_PREFIX = '/video/break'<br />
BREAK_ROOT = 'http://www.break.com'<br />
BREAK_NEWEST = 'http://www.break.com/videos/newest/'<br />
BREAK_MVDAILY = 'http://www.break.com/videos/most-viewed-daily/'<br />
BREAK_MVWEEKLY = 'http://www.break.com/videos/most-viewed-weekly/'<br />
BREAK_MVMONTHLY = 'http://www.break.com/videos/most-viewed-monthly/'<br />
BREAK_MVALLTIME = 'http://www.break.com/videos/most-viewed/'<br />
BREAK_TRDAILY = 'http://www.break.com/videos/top-rated-daily/'<br />
BREAK_TRWEEKLY = 'http://www.break.com/videos/top-rated-weekly/'<br />
BREAK_TRMONTHLY = 'http://www.break.com/videos/top-rated-monthly/'<br />
BREAK_TRALLTIME = 'http://www.break.com/videos/top-rated/'<br />
BREAK_MDDAILY = 'http://www.break.com/videos/most-discussed-daily/'<br />
BREAK_MDWEEKLY = 'http://www.break.com/videos/most-discussed-weekly/'<br />
BREAK_MDMONTHLY = 'http://www.break.com/videos/most-discussed-monthly/'<br />
BREAK_MDALLTIME = 'http://www.break.com/videos/most-discussed/'<br />
BREAK_MSDAILY = 'http://www.break.com/videos/most-shared-daily/'<br />
BREAK_MSWEEKLY = 'http://www.break.com/videos/most-shared-weekly/'<br />
BREAK_MSMONTHLY = 'http://www.break.com/videos/most-shared-monthly/'<br />
BREAK_MSALLTIME = 'http://www.break.com/videos/most-shared/'<br />
<br />
XPATH_VIDEOS = '//div[@class='cat-cnt-item-th']'<br />
<br />
ART           = 'art-back.png'<br />
ICON          = 'icon-main.png'<br />
<br />
<br />
####################################################################################################<br />
<br />
def Start():<br />
<br />
    Plugin.AddPrefixHandler(VIDEO_PREFIX, MainMenu, "Break.com", ICON, ART)<br />
<br />
    Plugin.AddViewGroup("InfoList", viewMode="InfoList", mediaType="items")<br />
    Plugin.AddViewGroup("List", viewMode="List", mediaType="items")<br />
<br />
    MediaContainer.art = R('art-default.png')<br />
    MediaContainer.title1 = "BREAK Videos"<br />
    DirectoryItem.thumb = R('icon-default.png')<br />
<br />
####################################################################################################<br />
<br />
def MainMenu():<br />
    <br />
    dir = MediaContainer(viewGroup="InfoList")<br />
<br />
    dir.Append(Function(DirectoryItem(Video, "Newest",thumb=R(ICON),art=R(ART)), title="Newest", url=BREAK_NEWEST))<br />
 <br />
    dir.Append(Function(DirectoryItem(Video, "Most Viewed Daily",thumb=R(ICON),art=R(ART)), title="Most Viewed Daily", url=BREAK_MVDAILY))<br />
    dir.Append(Function(DirectoryItem(Video, "Most Viewed Weekly",thumb=R(ICON),art=R(ART)), title="Most Viewed Weekly", url=BREAK_MVWEEKLY))<br />
    dir.Append(Function(DirectoryItem(Video, "Most Viewed Monthly",thumb=R(ICON),art=R(ART)), title="Most Viewed Monthly", url=BREAK_MVMONTHLY))<br />
    dir.Append(Function(DirectoryItem(Video, "Most Viewed All Time",thumb=R(ICON),art=R(ART)), title="Most Viewed All Time", url=BREAK_MVALLTIME))<br />
<br />
    dir.Append(Function(DirectoryItem(Video, "Top Rated Daily",thumb=R(ICON),art=R(ART)), title="Top Rated Daily", url=BREAK_TRDAILY))<br />
    dir.Append(Function(DirectoryItem(Video, "Top Rated Weekly",thumb=R(ICON),art=R(ART)), title="Top Rated Weekly", url=BREAK_TRWEEKLY))<br />
    dir.Append(Function(DirectoryItem(Video, "Top Rated Monthly",thumb=R(ICON),art=R(ART)), title="Top Rated Monthly", url=BREAK_TRMONTHLY))<br />
    dir.Append(Function(DirectoryItem(Video, "Top Rated All Time",thumb=R(ICON),art=R(ART)), title="Top Rated All Time", url=BREAK_TRALLTIME))<br />
<br />
    dir.Append(Function(DirectoryItem(Video, "Most Discussed Daily",thumb=R(ICON),art=R(ART)), title="Most Discussed Daily", url=BREAK_MDDAILY))<br />
    dir.Append(Function(DirectoryItem(Video, "Most Discussed Weekly",thumb=R(ICON),art=R(ART)), title="Most Discussed Weekly", url=BREAK_MDWEEKLY))<br />
    dir.Append(Function(DirectoryItem(Video, "Most Discussed Monthly",thumb=R(ICON),art=R(ART)), title="Most Discussed Monthly", url=BREAK_MDMONTHLY))<br />
    dir.Append(Function(DirectoryItem(Video, "Most Discussed All Time",thumb=R(ICON),art=R(ART)), title="Most Discussed All Time", url=BREAK_MDALLTIME))<br />
<br />
    dir.Append(Function(DirectoryItem(Video, "Most Shared Daily",thumb=R(ICON),art=R(ART)), title="Most Shared Daily", url=BREAK_MSDAILY))<br />
    dir.Append(Function(DirectoryItem(Video, "Most Shared Weekly",thumb=R(ICON),art=R(ART)), title="Most Shared Weekly", url=BREAK_MSWEEKLY))<br />
    dir.Append(Function(DirectoryItem(Video, "Most Shared Monthly",thumb=R(ICON),art=R(ART)), title="Most Shared Monthly", url=BREAK_MSMONTHLY))<br />
    dir.Append(Function(DirectoryItem(Video, "Most Shared All Time",thumb=R(ICON),art=R(ART)), title="Most Shared All Time", url=BREAK_MSALLTIME))<br />
<br />
    return dir<br />
<br />
####################################################################################################<br />
<br />
def Video(sender, title, url):<br />
<br />
 dir = MediaContainer(title3=title, art=R(ART), viewGroup="InfoList")<br />
<br />
  videos = XML.ElementFromURL(url, isHTML=True, errors='ignore').xpath(XPATH_VIDEOS)<br />
  for content in videos:<br />
      title = content.xpath("a/img/span")[0].txt<br />
      thumb = content.xpath("/a/img")[0].get('src')<br />
      url = content.xpath("/a")[0].get('href')<br />
<br />
  dir.Append(Function(DirectoryItem(VideoFile, "Test", thumb=thumb), title=title, url=url))<br />
<br />
  return dir<br />
<br />
####################################################################################################<br />
<br />
def VideoFile(sender, title, url):<br />
<br />
  dir = MediaContainer(viewGroup="InfoList")<br />
<br />
        return MessageContainer("Test")

I really should step back here and be quiet as there are tons more qualified guys here, but if you knew me you would know that “quiet” is not a word that describes me all that well :slight_smile: So here we go:

Python is sensitive to indentations, so here comes a longshot: Your last “dir” seem to be one tab-step to far in, or at least a couple of spaces. Im far from being sure on this, but take a lookthrough at your code and maybe you find some more things like that.

Thanks, I am looking at it right now…

The tabs and spaces are all alligned properly now and it stil does not work does anyone perhaps have other suggestions?

And just to be certain, you did add a specific name in your plist so it doesnt have the same name as another plugin? And when you did that you hopefully used Smultron or BBEdit or something similar and not the Apple Plist Editor (which destroys the Plist for reasons I cant remember).

No it does not have the same name as another plugin. I configured it using apple texteditor. But it all worked fine until I started adding more features…





<plist version="1.0"><br />
  <dict><br />
    <key>CFBundleDevelopmentRegion</key><br />
    <string>English</string><br />
    <key>CFBundleExecutable</key><br />
    <string>Hello</string><br />
    <key>CFBundleIdentifier</key><br />
    <string>com.plexapp.plugins.break</string><br />
    <key>CFBundleInfoDictionaryVersion</key><br />
    <string>6.0</string><br />
    <key>PlexFrameworkVersion</key><br />
    <string>1</string><br />
    <key>CFBundlePackageType</key><br />
    <string>AAPL</string><br />
    <key>CFBundleSignature</key><br />
    <string>hook</string><br />
    <key>CFBundleVersion</key><br />
    <string>1.0</string><br />
    <key>PlexPluginMode</key><br />
    <string>AlwaysOn</string><br />
    <key>PlexPluginDebug</key><br />
    <string>1</string><br />
  </dict><br />
</plist>

Ok, “good”. Then I hope someone else can hint you in the right direction. I’ll talk to the other guys and let them know you need help.

Hi,



if you fixed the indentation then nothing jumps out at me. Have to tried running PMS from the command line? That gives you the logging output from PMS and the python engine and will usually tell you where syntax errors are. There is also a PMS.Log() function that will spit out to the terminal and can be very useful.



in a terminal:



killall “Plex Media Server”

~/Library/Application\ Support/Plex/Plex\ Media\ Server.app/Contents/MacOS/Plex\ Media\ Server



Another thing (not the problem). You don’t need to pass title as a parameter into the Video function. It can be obtained from sender (title2=sender.itemTitle).



You can also set up default icon and art in the Start() function to avoid having to specify it on every dir.Append line



MediaContainer.art = R(‘art-default.png’)

DirectoryItem.thumb=R(“icon-default.png”)



hope that helps,

Jonny

Oh, just noticed something.



XPATH_VIDEOS = ‘//div[@class=‘cat-cnt-item-th’]’



is all single quotes. Try



XPATH_VIDEOS = “//div[@class=‘cat-cnt-item-th’]”

yeah, pychecker is picking up the quote thing jonny said on line 26 and the impropper indent on lines 79 to 85 and line 97. the complete cleaned up code that passes syntax checkers looks like:


from PMS import *<br />
from PMS.Objects import *<br />
from PMS.Shortcuts import *<br />
<br />
VIDEO_TITLE = 'Break.com'<br />
VIDEO_PREFIX = '/video/break'<br />
BREAK_ROOT = 'http://www.break.com'<br />
BREAK_NEWEST = 'http://www.break.com/videos/newest/'<br />
BREAK_MVDAILY = 'http://www.break.com/videos/most-viewed-daily/'<br />
BREAK_MVWEEKLY = 'http://www.break.com/videos/most-viewed-weekly/'<br />
BREAK_MVMONTHLY = 'http://www.break.com/videos/most-viewed-monthly/'<br />
BREAK_MVALLTIME = 'http://www.break.com/videos/most-viewed/'<br />
BREAK_TRDAILY = 'http://www.break.com/videos/top-rated-daily/'<br />
BREAK_TRWEEKLY = 'http://www.break.com/videos/top-rated-weekly/'<br />
BREAK_TRMONTHLY = 'http://www.break.com/videos/top-rated-monthly/'<br />
BREAK_TRALLTIME = 'http://www.break.com/videos/top-rated/'<br />
BREAK_MDDAILY = 'http://www.break.com/videos/most-discussed-daily/'<br />
BREAK_MDWEEKLY = 'http://www.break.com/videos/most-discussed-weekly/'<br />
BREAK_MDMONTHLY = 'http://www.break.com/videos/most-discussed-monthly/'<br />
BREAK_MDALLTIME = 'http://www.break.com/videos/most-discussed/'<br />
BREAK_MSDAILY = 'http://www.break.com/videos/most-shared-daily/'<br />
BREAK_MSWEEKLY = 'http://www.break.com/videos/most-shared-weekly/'<br />
BREAK_MSMONTHLY = 'http://www.break.com/videos/most-shared-monthly/'<br />
BREAK_MSALLTIME = 'http://www.break.com/videos/most-shared/'<br />
<br />
XPATH_VIDEOS = "//div[@class='cat-cnt-item-th']"<br />
<br />
ART           = 'art-back.png'<br />
ICON          = 'icon-main.png'<br />
<br />
<br />
####################################################################################################<br />
<br />
def Start():<br />
<br />
    Plugin.AddPrefixHandler(VIDEO_PREFIX, MainMenu, "Break.com", ICON, ART)<br />
<br />
    Plugin.AddViewGroup("InfoList", viewMode="InfoList", mediaType="items")<br />
    Plugin.AddViewGroup("List", viewMode="List", mediaType="items")<br />
<br />
    MediaContainer.art = R('art-default.png')<br />
    MediaContainer.title1 = "BREAK Videos"<br />
    DirectoryItem.thumb = R('icon-default.png')<br />
<br />
####################################################################################################<br />
<br />
def MainMenu():<br />
    <br />
    dir = MediaContainer(viewGroup="InfoList")<br />
<br />
    dir.Append(Function(DirectoryItem(Video, "Newest",thumb=R(ICON),art=R(ART)), title="Newest", url=BREAK_NEWEST))<br />
 <br />
    dir.Append(Function(DirectoryItem(Video, "Most Viewed Daily",thumb=R(ICON),art=R(ART)), title="Most Viewed Daily", url=BREAK_MVDAILY))<br />
    dir.Append(Function(DirectoryItem(Video, "Most Viewed Weekly",thumb=R(ICON),art=R(ART)), title="Most Viewed Weekly", url=BREAK_MVWEEKLY))<br />
    dir.Append(Function(DirectoryItem(Video, "Most Viewed Monthly",thumb=R(ICON),art=R(ART)), title="Most Viewed Monthly", url=BREAK_MVMONTHLY))<br />
    dir.Append(Function(DirectoryItem(Video, "Most Viewed All Time",thumb=R(ICON),art=R(ART)), title="Most Viewed All Time", url=BREAK_MVALLTIME))<br />
<br />
    dir.Append(Function(DirectoryItem(Video, "Top Rated Daily",thumb=R(ICON),art=R(ART)), title="Top Rated Daily", url=BREAK_TRDAILY))<br />
    dir.Append(Function(DirectoryItem(Video, "Top Rated Weekly",thumb=R(ICON),art=R(ART)), title="Top Rated Weekly", url=BREAK_TRWEEKLY))<br />
    dir.Append(Function(DirectoryItem(Video, "Top Rated Monthly",thumb=R(ICON),art=R(ART)), title="Top Rated Monthly", url=BREAK_TRMONTHLY))<br />
    dir.Append(Function(DirectoryItem(Video, "Top Rated All Time",thumb=R(ICON),art=R(ART)), title="Top Rated All Time", url=BREAK_TRALLTIME))<br />
<br />
    dir.Append(Function(DirectoryItem(Video, "Most Discussed Daily",thumb=R(ICON),art=R(ART)), title="Most Discussed Daily", url=BREAK_MDDAILY))<br />
    dir.Append(Function(DirectoryItem(Video, "Most Discussed Weekly",thumb=R(ICON),art=R(ART)), title="Most Discussed Weekly", url=BREAK_MDWEEKLY))<br />
    dir.Append(Function(DirectoryItem(Video, "Most Discussed Monthly",thumb=R(ICON),art=R(ART)), title="Most Discussed Monthly", url=BREAK_MDMONTHLY))<br />
    dir.Append(Function(DirectoryItem(Video, "Most Discussed All Time",thumb=R(ICON),art=R(ART)), title="Most Discussed All Time", url=BREAK_MDALLTIME))<br />
<br />
    dir.Append(Function(DirectoryItem(Video, "Most Shared Daily",thumb=R(ICON),art=R(ART)), title="Most Shared Daily", url=BREAK_MSDAILY))<br />
    dir.Append(Function(DirectoryItem(Video, "Most Shared Weekly",thumb=R(ICON),art=R(ART)), title="Most Shared Weekly", url=BREAK_MSWEEKLY))<br />
    dir.Append(Function(DirectoryItem(Video, "Most Shared Monthly",thumb=R(ICON),art=R(ART)), title="Most Shared Monthly", url=BREAK_MSMONTHLY))<br />
    dir.Append(Function(DirectoryItem(Video, "Most Shared All Time",thumb=R(ICON),art=R(ART)), title="Most Shared All Time", url=BREAK_MSALLTIME))<br />
<br />
    return dir<br />
<br />
####################################################################################################<br />
<br />
def Video(sender, title, url):<br />
<br />
  dir = MediaContainer(title3=title, art=R(ART), viewGroup="InfoList")<br />
<br />
  videos = XML.ElementFromURL(url, isHTML=True, errors='ignore').xpath(XPATH_VIDEOS)<br />
  for content in videos:<br />
    title = content.xpath("a/img/span")[0].txt<br />
    thumb = content.xpath("/a/img")[0].get('src')<br />
    url = content.xpath("/a")[0].get('href')<br />
<br />
  dir.Append(Function(DirectoryItem(VideoFile, "Test", thumb=thumb), title=title, url=url))<br />
<br />
  return dir<br />
<br />
####################################################################################################<br />
<br />
def VideoFile(sender, title, url):<br />
<br />
  dir = MediaContainer(viewGroup="InfoList")<br />
<br />
  return MessageContainer("Test")<br />




for the future, i'd highly recommend ditching apple's text editor for something much more awesome like textmate, syntax highlighting would have alerted you to that quote problem immediatly and the syntax validator picked up the whitespace errors.

I fixed the indentation jumps and I already changed the quotes in xpath_videos (Saw that also after hours of staring…) I did also some log checks and their came up no errors.





18:48:35.151306: com.plexapp.plugins.break : (Framework) Bundle verification complete

18:48:35.153464: com.plexapp.plugins.break : (Framework) Debugging is enabled

18:48:35.153920: com.plexapp.plugins.break : (Framework) Default encoding is utf-8

18:48:35.156627: com.plexapp.plugins.break : (Framework) Loaded en strings

18:48:35.165006: com.plexapp.plugins.break : (Framework) Loaded en-us strings

18:48:35.165047: com.plexapp.plugins.break : (Framework) Configured framework modules





I really do not understand what is going wrong, but thanks for your quick support!



Every suggestion is welcome!

Hey Billy Joe I just saw your message and it worked! Thank you very much. I read that you use pychecker. I gonna use that too.



Thanks again.




i used py-checker (installed via macports) as the backend for textmate's pycheckmate syntax validator

Yes, I’ll do that. I saw that dreamweaver also does not highlight the code because it does not recognize python but i just installed textmate…



Thanks again.

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