Ejemplo n.º 1
0
    def map_channels(self):
        i = 0
        try:
            xml_data = Utils.download_binary(Utils.build_uri(self._handle, self._channels_uri))
        except StandardError as e:
            xbmcgui.Dialog().ok('tric', e)
            return

        try:
            vod_xml_data = Utils.download_binary(Utils.build_uri(self._handle, self._vod_uri))
        except StandardError as e:
            xbmcgui.Dialog().ok('tric', e)
            return

        parsed_xml = ET.fromstring(xml_data)
        vod_parsed_xml = ET.fromstring(vod_xml_data)

        for channel in parsed_xml.findall('channel'):
            try:
                name = channel.find("name").text.encode('utf-8').strip()
            except AttributeError:
                name = None

            try:
                logo = channel.find("logo").text.encode('utf-8')
            except AttributeError:
                logo = ''

            try:
                url = channel.find("url").text.encode('utf-8').strip()
            except AttributeError:
                url = None

            try:
                program_title = channel.find("program_title").text.encode('utf-8').strip()
            except AttributeError:
                program_title = ''

            if name is not None:
                self._channels_list.append(name)
                self._channels_map[name] = {
                    "name": name,
                    "logo": logo,
                    "url": url,
                    "program_title": program_title
                }

                for vod_channel in vod_parsed_xml.findall('channel'):
                    try:
                        vod_name = vod_channel.find("name").text.encode('utf-8').strip()
                    except AttributeError:
                        continue

                    if vod_name == name:
                        self._channels_map[name]['id'] = vod_channel.find('stream').text.encode('utf-8').strip()
Ejemplo n.º 2
0
    def vod_channel(self, channel):
        xbmcplugin.setPluginCategory(self._handle, 'Annatel')
        xbmcplugin.setContent(self._handle, 'files')

        try:
            uri = Utils.build_uri(self._handle, self._vod_uri,
                                  act="channel", channel=channel)
            xml_data = Utils.download_binary(uri)
        except StandardError as e:
            xbmcgui.Dialog().ok('tric', e)
            return

        listing = []
        parsed_xml = ET.fromstring(xml_data)
        for date in parsed_xml.findall("date"):
            d = date.find("day").text.encode('utf-8').strip()
            human_date = date.find("display").text.encode('utf-8').strip()

            list_item = xbmcgui.ListItem(label=human_date)
            list_item.setArt({'thumb': self._cal_thumb})
            call = Utils.get_url(action="vod_channel_day", url=self._url, channel=channel, day=d)

            listing.append((call, list_item, True))

        xbmcplugin.addDirectoryItems(self._handle, listing, len(listing))
        xbmcplugin.endOfDirectory(self._handle)
Ejemplo n.º 3
0
    def channel_select(self, url):
        m3u8_data = io.StringIO(unicode(Utils.download_binary(url)))
        last_line = None

        for i in m3u8_data.readlines():
            last_line = i

        uri = url.rsplit('/', 1)[0] + '/' + last_line.strip()
        play_item = xbmcgui.ListItem()

        xbmc.Player().play(uri, play_item, False)
Ejemplo n.º 4
0
    def vod_channel_day(self, channel_id, day):
        xbmcplugin.setPluginCategory(self._handle, 'Annatel')
        xbmcplugin.setContent(self._handle, 'episodes')

        try:
            uri = Utils.build_uri(self._handle, self._vod_uri,
                                  act="program", channel=channel_id, day=day)
            xml_data = Utils.download_binary(uri)
        except StandardError as e:
            xbmcgui.Dialog().ok('tric', e)
            return

        listing = []
        parsed_xml = ET.fromstring(xml_data)
        for program in parsed_xml.findall('program'):
            try:
                name = program.find("name").text.encode('utf-8').strip()
            except AttributeError:
                name = ''

            try:
                description = program.find("description").text.encode('utf-8').strip()
            except AttributeError:
                description = ''

            try:
                url = program.find("url").text.encode('utf-8').strip()
            except AttributeError:
                url = None

            if url is not None:
                logo = self.retrieve_channel_logo(channel_id)
                list_item = xbmcgui.ListItem(label=name)
                list_item.setProperty('IsPlayable', 'true')
                list_item.setArt({'thumb': logo})
                list_item.setInfo('video', {
                    'title': name,
                    'episodeguide': description
                })
                call = Utils.get_url(action='channel_select', url=url)
                listing.append((call, list_item, False))

        xbmcplugin.addDirectoryItems(self._handle, listing, len(listing))
        xbmcplugin.endOfDirectory(self._handle)
Ejemplo n.º 5
0
    def retrieve_channel_logo(self, channel_id):
        try:
            uri = Utils.build_uri(self._handle, self._vod_uri)
            xml_data = Utils.download_binary(uri)
        except StandardError as e:
            xbmcgui.Dialog().ok('tric', e)
            return

        parsed_xml = ET.fromstring(xml_data)

        for channel in parsed_xml.findall('channel'):
            cid = channel.find('stream').text.encode('utf-8').strip()
            name = channel.find('name').text.encode('utf-8').strip()

            if cid == channel_id:
                if name in self._channels_map:
                    return self._channels_map[name]['logo']

                return None