Beispiel #1
0
def connect_openvpn(config, restart=False, sudopassword=None):
    log_debug('Connecting OpenVPN configuration: [%s]' % config)
    global _state

    if _sudo and _sudopwdrequired and sudopassword is None:
        sudopassword = utils.keyboard(
            heading=_settings.get_string(3012), hidden=True)
    openvpn = vpn.OpenVPN(_openvpn, _settings.get_datapath(
        config), ip=_ip, port=_port, args=_args, sudo=_sudo, sudopwd=sudopassword, debug=(_settings['debug'] == 'true'))
    try:
        if restart:
            openvpn.disconnect()
            _state = disconnected
        openvpn.connect()
        display_notification(_settings.get_string(4002) % os.path.splitext(os.path.basename(config))[0])
        _state = connected
    except vpn.OpenVPNError as exception:
        if exception.errno == 1:
            _state = connected
            if utils.yesno(_settings.get_string(3002), _settings.get_string(3009), _settings.get_string(3010)):
                log_debug('User has decided to restart OpenVPN')
                connect_openvpn(config, True, sudopassword)
            else:
                log_debug('User has decided not to restart OpenVPN')
        else:
            utils.ok(_settings.get_string(
                3002), _settings.get_string(3011), exception.string)
            _state = failed
def play_streams(streams, name=None, logo=None):
    log_debug('play_streams', 2)
    log_debug('streams: %s' % streams, 3)
    log_debug('name: %s' % name, 3)
    log_debug('logo: %s' % logo, 3)
    if (__prompt__ and xbmc.Player().isPlayingAudio()):
        if (utils.yesno(__addonname__, __settings__.get_string(3005))):
            add_streams(streams, name, logo)
    else:
        add_streams(streams, name, logo)
Beispiel #3
0
def delete_ovpn():
    name = select_ovpn()
    if name is not None and len(name) > 0:
        ovpn = _settings.get_datapath(name)
        log_debug('Delete: [%s]' % ovpn)
        if os.path.exists(ovpn):
            if not utils.yesno(_settings.get_string(3002), _settings.get_string(3006)):
                utils.ok(_settings.get_string(
                    3002), _settings.get_string(3007))
            else:
                log_debug('Deleting: [%s]' % (ovpn))
                os.remove(ovpn)
    elif name is None:
        utils.ok(_settings.get_string(3002), _settings.get_string(3008))
Beispiel #4
0
def import_ovpn():
    path = utils.browse_files(_settings.get_string(3000), mask='.ovpn|.conf')
    if path and os.path.exists(path) and os.path.isfile(path):
        log_debug('Import: [%s]' % path)
        name = utils.keyboard(heading=_settings.get_string(3001))
        if name and len(name) > 0:
            ovpn = _settings.get_datapath('%s.ovpn' % name)
            if os.path.exists(ovpn) and not utils.yesno(_settings.get_string(3002), _settings.get_string(3003)):
                    utils.ok(_settings.get_string(
                        3002), _settings.get_string(3004))
            else:
                log_debug('Copying [%s] to [%s]' % (path, ovpn))
                shutil.copyfile(path, ovpn)
        else:
            utils.ok(_settings.get_string(3002), _settings.get_string(3005))
Beispiel #5
0
def delete_ovpn():
    name = select_ovpn()
    if name is not None and len(name) > 0:
        ovpn = _settings.get_datapath(name)
        log_debug('Delete: [%s]' % ovpn)
        if os.path.exists(ovpn):
            if not utils.yesno(_settings.get_string(3002),
                               _settings.get_string(3006)):
                utils.ok(_settings.get_string(3002),
                         _settings.get_string(3007))
            else:
                log_debug('Deleting: [%s]' % (ovpn))
                os.remove(ovpn)
    elif name is None:
        utils.ok(_settings.get_string(3002), _settings.get_string(3008))
Beispiel #6
0
def import_ovpn():
    path = utils.browse_files(_settings.get_string(3000), mask='.ovpn|.conf')
    if path and os.path.exists(path) and os.path.isfile(path):
        log_debug('Import: [%s]' % path)
        name = utils.keyboard(heading=_settings.get_string(3001))
        if name and len(name) > 0:
            ovpn = _settings.get_datapath('%s.ovpn' % name)
            if os.path.exists(ovpn) and not utils.yesno(
                    _settings.get_string(3002), _settings.get_string(3003)):
                utils.ok(_settings.get_string(3002),
                         _settings.get_string(3004))
            else:
                log_debug('Copying [%s] to [%s]' % (path, ovpn))
                shutil.copyfile(path, ovpn)
        else:
            utils.ok(_settings.get_string(3002), _settings.get_string(3005))
