Sorry man, this isn’t working code. I’m at work and not in front of a mac or plex. It’s just a very good hint about what you should be doing. You will need to change the xpath specifics and the xml attribute specifics.
That error is because Python uses white space or indents to determine blocks. That line probably has a different amount of white space than the line above or below. And tabs are considered different than single spaces. Make sure all lines within one indent contain the same number of leading white spaces.
that is one of the tricky things with python, pooploser. Whe you have a loop item like “if”,“else”, or “for” you need to have a colon at the end of that line, and then indent the commands to run inside that loop. Allit takes is a tab. First delete the spaces before “title=” and then indent “title=” line with a tab.
Wow, weren’t we on page one this morning?
# PMS plugin framework<br />
import re, string, datetime<br />
from PMS import *<br />
<br />
##################################################################################################ABC<br />
PLUGIN_PREFIX = "/photos/deviantart"<br />
NAMESPACES = {xmlns:media="http://search.yahoo.com/mrss/",xmlns:atom="http://www.w3.org/2005/Atom",xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"}<br />
<br />
DEVIANTART_URL = "http://www.deviantart.com/"<br />
DEVIANTART_CATEGORIES = "http://www.deviantart.com"<br />
<br />
FEED = "feed"<br />
DEBUG = False<br />
abcart ="art-default.png"<br />
abcthumb ="icon-default.png"<br />
<br />
####################################################################################################<br />
<br />
def Start():<br />
Plugin.AddPrefixHandler(PLUGIN_PREFIX, MainMenu, "Deviant Art","icon-default.jpg", "art-default.jpg")<br />
Plugin.AddViewGroup("InfoList", viewMode="InfoList", mediaType="items")<br />
<br />
MediaContainer.art =R(abcart)<br />
DirectoryItem.thumb =R(abcthumb)<br />
<br />
####################################################################################################<br />
#def MainMenu():<br />
# dir = MediaContainer(mediaType='items') <br />
# dir.Append(Function(DirectoryItem(all_shows, "Categories"), pageUrl = DEVIANTART_CATEGORIES))<br />
# return dir<br />
<br />
####################################################################################################<br />
def MainMenu():<br />
pageUrl= DEVIANTART_CATEGORIES<br />
dir = MediaContainer(mediaType='items')<br />
content = XML.ElementFromURL(pageUrl, True)<br />
Log(content.xpath('//div[@class="sliding-menu "]/ul/li/ul/li/a'))<br />
for item in content.xpath('//div[@class="sliding-menu "]/ul/li/ul/li/a'):<br />
Log(item)<br />
title=item.text <br />
titleUrl = item.get('href') <br />
<br />
Log(title)<br />
Log(titleUrl)<br />
dir.Append(Function(DirectoryItem(ItemPage, title), pageUrl = titleUrl))<br />
return dir<br />
####################################################################################################<br />
def ItemPage(sender, pageUrl):<br />
dir = MediaContainer(title2=sender.itemTitle)<br />
Log("Success!")<br />
pageUrl= pageUrl<br />
dir = MediaContainer(mediaType='items')<br />
content = XML.ElementFromURL(pageUrl, True)<br />
Log(content.xpath('//div[@class="sliding-menu "]/ul/li/ul/li/a'))<br />
for item in content.xpath('//div[@class="sliding-menu "]/ul/li/ul/li/a'):<br />
Log(item)<br />
title=item.text <br />
titleUrl = item.get('href') <br />
<br />
Log(title)<br />
Log(titleUrl)<br />
dir.Append(Function(DirectoryItem(ItemPage2, title), pageUrl = titleUrl))<br />
return dir<br />
####################################################################################################<br />
def ItemPage2(sender, pageUrl):<br />
dir = MediaContainer(title2=sender.itemTitle)<br />
Log("Success!")<br />
pageUrl= pageUrl<br />
dir = MediaContainer(mediaType='items')<br />
content = XML.ElementFromURL(pageUrl, True)<br />
Log(content.xpath('//div[@class="sliding-menu "]/ul/li/ul/li/a'))<br />
for item in content.xpath('//div[@class="sliding-menu "]/ul/li/ul/li/a'):<br />
Log(item)<br />
title=item.text <br />
titleUrl = item.get('href') <br />
<br />
Log(title)<br />
Log(titleUrl)<br />
dir.Append(Function(DirectoryItem(RssFeedItems, title), pageUrl = titleUrl))<br />
return dir<br />
####################################################################################################<br />
def RssFeedItems(sender, pageUrl):<br />
dir = MediaContainer(title2=sender.itemTitle)<br />
pageContents = HTTP.Request(pageUrl)<br />
pageContentsXML = XML.ElementFromString(pageContents)<br />
Log("Success!")<br />
pageUrl= pageUrl<br />
dir = MediaContainer(mediaType='items') <br />
content = XML.ElementFromURL(pageUrl, isHTML=false)<br />
image = 0<br />
for item in content.xpath('//item'):<br />
title = item.xpath(".//title", namespaces=NAMESPACES)[0].text<br />
description= item.xpath('//description').text<br />
Log(title)<br />
photoUrl = item.xpath('.//media:content', namespaces=NAMESPACES)[0].get('url')<br />
thumb = item.xpath('.//media:thumbnail', namespaces=NAMESPACES)[0].get('url')<br />
rssfeed = item.get('href')<br />
PMS.Log(rssfeed)<br />
content2=XML.ElementFromURL(rssfeed,isHTML=False)<br />
dir.Function(DirectoryItem(rssfeed, image, "test"))<br />
return dir
Your last function seems confused. You aren’t actually adding any PhotoItems to the end of the tree and your are already looping around the rss feed content so you don’t need to do it again. Use something like
dir.Append(PhotoItem(photoUrl, title, summary=description, thumb = thumb))
rather than adding another directory item.
At this point I'd take a step back and try and actually understand what you are doing and what's going on. You won't get much further by just copy, paste, replace programming.
Jonny
thanks jonny, you’re right
i am very much getting what i’m doing by now, thanks to the help of some kind people in the chat 
it was a very steep hill to climb though.
i’m rather a person of ‘learning by doing’ philosophy, but i will read into the whole stuff aswell.
def RssFeedItems(sender, pageUrl):<br />
dir = MediaContainer(title2=sender.itemTitle)<br />
pageContents = HTTP.Request(pageUrl)<br />
content1=XML.ElementFromURL(pageUrl, isHTML="True")<br />
for item in content1.xpath('//link[@type="application/rss+xml"]'): <br />
rssfeed=item.get('href') <br />
Log("rssfeed")<br />
content = XML.ElementFromURL(rssfeed, isHTML="False") <br />
pageUrl= pageUrl<br />
for item in content.xpath('//item'):<br />
title = item.xpath('.//title', namespaces=NAMESPACES)[0].text<br />
description = item.xpath('//description').text<br />
Log(title)<br />
thumb = item.xpath('./content', namespaces=NAMESPACES)[0].get('url')<br />
dir.Append(PhotoItem(thumb, title=title, thumb=thumb))<br />
return dir<br />
Well, that looks like it would work but you are collapsing two levels of the hierarchy into one, which could be what you want.
It will go to the content of the HTML at the URL pageUrl. It will then look for all link tags with an attribute type=“application/rss+xml”. Then, for each of these it will look at the feed with URL=rssfeed and look for all tags named item (you sure that is correct, I made it up?). Then for each of those tags named item it will extract the photo and add the media.
I was assuming you wanted to have a deeper navigation hierarchy in Plex but this will work. The one potential downside is speed. It will have to visit a lot of URLs (all the rss feeds) to get the content for one page. By splitting it into another level on the hierarchy you’ll speed things up since that level will only parse one rss feed.
Jonny
Me too (the learn by doing part, I think you have to with programming) but blind cut and pasting without actually learning or understanding what’s going one won’t get you anywhere fast.
FYI- Jonny, there was a double marathon in chat and I think the plug is now working. Pooploser is sleeping now, and wants to now focus on login and search... like I said. "FYI"
Sorry to jump in. Been following this discussion and others trying to write my first video plugin. What’s the best way to wrap it in a .bundle so it is easily testable? Is there a wiki or forum thread that walks through this?
Hey Joe,
There is actually a kick-starter here, if you want to create the .bundle:
http://dev.plexapp.com/tools/plugin_kickstart/
Lots of info here:
http://dev.plexapp.com/
In finder, copy and paste another video plugin, and replace the init file with yours.
Thanks, Guys. Found the Kick starter and got a bundle going. Anything special I should look out for if I’m doing a flash video plugin?
Also… dropping it in my plugins folder after initial setup isn’t showing up in the video plugins screen in plex
Yeah, avoid flash ![]()
Welcome, feel free to ask questions. And, I was only being a little facetious about flash. You can sometimes use firebug or charles to find the direct video URL and it makes life much easier.
I am also a big fan of httpfox when using firefox.
I found a post talking about some add ons in addition to some I already had. I have firebug, XPath Checker, and httpfox.
Should I shy away from a flash plugin for my first attempt?
I say, if you've got the interest in the plugin, "Go for it!"
It is less of a hassle if you can use an rtmp link (or even mp4)
but we'll help, if get stuck. ;)
You might want to start a new thread too.
No, ignore me:). If you have some content you want to see in Plex that’s your best reason. Plex can handle flash with not too much more effort than other formats… That’s one of the reasons it’s a great platform to develop on.