Exemplo n.º 1
0
def ConstructProgramme(element):

    imageUri = ''
    if len(element.xpath('.//img/@src')) > 0:
        imageUri = element.xpath('.//img/@src')[0]
        imageUri = imageUri.replace('player_image_thumb_standard',
                                    'posterframe')

    additionInfoEpisodeCount = None
    if len(element.xpath(".//span[@class='episode-free']")) > 0:
        additionInfoEpisodeCount = element.xpath(
            ".//span[@class='episode-free']")[0].text

    return MediaItems.Programme(
        title=element.xpath(".//div[@class='programme-title cell-title']/a")
        [0].text,
        pageUri=ITV_URL + element.xpath(
            ".//div[@class='programme-title cell-title']/a/@href")[0],
        imageUri=imageUri,
        #genres                     = element.xpath('./d:Genres',namespaces={'d' : ITV_XML_NS})[0].text,
        shortSynopsis='',
        #longSynopsis               = element.xpath('./d:LongSynopsis',namespaces={'d' : ITV_XML_NS})[0].text,
        #additionInfoText           = element.xpath('./d:AdditionalInfo/d:Text',namespaces={'d' : ITV_XML_NS})[0].text,
        #additionInfoUri            = element.xpath('./d:AdditionalInfo/d:Uri',namespaces={'d' : ITV_XML_NS})[0].text,
        additionInfoEpisodeCount=additionInfoEpisodeCount,
        #additionHeaderText         = element.xpath('./d:AdditionalInfo/d:AdditionalHeaderText',namespaces={'d' : ITV_XML_NS})[0].text,
        #additionalSynopsisText     = element.xpath('./d:AdditionalInfo/d:AdditionalSynopsisText',namespaces={'d' : ITV_XML_NS})[0].text,
        #channel                    = element.xpath('./d:AdditionalInfo/d:Channel',namespaces={'d' : ITV_XML_NS})[0].text,
        #latestEpisodeId            = element.xpath('./d:LatestEpisode/d:Id',namespaces={'d' : ITV_XML_NS})[0].text,
        latestEpisodeDate='',
        latestEpisodeTime='',
    )
Exemplo n.º 2
0
def ConstructProgrammeSearch(element):

    imageUri = ''
    if len(element.xpath(
            ".//div[@class='search-result-image']//img/@src")) > 0:
        imageUri = element.xpath(
            ".//div[@class='search-result-image']//img/@src")[0]
        imageUri = imageUri.replace('player_image_thumb_standard',
                                    'posterframe')

    additionInfoEpisodeCount = None
    if len(element.xpath(".//span[@class='search-max']")) > 0:
        additionInfoEpisodeCount = element.xpath(
            ".//span[@class='search-max']")[0].text

    return MediaItems.Programme(
        title=element.xpath(".//h4[@class='programme-title']/a")[0].text,
        pageUri=element.xpath(".//h4[@class='programme-title']/a/@href")[0],
        imageUri=imageUri,
        shortSynopsis=" ".join(
            element.xpath(
                ".//div[@class='programme-description']//text()")).strip(),
        additionInfoEpisodeCount=additionInfoEpisodeCount,
        latestEpisodeDate='',
        latestEpisodeTime='',
    )
Exemplo n.º 3
0
def ConstructEpisodeSearch(element):

    daysRemaining = None
    res = re.search(
        "(\\d+)", " ".join(
            element.xpath(".//div[@class='remaining-time']//text()")).strip())
    if res:
        daysRemaining = res.groups()[0]

    return MediaItems.Episode(
        id=ITV_URL + element.xpath(".//a/@href")[0],
        title=" ".join(
            element.xpath(".//div[@class='episode-title']//text()")).strip(),
        shortSynopsis=" ".join(
            element.xpath(".//div[@class='description']//text()")).strip(),
        daysRemaining=daysRemaining)
Exemplo n.º 4
0
def ConstructProgramme(element):
	
	imageUri = ''
	if len(element.xpath('.//img/@src')) > 0:
		imageUri = element.xpath('.//img/@src')[0]
		imageUri = imageUri.replace('player_image_thumb_standard','posterframe')
		
	additionInfoEpisodeCount = None
