Options

RSS parsing help - plex plugin dev

klphotoklphoto 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!
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()

Comments

  • Options
    [Deleted User][Deleted User] Big grins Posts: 0 Big grins
    edited April 9, 2009
    The user and all related content has been deleted.
  • Options
    mtnbikermtnbiker Registered Users Posts: 178 Major grins
    edited April 25, 2009
    please oh please...someone, this would be GREAT
  • Options
    devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited May 2, 2009
    I recently started running a Mac Mini (with Plex) as my media server, so having a plugin is something that I really want.

    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.

    20090502-q2kenj1rw8ycdktxwrmtng5ak9.png

    Right now I only list galleries with no category/subcategory architecture, but that's definitely something I want.
    David Parry
    SmugMug API Developer
    My Photos
  • Options
    [Deleted User][Deleted User] Big grins Posts: 0 Big grins
    edited May 2, 2009
    The user and all related content has been deleted.
  • Options
    bobmoranebobmorane Registered Users Posts: 9 Beginner grinner
    edited March 20, 2010
    Hi,
    Did someone finally achieve this ?
    The plex appstore provides picasa or flickr plugins, that would be awesome to have a smugmug one...

    thanks
  • Options
    sg_is_mesg_is_me Registered Users Posts: 19 Big grins
    edited October 11, 2011
Sign In or Register to comment.