Пример #1
0
def Bad_Function():
    if debug != 'true':
        dialog.ok(
            'SET DEBUG TO TRUE',
            'Go into your add-on settings and set debug mode to True then run this again. If debug is set to true we have proper error reporting in place to help your add-on development.'
        )
        koding.Open_Settings(focus='1.1')
    xbmc.log(this_should_error, 2)
def doLogin(login_url):

    ''' to call login,source_data = weblogin.dologin(login_url)  

    login_url = site to login into e.g login_url = 'http://p.xxe.press/login.php'
    '''

    source_data = ''
    Addon_Name    = koding.Addon_Info(id='name')
    Addon_Version = koding.Addon_Info(id='version')
    Addon_Profile = koding.Addon_Info(id='profile')
    Cookie_Folder = os.path.join(Addon_Profile,'cookies')
    cookie_name = web.cookie_name_create(login_url)
    cookiepath = os.path.join(Cookie_Folder,str(cookie_name)+'.lwp')
    cookiepath =  koding.Physical_Path(cookiepath)
    username = koding.Addon_Setting('username')
    password = koding.Addon_Setting('password')

    #delete any old version of the cookie file
    try:
        os.remove(cookiepath)
    except:
        pass
    koding.dolog('UserName = %s %s Password = %s %s'%(username,len(username),password,len(password)),line_info=True)
    koding.dolog('cookiepath = %s'%cookiepath,line_info=True)
    if len(username) == 0  or len(password) == 0:
        yesno = koding.YesNo_Dialog(title=str(Addon_Name)+' Login for'+str(login_url),message='There is no UserName or Password set, would you like to set it now?')
        if yesno == True:
            koding.Open_Settings()
        else:
            return False
    if username and password:
        #the header used to pretend you are a browser
        header_string = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3'
	#build the form data necessary for the login
        login_data = urllib.urlencode({'username':username, 'password':password})
        #build the request we will make
        req = urllib2.Request(login_url, login_data)
        req.add_header('User-Agent',header_string)
        #initiate the cookielib class
        cj = cookielib.LWPCookieJar()
        #install cookielib into the url opener, so that cookies are handled
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
        #do the login and get the response
        response = opener.open(req)
        source = response.read()
        source_data += str(source)
        response.close()
        #check the received html for a string that will tell us if the user is logged in
        #pass the username, which can be used to do this.
        login = check_login(source,username)
        #if login suceeded, save the cookiejar to disk
        if login == True:
            cj.save(cookiepath)
        #return whether we are logged in or not
        return login,source_data
    else:
        return False
Пример #3
0
def open_settings():
    koding.Open_Settings("", "", click=True, stop_script=True)
Пример #4
0
# plugin.program.tbs
# Total Revolution Maintenance (c) by Total Revolution [email protected])

# Total Revolution Maintenance is licensed under a
# Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.

# You should have received a copy of the license along with this
# work. If not, see http://creativecommons.org/licenses/by-nc-nd/4.0.

import koding
import xbmc
import shutil

try:
    AddonID = xbmcaddon.Addon().getAddonInfo('id')
except:
    AddonID = koding.Caller()


def Wipe_Settings():
    path = xbmc.translatePath('special://profile/addon_data/' + AddonID)
    shutil.rmtree(path)
    koding.OK_Dialog(String(30338), String(30339))


if __name__ == '__main__':
    koding.Busy_Dialog()
    Wipe_Settings()
    koding.Busy_Dialog(False)
    koding.Open_Settings()
Пример #5
0
def Dependency_OpenSetting(url):
    koding.dolog('Opening Dependency  Settings Menu for ' + str(url),
                 line_info=True)
    koding.Open_Settings(addon_id=url)
Пример #6
0
def epgtools():
    from koding import String
    dialog_array = []
    exec_array = []
    enable_selector = koding.Addon_Setting(setting='usecustom',
                                           addon_id='script.trtv')
    custom_config = koding.Addon_Setting(setting='custom.config.links',
                                         addon_id='script.trtv')
    custom_reset = koding.Addon_Setting(setting='custom.reset',
                                        addon_id='script.trtv')
    custom_settings = koding.Addon_Setting(setting='custom.settings',
                                           addon_id='script.trtv')
    custom_update = koding.Addon_Setting(setting='custom.update.links',
                                         addon_id='script.trtv')
    custom_url = koding.Addon_Setting(setting='custom.url',
                                      addon_id='script.trtv')
    custom_vpn = koding.Addon_Setting(setting='custom.vpn',
                                      addon_id='script.trtv')
    if enable_selector == 'true':
        if custom_vpn == 'true' and xbmc.getCondVisibility(
                'System.HasAddon(service.vpn.manager)'):
            exec_array.append(
                'xbmc.executebuiltin(\'ActivateWindow(10025,"plugin://service.vpn.manager/?toplevel",return)\')'
            )
            dialog_array.append(String(code=30842, source='script.trtv'))
        if 'http' in custom_url:
            dialog_array.append(String(code=30829, source='script.trtv'))
            exec_array.append(
                'xbmc.executebuiltin("RunScript(special://home/addons/plugin.program.tbs/epg.py,listings,silent)")'
            )
        if custom_update == 'true':
            dialog_array.append(String(code=30825, source='script.trtv'))
            exec_array.append(
                'xbmc.executebuiltin("RunScript(special://home/addons/script.trtv/updateini.py)")'
            )
        if custom_config == 'true':
            dialog_array.append(String(code=30826, source='script.trtv'))
            exec_array.append(
                'xbmc.executebuiltin(\'ActivateWindow(10025,"plugin://plugin.video.addons.ini.creator",return)\')'
            )
        if custom_reset == 'true':
            dialog_array.append(String(code=30827, source='script.trtv'))
            if sys.argv[-1] == 'epg':
                exec_array.append(
                    'xbmc.executebuiltin("RunScript(special://home/addons/script.trtv/deleteDB.py,wipeEPG)");xbmc.executebuiltin("ActivateWindow(home)");xbmc.executebuiltin("StopScript(script.trtv)")'
                )
            else:
                exec_array.append(
                    'xbmc.executebuiltin("RunScript(special://home/addons/script.trtv/deleteDB.py,wipeEPG)")'
                )
        if custom_settings == 'true':
            dialog_array.append(String(code=30828, source='script.trtv'))
            exec_array.append(
                'xbmc.executebuiltin("RunScript(special://home/addons/script.trtv/openSettings.py,std)")'
            )
        if len(dialog_array) > 0:
            choice = dialog.select(String(code=30805, source='script.trtv'),
                                   dialog_array)
            if choice >= 0:
                exec(exec_array[choice])
    else:
        dialog.ok(String(code=30830, source='script.trtv'),
                  String(code=30831, source='script.trtv'))
        koding.Open_Settings(addon_id='script.trtv', focus='3.11', click=True)