Пример #1
0
    def create_playlist(self):
        if self._debug_mode:
            log.debug('Executing: api.create_playlist')

        prefs = load_file(file="channel_prefs.json", isJSON=True)
        channels = load_file(file="channels.json", isJSON=True)

        playlist_all = u'#EXTM3U\n'
        playlist = u'#EXTM3U\n'

        for row in channels:
            channeldata = self.get_channel_data(row=row)
            id = unicode(channeldata['channel_id'])

            if len(id) > 0:
                path = 'plugin://{addonid}/?_=play_video&channel={channel}&id={asset}&type=channel&_l=.pvr'.format(
                    addonid=ADDON_ID,
                    channel=channeldata['channel_id'],
                    asset=channeldata['asset_id'])
                playlist_all += u'#EXTINF:-1 tvg-id="{id}" tvg-chno="{channel}" tvg-name="{name}" tvg-logo="{logo}" group-title="TV" radio="false",{name}\n{path}\n'.format(
                    id=channeldata['channel_id'],
                    channel=channeldata['channel_number'],
                    name=channeldata['label'],
                    logo=channeldata['station_image_large'],
                    path=path)

                if not prefs or not check_key(
                        prefs, id) or prefs[id]['epg'] == 'true':
                    playlist += u'#EXTINF:-1 tvg-id="{id}" tvg-chno="{channel}" tvg-name="{name}" tvg-logo="{logo}" group-title="TV" radio="false",{name}\n{path}\n'.format(
                        id=channeldata['channel_id'],
                        channel=channeldata['channel_number'],
                        name=channeldata['label'],
                        logo=channeldata['station_image_large'],
                        path=path)

        self._channels_age = time.time()
        settings.setInt(key='_channels_age', value=self._channels_age)

        if self._debug_mode:
            log.debug('Setting _channels_age to: {channels_age}'.format(
                channels_age=self._channels_age))
            log.debug('Writing tv.m3u8: {playlist}'.format(playlist=playlist))

        write_file(file="tv.m3u8", data=playlist, isJSON=False)
        write_file(file="tv_all.m3u8", data=playlist_all, isJSON=False)
        combine_playlist()

        if self._debug_mode:
            log.debug('Execution Done: api.create_playlist')
Пример #2
0
    def get_channels_for_user(self, location):
        channels_url = '{channelsurl}?byLocationId={location}&includeInvisible=true&personalised=true'.format(
            channelsurl=settings.get('_channels_url'), location=location)
        data = self.download(url=channels_url,
                             type="get",
                             code=[200],
                             data=None,
                             json_data=False,
                             data_return=True,
                             return_json=True,
                             retry=True,
                             check_data=False)

        if data and check_key(data, 'entryCount') and check_key(
                data, 'channels'):
            settings.setInt(key='_channels_age', value=time.time())

            write_file(file="channels.json",
                       data=data['channels'],
                       isJSON=True)

            playlist = u'#EXTM3U\n'

            for row in sorted(
                    data['channels'],
                    key=lambda r: float(r.get('channelNumber', 'inf'))):
                channeldata = self.get_channel_data(row=row)
                urldata = get_play_url(content=channeldata['stream'])

                if urldata and check_key(urldata, 'play_url') and check_key(
                        urldata, 'locator'):
                    path = 'plugin://{addonid}/?_=play_video&type=channel&id={play_url}&locator={locator}&_l=.pvr'.format(
                        addonid=ADDON_ID,
                        play_url=quote(urldata['play_url']),
                        locator=quote(urldata['locator']))

                    playlist += u'#EXTINF:-1 tvg-id="{id}" tvg-chno="{channel}" tvg-name="{name}" tvg-logo="{logo}" group-title="TV" radio="false",{name}\n{path}\n'.format(
                        id=channeldata['channel_id'],
                        channel=channeldata['channel_number'],
                        name=channeldata['label'],
                        logo=channeldata['station_image_large'],
                        path=path)

            write_file(file="tv.m3u8", data=playlist, isJSON=False)
            combine_playlist()
Пример #3
0
    def get_channels_for_user(self):
        channels_url = '{api_url}/TRAY/LIVECHANNELS?orderBy=orderId&sortOrder=asc&from=0&to=999&dfilter_channels=subscription'.format(api_url=settings.get(key='_api_url'))
        data = self.download(url=channels_url, type='get', code=[200], data=None, json_data=False, data_return=True, return_json=True, retry=True, check_data=True)

        if data and check_key(data['resultObj'], 'containers'):
            settings.setInt(key='_channels_age', value=time.time())

            write_file(file="channels.json", data=data['resultObj']['containers'], isJSON=True)

            playlist = u'#EXTM3U\n'

            for row in data['resultObj']['containers']:
                channeldata = self.get_channel_data(row=row)
                path = 'plugin://{addonid}/?_=play_video&channel={channel}&id={asset}&type=channel&_l=.pvr'.format(addonid=ADDON_ID, channel=channeldata['channel_id'], asset=channeldata['asset_id'])
                playlist += u'#EXTINF:-1 tvg-id="{id}" tvg-chno="{channel}" tvg-name="{name}" tvg-logo="{logo}" group-title="TV" radio="false",{name}\n{path}\n'.format(id=channeldata['channel_id'], channel=channeldata['channel_number'], name=channeldata['label'], logo=channeldata['station_image_large'], path=path)

            write_file(file="tv.m3u8", data=playlist, isJSON=False)
            combine_playlist()
Пример #4
0
    def get_channels_for_user(self, channels):
        settings.setInt(key='_channels_age', value=time.time())

        write_file(file="channels.json", data=channels, isJSON=True)

        data = u'#EXTM3U\n'

        for row in channels:
            channeldata = self.get_channel_data(rows=channels, row=row)
            path = 'plugin://{addonid}/?_=play_video&channel={channel}&type=channel&_l=.pvr'.format(
                addonid=ADDON_ID, channel=channeldata['channel_id'])
            data += u'#EXTINF:-1 tvg-id="{id}" tvg-chno="{channel}" tvg-name="{name}" tvg-logo="{logo}" group-title="TV" radio="false",{name}\n{path}\n'.format(
                id=channeldata['channel_id'],
                channel=channeldata['channel_number'],
                name=channeldata['label'],
                logo=channeldata['station_image_large'],
                path=path)

        write_file(file="tv.m3u8", data=data, isJSON=False)
        combine_playlist()