Beispiel #1
0
def resetTorrentSettings():
    if Dialog().yesno(30013, 30014):
        # Network
        __addon__.setSetting("listen_port", '6881')
        __addon__.setSetting("use_random_port", 'true')
        __addon__.setSetting("encryption", '1')
        __addon__.setSetting("connections_limit", '200')
        # Peers
        __addon__.setSetting("torrent_connect_boost", '50')
        __addon__.setSetting("connection_speed", '50')
        __addon__.setSetting("peer_connect_timeout", '15')
        __addon__.setSetting("min_reconnect_time", '60')
        __addon__.setSetting("max_failcount", '3')
        # Features
        __addon__.setSetting("enable_tcp", 'true')
        __addon__.setSetting("enable_dht", 'true')
        __addon__.setSetting("enable_lsd", 'true')
        __addon__.setSetting("enable_utp", 'true')
        __addon__.setSetting("enable_scrape", 'false')
        __addon__.setSetting("enable_upnp", 'true')
        __addon__.setSetting("enable_natpmp", 'true')
        # Additional
        __addon__.setSetting("trackers", '')
        __addon__.setSetting("dht_routers", '')
        notify(30314)
Beispiel #2
0
    def player(self, subtitle=None, quality=None, **params):
        log("(Main) Creating player options")
        if settings.addon.handle > -1:
            xbmcplugin.endOfDirectory(settings.addon.handle, True, False, False)

        item = self.getSelectedItem()

        free_space = self._calculate_free_space()
        if not quality:
            waring = []
            for _q in self.mediaSettings.qualities:
                if params.get(_q):
                    if params['%ssize' %_q] > free_space:
                        if _q == '3D' and self.mediaSettings.play3d == 1 and not Dialog().yesno(line2=30011, lineStr1=' ', headingStr=item['info']['title']):
                            continue
                        quality = _q
                        break
                    waring = waring+[_q]

            if waring:
                if not quality:
                    raise Notify('There is not enough free space in %s' %self.mediaSettings.download_path, 30323, level=NOTIFYLEVEL.ERROR)

                if len(waring) > 1:
                    notify(message=__addon__.getLocalizedString(30325) %(", ".join(waring), waring.pop()), level=NOTIFYLEVEL.WARNING)
                else:
                    notify(message=__addon__.getLocalizedString(30326) %waring[0], level=NOTIFYLEVEL.WARNING)
                log('(Main) There must be a minimum of %s to play. %s available in %s' %(shortenBytes(params['%ssize' %quality]), shortenBytes(free_space), self.mediaSettings.download_path), LOGLEVEL.NOTICE)

        elif not params.get(quality):
                raise Error('%s quality was not found' %quality, 30023)
        elif params['%ssize' %quality] < free_space:
                raise Notify('There is not enough free space in %s' %self.mediaSettings.download_path, 30323, level=NOTIFYLEVEL.ERROR)

        TorrentPlayer().playTorrentFile(self.mediaSettings, build_magnetFromMeta(params[quality], "quality %s" %quality), item, subtitle)
def resetTorrentSettings():
    if Dialog().yesno(30013, 30014):
        # Network
        __addon__.setSetting("listen_port", '6881')
        __addon__.setSetting("use_random_port", 'true')
        __addon__.setSetting("encryption", '1')
        __addon__.setSetting("connections_limit", '200')
        # Peers
        __addon__.setSetting("torrent_connect_boost", '50')
        __addon__.setSetting("connection_speed", '50')
        __addon__.setSetting("peer_connect_timeout", '15')
        __addon__.setSetting("min_reconnect_time", '60')
        __addon__.setSetting("max_failcount", '3')
        # Features
        __addon__.setSetting("enable_tcp", 'true')
        __addon__.setSetting("enable_dht", 'true')
        __addon__.setSetting("enable_lsd", 'true')
        __addon__.setSetting("enable_utp", 'true')
        __addon__.setSetting("enable_scrape", 'false')
        __addon__.setSetting("enable_upnp", 'true')
        __addon__.setSetting("enable_natpmp", 'true')
        # Additional
        __addon__.setSetting("trackers", '')
        __addon__.setSetting("dht_routers", '')
        notify(30314)
Beispiel #4
0
    def clear_cache(self, **params):
        def _run(path):
            for x in os.listdir(path):
                if x in ['.', '..']:
                    continue
                _path = os.path.join(path, x)
                if os.path.isfile(_path):
                    os.remove(_path)
                elif os.path.isdir(_path):
                    _run(_path)
                    os.rmdir(_path)

        if Dialog().yesno(30033):
            _run(settings.addon.cache_path)
            notify(30301)
