2007-09-12, 19:59
Hi there,
here is a new plugin for watching/listening to video/audio Podcasts.
You can put it in the Q:/plugins/video/Podcast or Q:/plugins/music/Podcast directory as default.py.
Before that, you need to edit the script to enter your podcasts in the correct format. This will be put into a seperate file in future versions.
Have Fun!
here is a new plugin for watching/listening to video/audio Podcasts.
You can put it in the Q:/plugins/video/Podcast or Q:/plugins/music/Podcast directory as default.py.
Before that, you need to edit the script to enter your podcasts in the correct format. This will be put into a seperate file in future versions.
Have Fun!
Code:
#G4.py Version 0.3
#Author Greg Chrystall [email protected]
#Script modded by Brad Quesnell [email protected]
#Note this is the first release, heavily copied from other XBMC Scripts.
import xml.dom.minidom, urllib, os, os.path, xbmc, xbmcgui, string, traceback, time,sys,xbmcplugin
# Setup logging routines
ROOT_DIR = os.getcwd()[:-1]+'\\'
IMAGE_DIR = ROOT_DIR+'images\\'
def LOG(message):
print message
def LOGCLOSE():
print "End of log."
itemElements = ['title','link','pubDate', 'description']
rssFeeds = {'Kanzlerin' : 'http://www.bundeskanzlerin.de/Webs/BK/DE/Service/RSS/Functions/bundeskanzlerinPodCastRSS20,templateId=renderNewsfeed.xml',
'Attack of the Show' : 'http://www.g4tv.com/attackoftheshow/podcasts/5/Attack_of_the_Show_Daily_Video_Podcast.xml',
'AOTS: Fresh Ink' : 'http://www.g4tv.com/attackoftheshow/podcasts/21/AOTS_Fresh_Ink.xml',
'AOTS: In Your Pants' : 'http://www.g4tv.com/attackoftheshow/podcasts/22/AOTS_In_Your_Pants.xml',
'AOTS: Hardware' : 'http://www.g4tv.com/attackoftheshow/podcasts/23/AOTS_Hardware.xml',
'AOTS: Game Break' : 'http://www.g4tv.com/attackoftheshow/podcasts/24/AOTS_Game_Break.xml',
'G4tv.com Originals' : 'http://www.g4tv.com/g4originals/podcasts/25/G4tvcom_Originals.xml',
'Tagesschau':'http://www.tagesschau.de/export/video-podcast/tagesschau',
'Cinematech':'http://www.g4tv.com/cinematech/podcasts/8/Cinematech_Video_Podcast.xml',
'Cinematech : Nocturnal Emissions':'http://www.g4tv.com/cinematechnocturnalemissions/podcasts/9/Cinematech_Nocturnal_Emissions_Video_Podcast.xml',
'Happy Tree Friends':'http://podcast.happytreefriends.com/htfrss.xml',
'ICONS':'http://www.g4tv.com/icons/podcasts/17/ICONS_Video_Podcast.xml',
'Street Fury':'http://www.g4tv.com/streetfury/podcasts/11/Street_Fury_Video_Podcast.xml',
'The Daily Feed':'http://www.g4tv.com/thefeed/podcasts/19/The_Daily_Feed_Video_Podcast.xml',
'The Man Show':'http://www.g4tv.com/themanshow/podcasts/14/The_Man_Show_Video_Podcast.xml',
'X-Play':'http://www.g4tv.com/xplay/podcasts/6/XPlay_Daily_Video_Podcast.xml',
'Ninja Warrior':'http://www.g4tv.com/ninjawarrior/podcasts/27/Ninja_Warrior_Video_Podcast.xml',
'Freestyle 101':'http://www.g4tv.com/g4originals/podcasts/26/Freestyle_101_Video_Podcast.xml'
}
class G4Viewer:
def __init__(self,show=None):
self.feeds = {}
self.urlsInOrder = []
if (len(show)<1):
self.displayOverview()
else:
print urllib.unquote_plus(sys.argv[2][1:-1])
self.displayPodcast(urllib.unquote_plus(show))
def displayOverview(self):
for name, url in sorted(rssFeeds.iteritems()):
liz=xbmcgui.ListItem(name)
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=sys.argv[0]+"?"+urllib.quote(name),listitem=liz,isFolder=True)
def displayPodcast(self, show):
try:
self.feeds[show] = FeedItems(rssFeeds[show]).getData()
except:
traceback.print_exc(file=sys.stdout)
print "Error! Could not get rss feed: '" + show + "'"
return
for item in self.feeds[show]:
name=item.getElement("title")
url=item.getElement("mediaUrl")
liz=xbmcgui.ListItem(name)
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=liz)
class FeedItems:
def __init__(self, url):
self.dom = None
f = urllib.urlopen(url)
xmlDocument = f.read()
f.close()
self.dom = xml.dom.minidom.parseString(xmlDocument)
self.data = []
self.extractURLNameDictionary()
def extractURLNameDictionary(self):
items = self.dom.getElementsByTagName("item")
for item in items:
elements = {}
for itemElement in itemElements:
try:
elements[itemElement] = item.getElementsByTagName(itemElement)[0].childNodes[0].data.strip()
#print itemElement, " = ", item.getElementsByTagName(itemElement)[0].childNodes[0].data
except:
pass
try:
elements["mediaUrl"] = item.getElementsByTagName("enclosure")[0].getAttribute("url").strip()
except:
try:
elements["mediaUrl"] = item.getElementsByTagName("link")[0].childNodes[0].data.strip()
except:
traceback.print_exc(file=sys.stdout)
print "Error - Problem building feed."
self.data.append(RSSItem(elements))
def getData(self):
return self.data
class RSSItem:
def __init__(self, elements):
# list that includes required item elements
self.elements = elements
def getElement(self, element):
return self.elements[element]
def getElementNames(self):
return self.elements.keys()
def hasElement(self, element):
return self.elements.has_key(element)
w = G4Viewer(sys.argv[2][1:len(sys.argv[2])])
xbmcplugin.endOfDirectory(int(sys.argv[1]))