Make this code read from html and use image for thumbnail?

Does anyone know how i can get this code to add thumbnail image from html file please?

NAME = 'Plex Film'
ICON          = 'icon-default.png'
ART           = 'art-default.jpg'
####################################################################################################
def Start():

	DirectoryObject.thumb = R(ICON)
	DirectoryObject.art = R(ART)
	VideoClipObject.thumb = R(ICON)
	VideoClipObject.art = R(ART) 

	ObjectContainer.title1 = NAME
	HTTP.CacheTime = 10

####################################################################################################
@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])

		oc.add(CreateVideoClipObject(
			url = url,
			title = title,
			summary = summary,
			originally_available_at = originally_available_at
		))

	return oc

####################################################################################################
def CreateVideoClipObject(url, title, summary, originally_available_at, include_container=False):

	videoclip_obj = VideoClipObject(
		key = Callback(CreateVideoClipObject, url=url, title=title, summary=summary, originally_available_at=originally_available_at, include_container=True),
		rating_key = url,
		title = title,
		summary = summary,
		originally_available_at = originally_available_at,
		items = [
			MediaObject(
				parts = [
					PartObject(key=url)
				],
				container = Container.MP4,
				video_codec = VideoCodec.H264,
				#####video_resolution = '544',######
				audio_codec = AudioCodec.AAC,
				audio_channels = 2,
				optimized_for_streaming = True
			)
		]
	)

	if include_container:
		return ObjectContainer(objects=[videoclip_obj])
	else:
		return videoclip_obj

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

/T

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

And forgot:

The name Plex Film is not a good name to use for a channel, since that’s a trademark violation!

Suggest you change it to like Films for Plex instead

@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

doesnt work buddy, channel not responding

@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.