コード例 #1
0
 def tick(self):
     if datetime.datetime.now() > self._next_update:
         try:
             self._schedule_next(self.update_interval())
             self._update(False, self.dummy_notification_progress if xbmc.Player().isPlaying() else self.notification_process)
         except UserNotDefinedException:
             pass
         except NetConnectionError:
             self._schedule_next(60)
             log('Can''t update, no internet connection')
             pass
         except Exception as e:
             log(str(e))
             self.notify(_('playlist_or_epg_not_created'), True)
コード例 #2
0
    def onSettingsChanged(self):
        if self.updating:
            return

        self.updating = True
        try:
            self.addon = self.create_addon()  # refresh for updated settings!
            if not self.abortRequested():
                try:
                    res = self._update(True, self.notification_process)

                    if res == 1:
                        self.notify(_('playlist_created'), False)
                    if res == 2:
                        self.notify(_('playlist_and_epg_created'), False)
                except Exception as e:
                    log(str(e))
                    self.notify(_('playlist_or_epg_not_created'), True)
        finally:
            self.updating = False
コード例 #3
0
ファイル: service.py プロジェクト: Sorien/plugin.iptv
    def _update(self, configure, callback):
        # type: (bool, Callable[[str, int], None] or None) -> None or int

        result = None

        _playlist_path = self.playlist_path()
        _epg_path = self.epg_path()

        if not _playlist_path or (not (_playlist_path or _epg_path)):
            return result

        self.prepare_update()

        callback(_('creating_playlist'), 0)

        channels = self.fetch_channels(lambda percent: callback(
            _('creating_playlist'), int(percent // 2.5)))

        try:
            log('Creating playlist [%d channels]' % len(channels))
            iptv.exports.create_m3u(_playlist_path, channels, self.make_url)

            result = 1
        except IOError as e:
            log(str(e))
            raise PlaylistNotCreated()

        if _epg_path:
            try:
                callback(_('creating_epg'), 40)

                epg = self.fetch_epg(
                    channels, lambda percent: callback(_('creating_epg'), 40 +
                                                       (percent // 2)))
                log('Creating XMLTV EPG')
                iptv.exports.create_epg(_epg_path, epg)

                result = 2
            except IOError as e:
                log(str(e))
                raise EpgNotCreated()

        if configure:
            callback(_('configuring_addon'), 90)
            self.updated_after_settings_changed()

        callback('', 100)

        return result
コード例 #4
0
 def _schedule_next(self, seconds):
     # type: (int) -> None
     dt = datetime.datetime.now() + datetime.timedelta(seconds=seconds)
     log('Next update %s' % dt)
     self._next_update = dt
コード例 #5
0
 def save(self):
     log('Saving next update %s' % self._next_update)
     self.addon.setSetting('__next_update', str(time.mktime(self._next_update.timetuple())))
コード例 #6
0
ファイル: service.py プロジェクト: Sorien/plugin.iptv
 def __del__(self):
     log('service destroyed')