#	if len(element.xpath(".//p")) > 0:
#		additionInfoEpisodeCount = element.xpath(".//p")[0].text # TODO: strip ' episodes' from end of string
	
	return MediaItems.Programme(
		title                      = element.xpath(".//h3")[0].text.strip(),
		pageUri                    = element.xpath(".//a/@href")[0],
		imageUri                   = imageUri,
		shortSynopsis              = '',
		additionInfoEpisodeCount   = additionInfoEpisodeCount,
		latestEpisodeDate          = '',
		latestEpisodeTime          = '',
	)
Exemplo n.º 5
0
def ConstructEpisode(element, pageUri):

    id = pageUri
    if len(element.xpath(
            ".//div[contains(@class, 'node-episode')]/a[1]/@href")) > 0:
        id = ITV_URL + element.xpath(
            ".//div[contains(@class, 'node-episode')]/a[1]/@href")[0]
    elif len(element.xpath("./a")) > 0:
        id = ITV_URL + element.xpath("./a[1]/@href")[0]

    title = 'Unknown'
    if len(element.xpath("//h2[@class='title episode-title']")) > 0:
        title = element.xpath("//h2[@class='title episode-title']")[0].text
    elif len(element.xpath(".//div[@class='programme-title']")) > 0:
        title = " ".join(
            element.xpath(".//div[@class='programme-title']//text()")).strip()

    seasonNumber = ''
    if len(
            element.xpath(
                ".//div[contains(@class, 'field-name-field-season-number')]//text()"
            )) > 0:
        seasonNumber = element.xpath(
            ".//div[contains(@class, 'field-name-field-season-number')]//text()"
        )[0]

    episodeNumber = ''
    if len(
            element.xpath(
                ".//div[contains(@class, 'field-name-field-episode-number')]//text()"
            )) > 0:
        episodeNumber = element.xpath(
            ".//div[contains(@class, 'field-name-field-episode-number')]//text()"
        )[0]

    daysRemaining = None
    if len(element.xpath(".//div[@class='offer-duration']")) > 0:
        daysRemaining = re.search(
            "(\\d*)",
            element.xpath(".//div[@class='offer-duration']")
            [0].text.strip()).groups()[0]
    #elif len() > 0:
    #	re.search("(\\d*)",element.xpath(".//div[@class='offer-duration']")[0].text.strip()).groups()[0]

    shortSynopsis = ''
    if len(
            element.xpath(
                ".//div[contains(@class,'field-name-field-short-synopsis')]//text()"
            )) > 0:
        shortSynopsis = element.xpath(
            ".//div[contains(@class,'field-name-field-short-synopsis')]//text()"
        )[0]

    duration = None
    if len(
            element.xpath(
                ".//div[contains(@class, 'field-name-field-duration')]//text()"
            )) > 0:
        res = re.search(
            "(?:(?:(\\d+)(?:\s*hours?\s*))|(?:(\\d+)(?:\s*minutes?))){1,2}",
            " ".join(
                element.xpath(
                    ".//div[contains(@class, 'field-name-field-duration')]//text()"
                )).strip())
        if res:
            duration = (int(res.groups()[0]) if res.groups()[0] else 0) * 60
            duration += (int(res.groups()[1]) if res.groups()[1] else 0)

    lastBroadcast = datetime.datetime.strptime(
        element.xpath(
            ".//div[contains(@class, 'field-name-field-broadcastdate')]//span/@content"
        )[0][:-6], '%Y-%m-%dT%H:%M:%S')

    posterFrameUri = None
    if len(
            element.xpath(
                ".//div[contains(@class,'field-name-field-image')]//img/@src")
    ) > 0:
        posterFrameUri = element.xpath(
            ".//div[contains(@class,'field-name-field-image')]//img/@src")[0]
    elif len(element.xpath(".//param[@name='poster']")) > 0:
        posterFrameUri = element.xpath(".//param[@name='poster']/@value")[0]

    if posterFrameUri:
        posterFrameUri = posterFrameUri.replace('player_image_thumb_standard',
                                                'posterframe')

    return MediaItems.Episode(
        id=id,
        title=title,
        seasonNumber=seasonNumber,
        episodeNumber=episodeNumber,
        duration=duration,
        lastBroadcast=lastBroadcast,
        daysRemaining=daysRemaining,
        shortSynopsis=shortSynopsis,
        posterFrameUri=posterFrameUri,
        #channel                    = element.xpath('./d:AdditionalInfo/d:Channel',namespaces={'d' : ITV_XML_NS})[0].text,
        #channelLogoUrl             = element.xpath('./d:AdditionalInfo/d:ChannelLogoUrl',namespaces={'d' : ITV_XML_NS})[0].text,
    )