Not tested, and never coded a regular channel before, but… but when walking the items, then maybe something like:
item.xpath("itunes:image@href")
The digest that, to get a real url, instead of the relative one the website produce, and use that as a thumb property, when creating the VideoClipObject
If your XML file contains namespaces (like the itunes one in the example you gave), you have to declare those that you need and use them in your xpath queries.
Declare required namespaces (put this somewhere at the top, where you define title, icons, etc.):
NAME = 'Plex Film'
ICON = 'icon-default.png'
ART = 'art-default.jpg'
NAMESPACES = {'itunes': 'http://www.itunes.com/dtds/podcast-1.0.dtd'} # <----
Then use the namespace in your xpath query:
@handler('/video/PlexFilm', NAME, allow_sync=True)
def MainMenu():
oc = ObjectContainer()
for item in XML.ElementFromURL('http://www.ghostbuild.uk/stream').xpath('//item'):
url = item.xpath('./enclosure/@url')[0]
title = item.xpath('./title/text()')[0]
summary = item.xpath('./description/text()')[0]
originally_available_at = Datetime.ParseDate(item.xpath('./pubDate/text()')[0])
thumb = item.xpath('./itunes:image/@href', namespaces=NAMESPACES)[0] # <----
oc.add(CreateVideoClipObject(
url = url,
title = title,
summary = summary,
originally_available_at = originally_available_at,
thumb = thumb
))
return oc
@sander1 said:
If your XML file contains namespaces (like the itunes one in the example you gave), you have to declare those that you need and use them in your xpath queries.
Declare required namespaces (put this somewhere at the top, where you define title, icons, etc.):
NAME = 'Plex Film'
ICON = 'icon-default.png'
ART = 'art-default.jpg'
NAMESPACES = {'itunes': 'http://www.itunes.com/dtds/podcast-1.0.dtd'} # <----
Then use the namespace in your xpath query:
@handler('/video/PlexFilm', NAME, allow_sync=True)
def MainMenu():
oc = ObjectContainer()
for item in XML.ElementFromURL('http://www.ghostbuild.uk/stream').xpath('//item'):
url = item.xpath('./enclosure/@url')[0]
title = item.xpath('./title/text()')[0]
summary = item.xpath('./description/text()')[0]
originally_available_at = Datetime.ParseDate(item.xpath('./pubDate/text()')[0])
thumb = item.xpath('./itunes:image/@href', namespaces=NAMESPACES)[0] # <----
oc.add(CreateVideoClipObject(
url = url,
title = title,
summary = summary,
originally_available_at = originally_available_at,
thumb = thumb
))
return oc
@tonyb554 said:
doesnt work buddy, channel not responding
We really need to see the full code of your channel, including some live XML data to help you any further. Copy/pasting the example code I gave probably won’t work and more or other code is needed. Saying “it doesn’t work” doesn’t help, as we cannot check anything.