Beispiel #5
0
def run():
    try:
        log("(Main) Starting - Platform: %s %s" %(Platform.system, Platform.arch), LOGLEVEL.INFO)

        log("(Main) Platform: %s" %sys.platform)
        if hasattr(os, 'uname'):
            log("(Main) Uname: %s" %str(os.uname()))
        log("(Main) Environ: %s" %str(os.environ))

        if not Platform.system:
            raise Error("Unsupported OS", 30302)

        def _empty_dir(path):
            if os.path.isdir(path):
                for x in os.listdir(path):
                    if x in ['.', '..', 'movies', 'tvshows']:
                        continue
                    _path = os.path.join(path, x)
                    if os.path.isfile(_path):
                        os.remove(_path)
                    elif os.path.isdir(_path):
                        _empty_dir(_path)
                        os.rmdir(_path)

        params = dict(urlparse.parse_qsl(settings.addon.cur_uri))
        if not params.pop('cmd', None):
            if not settings.addon.version+"~1" == settings.addon.last_update_id:
                # Clear cache after update
                _empty_dir(settings.addon.cache_path)
                __addon__.setSetting("last_update_id", settings.addon.version+"~1")
            else:
                # Clean debris from the cache dir
                try:
                    for mediaType in ['movies', 'tvshows']:
                        if getattr(settings, mediaType).delete_files:
                            _empty_dir(os.path.join(settings.addon.cache_path, mediaType))
                except:
                    log_error()
                    sys.exc_clear()
            PopcornTime(**params)
        else:
            Cmd(**params)

    except (Error, HTTPError, ProxyError, TorrentError) as e:
        notify(e.messageID, level=NOTIFYLEVEL.ERROR)
        log_error()
    except Notify as e:
        notify(e.messageID, e.message, level=e.level)
        log("(Main) Notify: %s" %str(e), LOGLEVEL.NOTICE)
        sys.exc_clear()
    except Abort:
        log("(Main) Abort", LOGLEVEL.INFO)
        sys.exc_clear()
    except:
        notify(30308, level=NOTIFYLEVEL.ERROR)
        log_error()
Beispiel #6
0
def clearCache():
    if Dialog().yesno(30033):
        clear_cache()
        notify(30301)
Beispiel #7
0
def clearMediaCache():
    if Dialog().yesno(30033):
        cleanDebris()
        notify(30301)
def clearCache():
    if Dialog().yesno(30033):
        clear_cache()
        notify(30301)
def clearMediaCache():
    if Dialog().yesno(30033):
        cleanDebris()
        notify(30301)
Beispiel #10
0
        log("(Main) Platform: %s" % sys.platform)
        if hasattr(os, 'uname'):
            log("(Main) Uname: %s" % str(os.uname()))
        log("(Main) Environ: %s" % str(os.environ))

        if not Platform.system:
            raise Error("Unsupported OS", 30302)

        params = dict(urlparse.parse_qsl(settings.addon.cur_uri))
        if not params.get('cmd'):
            params = _fix(params)
            getattr(gui, params.pop('endpoint',
                                    'index'))(params.pop('mediaType',
                                                         '')).show(**params)
        else:
            getattr(gui.cmd, params.get('cmd'))()

    except (Error, HTTPError, ProxyError, TorrentError) as e:
        notify(e.messageID, level=NOTIFYLEVEL.ERROR)
        log_error()
    except Notify as e:
        notify(e.messageID, e.message, level=e.level)
        log("(Main) Notify: %s" % str(e), LOGLEVEL.NOTICE)
        sys.exc_clear()
    except Abort:
        log("(Main) Abort", LOGLEVEL.INFO)
        sys.exc_clear()
    except:
        notify(30308, level=NOTIFYLEVEL.ERROR)
        log_error()
Beispiel #11
0
        log("(Main) Starting %s version %s build %s - Platform: %s %s" %(settings.addon.name, settings.addon.version, settings.BUILD, Platform.system, Platform.arch), LOGLEVEL.INFO)

        log("(Main) Platform: %s" %sys.platform)
        if hasattr(os, 'uname'):
            log("(Main) Uname: %s" %str(os.uname()))
        log("(Main) Environ: %s" %str(os.environ))

        if not Platform.system:
            raise Error("Unsupported OS", 30302)

        params = dict(urlparse.parse_qsl(settings.addon.cur_uri))
        if not params.get('cmd'):
            params = _fix(params)
            getattr(gui, params.pop('endpoint', 'index'))(params.pop('mediaType', '')).show(**params)
        else:
            getattr(gui.cmd, params.get('cmd'))()

    except (Error, HTTPError, ProxyError, TorrentError) as e:
        notify(e.messageID, level=NOTIFYLEVEL.ERROR)
        log_error()
    except Notify as e:
        notify(e.messageID, e.message, level=e.level)
        log("(Main) Notify: %s" %str(e), LOGLEVEL.NOTICE)
        sys.exc_clear()
    except Abort:
        log("(Main) Abort", LOGLEVEL.INFO)
        sys.exc_clear()
    except:
        notify(30308, level=NOTIFYLEVEL.ERROR)
        log_error()