def parse_xml(xml):

    xml = utils.xml_strip_namespace(xml)

    try:
        root = ET.fromstring(xml)
    except:
        return None

    elist = listentries()
    for entry in root.getiterator('episode'):
        title = entry.find('complete_title').text
        id = entry.find('id').text
        date = entry.find('actual_start').text
        summary = entry.find('synopsis').text
        thumbnail = entry.find('my_image_base_url').text + id + "_640_360.jpg"

        series = entry.find('toplevel_container_title').text
        episode = entry.find('position').text
        if episode is not None:
            episode = int(episode)

        e_categories = []
        for category in entry.find('categories').findall('category'):
            e_categories.append(category.find('short_name').text)

        elist.entries.append(listentry(title, id, date, summary, e_categories, series, episode))

    return elist
Exemplo n.º 2
0
def parse_xml(xml):

    xml = utils.xml_strip_namespace(xml)

    try:
        root = ET.fromstring(xml)
    except:
        return None

    elist = listentries()
    for entry in root.getiterator('episode'):
        title = entry.find('complete_title').text
        id = entry.find('id').text
        date = entry.find('actual_start').text
        summary = entry.find('synopsis').text
        thumbnail = entry.find('my_image_base_url').text + id + "_640_360.jpg"

        series = entry.find('toplevel_container_title').text
        episode = entry.find('position').text
        if episode is not None:
            episode = int(episode)

        e_categories = []
        for category in entry.find('categories').findall('category'):
            e_categories.append(category.find('short_name').text)

        elist.entries.append(
            listentry(title, id, date, summary, e_categories, series, episode))

    return elist
    def parse_playlist(self, xmlstr):
        xmlstr = utils.xml_strip_namespace(xmlstr)
        tree = ET.XML(xmlstr)

        self.meta = {}
        self._items = []
        self._related = []

        utils.log('Found programme: %s' % tree.find('title').text,xbmc.LOGINFO)
        self.meta['title'] = tree.find('title').text
        self.meta['summary'] = tree.find('summary').text

        for link in tree.findall('link'):
            if link.attrib['rel'] == 'holding':
                self.meta['thumbnail'] = link.attrib['href']
                break

        # Live radio feeds have no text node in the summary node
        if self.meta['summary'] is not None:
            self.meta['summary'].lstrip(' ')
        self.meta['date'] = tree.find('updated').text

        if tree.find('noitems'):
            utils.log('No playlist items: %s' % tree.find('noitems').get('reason'),xbmc.LOGINFO)
            self.meta['reason'] = tree.find('noitems').get('reason')

        self._items = [item(self, i) for i in tree.findall('item')]

        for link in tree.findall('relatedlink'):
            i = {}
            i['title'] = link.find('title').text
            #i['summary'] = item.summary # FIXME looks like a bug in BSS
            i['pid'] = (re_concept_id.findall(link.find('id').text) or [None])[0]
            i['programme'] = programme(i['pid'])
            self._related.append(i)
    def categories(self):
        categories = []
        url = self.create_url()
        data = httpget(url)

        if self.format == 'xml':
            # remove namespace
            data = utils.xml_strip_namespace(data)

            root = ET.fromstring(data)
            categories = []
            for category in root.getiterator('category'):
                id = category.find('id').text
                text = category.find('text').text
                categories.append([ text, id ])

        if self.format == 'json':
            json = _json.loads(data)

            for parent in json['blocklist']:
                id = parent['id']
                text = parent['text']
                categories.append([ text, id ])
                if 'child_categories' in parent:
                    for child in parent['child_categories']:
                        id = child['id']
                        text = child['text']
                        categories.append([ text, id ])

        return categories
    def get_media_list_for(self, stream, provider_pref):
        """
        Returns a list of media objects for the given rate, putting the
        preferred provider first if it exists
        """
        if not self.medias:
            url = self.mediaselector_url()
            utils.log("Stream XML URL: %s" % url,xbmc.LOGINFO)
            xml = httpget(url)
            xml = utils.xml_strip_namespace(xml)
            tree = ET.XML(xml)
            self.medias = []
            for m in tree.findall('media'):
                self.medias.extend(media.create_from_media_xml(self, m))

        result = []
        for m in self.medias:
            if m.application == stream:
                if m.connection_kind == provider_pref:
                    result.insert(0, m)
                else:
                    result.append(m)

        return result