Beispiel #7
0
def connect_openvpn(config, restart=False, sudopassword=None):
    log_debug('Connecting OpenVPN configuration: [%s]' % config)
    global _state

    if _sudo and _sudopwdrequired and sudopassword is None:
        sudopassword = utils.keyboard(heading=_settings.get_string(3012),
                                      hidden=True)
    openvpn = vpn.OpenVPN(_openvpn,
                          _settings.get_datapath(config),
                          ip=_ip,
                          port=_port,
                          args=_args,
                          sudo=_sudo,
                          sudopwd=sudopassword,
                          debug=(_settings['debug'] == 'true'))
    try:
        if restart:
            openvpn.disconnect()
            _state = disconnected
        openvpn.connect()
        display_notification(
            _settings.get_string(4002) %
            os.path.splitext(os.path.basename(config))[0])
        _state = connected
    except vpn.OpenVPNError as exception:
        if exception.errno == 1:
            _state = connected
            if utils.yesno(_settings.get_string(3002),
                           _settings.get_string(3009),
                           _settings.get_string(3010)):
                log_debug('User has decided to restart OpenVPN')
                connect_openvpn(config, True, sudopassword)
            else:
                log_debug('User has decided not to restart OpenVPN')
        else:
            utils.ok(_settings.get_string(3002), _settings.get_string(3011),
                     exception.string)
            _state = failed
                                         listitem=liz,
                                         isFolder=False)
    xbmcplugin.endOfDirectory(int(__settings__.get_argv(1)))

# Play an episode
elif __path__ == 'episode':
    episode = __overcast__.episode(__url__)
    liz = xbmcgui.ListItem(episode['title'],
                           iconImage=episode['artworkURL'],
                           thumbnailImage=episode['artworkURL'])
    liz.setInfo('music', {
        'title': episode['title'],
        'artist': episode['podcastTitle']
    })
    if (__prompt__ and xbmc.Player().isPlayingAudio()):
        if (utils.yesno(__addonname__, __settings__.get_string(3001))):
            xbmc.Player().play(item=episode['url'], listitem=liz)
    else:
        xbmc.Player().play(item=episode['url'], listitem=liz)

# Refresh display.
elif __path__ == 'refresh':
    xbmc.executebuiltin('Container.Refresh')

# Search for a podcast.
elif __path__ == 'search':
    try:
        searchstring = utils.keyboard(heading=__settings__.get_string(3000))
        if (searchstring and len(searchstring) > 0):
            podcasts = __overcast__.search(searchstring)
            contextmenu = [(__settings__.get_string(1001),
        streams = []
        if __id__ and __tunein__.is_custom_url_id(__id__):
            url = utils.get_value(__params__, 'url')
        else:
            url = utils.keyboard(heading=__settings__.get_string(3006))

        if (url and len(url) > 0):
            streams.append(url)
            results = __tunein__.search_stream(url)
            name = utils.get_value(__params__, 'name')
            logo = utils.get_value(__params__, 'logo')
            known_id = None
            for station in results:
                if ('guide_id' in station and __tunein__.is_station_id(station['guide_id'])):
                    known_id = station['guide_id']
                    if (utils.yesno(__addonname__, __settings__.get_string(3007) % station['text'], __settings__.get_string(3008))):
                        result = __tunein__.preset_add(
                            __username__, __password__, id=known_id)
                        break

            if known_id is None and (__id__ is None or not __tunein__.is_custom_url_id(__id__)):
                if (utils.yesno(__addonname__, __settings__.get_string(3012), __settings__.get_string(3013))):
                    name = utils.keyboard(
                        heading=__settings__.get_string(3014))
                    result = __tunein__.preset_add(
                        __username__, __password__, url=url, name=name)

            play_streams(streams, name, logo)
            if __id__ and __tunein__.is_custom_url_id(__id__):
                _recentscache.add({'URL': url, 'guide_id': __id__, 'image': logo, 'text': utils.get_value(
                    __params__, 'name')}, 'guide_id')