Permalink
Browse files

Plex plugin for Remedie

  • Loading branch information...
1 parent b27d299 commit d0617dac5e69287641896a1b0ffd827e6890d722 @miyagawa committed Jun 18, 2009
View
1 .gitignore
@@ -0,0 +1 @@
+*.pyc
View
73 Plug-ins/Remedie.bundle/Contents/Code/__init__.py
@@ -0,0 +1,73 @@
+from PMS import Plugin, Log, XML, HTTP, JSON, Prefs, RSS
+from PMS.MediaXML import *
+from PMS.FileTypes import PLS
+from PMS.Shorthand import _L, _R, _E, _D
+import re
+
+PLUGIN_PREFIX = "/video/remedie"
+FEED_URL = "http://localhost:10010/"
+
+####################################################################################################
+
+def Start():
+ Plugin.AddRequestHandler(PLUGIN_PREFIX, HandleRequest, "Remedie", "icon-default.png", "art-default.jpg")
+ Plugin.AddViewGroup("InfoList", viewMode="InfoList", contentType="items")
+ Plugin.AddViewGroup("List", viewMode="List", contentType="items")
+
+####################################################################################################
+
+def HandleRequest(pathNouns, count):
+ try:
+ title2 = pathNouns[count-1].split("||")[1]
+ pathNouns[count-1] = pathNouns[count-1].split("||")[0]
+ except:
+ title2 = ""
+
+ dir = MediaContainer("art-default.jpg", viewGroup="List", title1="Remedie", title2=title2.decode("utf-8"))
+ if count == 0:
+ dict = JSON.DictFromURL(FEED_URL + "rpc/channel/load");
+ for e in dict[u'channels']:
+ id = e[u'id']
+ title = e[u'name']
+ if e[u'unwatched_count']:
+ title += ' (' + str(e[u'unwatched_count']) + ')'
+ thumb = "icon-default.png"
+ if u'thumbnail' in e[u'props']:
+ thumb = e[u'props'][u'thumbnail'][u'url']
+ Log.Add(thumb)
+ dir.AppendItem(DirectoryItem("feed^" + str(id) + "||" + title, title, _R(thumb)))
+
+ elif pathNouns[0].startswith("feed"):
+ channel_id = pathNouns[0].split("^")[1]
+ dict = JSON.DictFromURL(FEED_URL + "rpc/channel/show?id=" + channel_id)
+ dir.SetViewGroup("InfoList")
+ for e in dict[u'items']:
+ type = e[u'props'][u'type']
+ id = PLUGIN_PREFIX + "/play^" + _E(e[u'ident']) + "^" + type
+ title = e[u'name']
+ summary = e[u'props'][u'description']
+ duration = ""
+ thumb = ""
+ if u'thumbnail' in e[u'props']:
+ thumb = e[u'props'][u'thumbnail'][u'url']
+ elif u'thumbnail' in dict[u'channel'][u'props']:
+ thumb = dict[u'channel'][u'props'][u'thumbnail'][u'url']
+ # TODO maybe special case YouTube
+ if re.match('^video/', type):
+ vidItem = VideoItem(id, e[u'name'], summary, duration, thumb)
+ else:
+ Log.Add(e[u'props'][u'link'])
+ vidItem = WebVideoItem(e[u'props'][u'link'], e[u'name'], summary, duration, thumb)
+ dir.AppendItem(vidItem)
+
+ elif pathNouns[0].startswith("play"):
+ # TODO mark it read
+ paths = pathNouns[0].split("^")
+ Log.Add(paths)
+ url = _D(paths[1])
+ type = paths[2]
+ Log.Add(url)
+ return Plugin.Redirect(url)
+
+ return dir.ToXML()
+####################################################################################################
View
2 Plug-ins/Remedie.bundle/Contents/Defaults.xml
@@ -0,0 +1,2 @@
+<PluginPreferences>
+</PluginPreferences>
View
22 Plug-ins/Remedie.bundle/Contents/Info.plist
@@ -0,0 +1,22 @@
+<plist version="1.0">
+ <dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string>com.plexapp.plugins.remedie</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>AAPL</string>
+ <key>CFBundleSignature</key>
+ <string>hook</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>PlexPluginMode</key>
+ <string>AlwaysOn</string>
+ <key>PlexPluginDebug</key>
+ <string>1</string>
+ </dict>
+</plist>
View
2 Plug-ins/Remedie.bundle/Contents/Strings/en.json
@@ -0,0 +1,2 @@
+{
+}

0 comments on commit d0617da

Please sign in to comment.