def onSettingsChanged(self):
        with self._lock:
            port_changed = enabled_changed = False

            port = get_port()
            if port != self._port:
                self._port = port
                port_changed = True

            enabled = service_enabled()
            if enabled != self._enabled:
                self._enabled = enabled
                enabled_changed = True

            if self._enabled:
                if port_changed and not enabled_changed:
                    self._stop()
                if port_changed or enabled_changed:
                    self._start()
                    self._wait(timeout=get_daemon_timeout(), notification=True)
                self._update_daemon_settings()
            elif enabled_changed:
                self._stop()
Beispiel #2
0
 def onSettingsChanged(self):
     self._api = Torrest(get_service_ip(), get_port())
     self._enabled = show_background_progress()
Beispiel #3
0
import routing
from xbmc import Monitor, executebuiltin, getInfoLabel, getCondVisibility, sleep
from xbmcgui import ListItem, DialogProgress, Dialog
from xbmcplugin import addDirectoryItem, endOfDirectory, setResolvedUrl

from lib.api import Torrest
from lib.dialog import DialogInsert
from lib.kodi import ADDON_PATH, ADDON_NAME, translate, notification, set_logger, refresh, show_picture
from lib.kodi_formats import is_music, is_picture, is_video, is_text
from lib.player import TorrestPlayer
from lib.settings import get_service_ip, get_port, get_buffering_timeout, show_status_overlay, get_min_candidate_size, \
    ask_to_delete_torrent, download_after_insert, get_files_order

set_logger()
plugin = routing.Plugin()
api = Torrest(get_service_ip(), get_port())


class PlayError(Exception):
    pass


def check_playable(func):
    def wrapper(*args, **kwargs):
        try:
            func(*args, **kwargs)
        except Exception as e:
            setResolvedUrl(plugin.handle, False, ListItem())
            if isinstance(e, PlayError):
                logging.debug(e)
            else: