RSS parsing help - plex plugin dev
klphoto
Registered Users Posts: 49 Big grins
Hi everyone,
I am trying to create a plugin for Plex media center so I and others can view my photos from Plex.
Attached are two examples of python scripts that other plugins use in order to display photos by parsing through rss feeds. I was wondering if anyone could help me change one of them to work with smugmug because I haven't been able to get it to work yet. Thanks so much!
I am trying to create a plugin for Plex media center so I and others can view my photos from Plex.
Attached are two examples of python scripts that other plugins use in order to display photos by parsing through rss feeds. I was wondering if anyone could help me change one of them to work with smugmug because I haven't been able to get it to work yet. Thanks so much!
from PMS import Plugin, Log, XML, HTTP, JSON, RSS, Utils from PMS.MediaXML import MediaContainer, DirectoryItem, PhotoItem PLUGIN_PREFIX = "/photos/JessicaClaire" ROOT_URL = "http://www.jessicaclaire.net" RSS_FEED = ROOT_URL + "/rss/" #################################################################################################### def Start(): Plugin.AddRequestHandler(PLUGIN_PREFIX, HandlePhotosRequest, "Jessica Claire", "icon-default.png", "art-default.png") Plugin.AddViewGroup("Pictures", viewMode="Pictures", contentType="photos") #################################################################################################### def HandlePhotosRequest(pathNouns, count): if count == 0: dir = MediaContainer("art-default.png", None, "Jessica Claire") for item in RSS.Parse(RSS_FEED).entries: entry = XML.ElementFromString(item.description, True) imgs = entry.xpath('//img') if len(imgs) > 5: thumb = '' for img in imgs: if img.get('src').find('jessicaclaire.net/images/content') != -1: thumb = img.get('src') summary = entry.text_content()[:400] + '...' dir.AppendItem(DirectoryItem(Utils.EncodeStringToUrlPath(item.link)+'$'+Utils.EncodeStringToUrlPath(item.title), item.title, thumb, summary)) elif count == 1: (url,title) = pathNouns[0].split('$') dir = MediaContainer("art-default.png", "Pictures", "Jessica Claire", Utils.DecodeUrlPathToString(title)) count = 1 for img in XML.ElementFromURL(Utils.DecodeUrlPathToString(url), True).xpath('//img'): if img.get('src').find('/images/content') != -1: url = ROOT_URL + img.get('src') dir.AppendItem(PhotoItem(url, 'Photo %d' % count, '', url)) count += 1 return dir.ToXML()
from PMS import Plugin, Log, DB, Thread, XML, HTTP, JSON, RSS, Utils from PMS.MediaXML import MediaContainer, DirectoryItem, PhotoItem import re PLUGIN_PREFIX = "/photos/BraedonPhotography" ROOT_URL = "http://braedonsblog.com" RSS_FEED = ROOT_URL + "/feed/" #################################################################################################### def Start(): Plugin.AddRequestHandler(PLUGIN_PREFIX, HandlePhotosRequest, "Braedon Photography", "icon-default.png", "art-default.jpg") Plugin.AddViewGroup("Pictures", viewMode="Pictures", contentType="photos") Plugin.AddViewGroup("Info", viewMode="InfoList", contentType="items") #################################################################################################### def HandlePhotosRequest(pathNouns, count): if count == 0: dir = MediaContainer("art-default.jpg", "Info", "Braedon Photography") for item in RSS.Parse(RSS_FEED).entries: entry = XML.ElementFromString(item.content[0].value, True) imgs = entry.xpath('//img') Log.Add(imgs) if len(imgs) >= 1: thumb = '' for img in imgs: if img.get('src').find('http://braedonsblog.com/wp-content/uploads') != -1: thumb = img.get('src') dir.AppendItem(DirectoryItem(Utils.EncodeStringToUrlPath(item.link)+'$'+Utils.EncodeStringToUrlPath(item.title), item.title, thumb, item.description)) elif count == 1: (url,title) = pathNouns[0].split('$') dir = MediaContainer("art-default.pngg", "Pictures", "Braedon Photography", Utils.DecodeUrlPathToString(title)) count = 1 for img in XML.ElementFromURL(Utils.DecodeUrlPathToString(url), True).xpath('//img'): if img.get('src').find('/wp-content/uploads') != -1: url = img.get('src') dir.AppendItem(PhotoItem(url, 'Photo %d' % count, '', url)) count += 1 return dir.ToXML()
0
Comments
I started playing around with the Plex plugins for the first time last night and made some good progress. Not sure how long it will take to get a plugin fully up and running...but i'm excited with what i have so far.
Right now I only list galleries with no category/subcategory architecture, but that's definitely something I want.
SmugMug API Developer
My Photos
Did someone finally achieve this ?
The plex appstore provides picasa or flickr plugins, that would be awesome to have a smugmug one...
thanks