def Dependency_OpenSettings():
    DepList = [str(addon_id)]
    dependencies = koding.Dependency_Check(addon_id=addon_id, recursive=True)
    addons_path = koding.Physical_Path('special://home/addons/')
    for dependacy in dependencies:
        if not dependacy in DepList:
            DepList.append(dependacy)
            path = str(addons_path) + str(
                dependacy) + '/resources/settings.xml'
            if xbmcvfs.exists(path):
                try:
                    Addon = xbmcaddon.Addon(str(dependacy))
                    AddonTitle = Addon.getAddonInfo('name')
                    AddonFanart = Addon.getAddonInfo('fanart')
                    AddonIcon = Addon.getAddonInfo('icon')
                    koding.dolog(str(AddonTitle) + ' has file ' + str(path),
                                 line_info=True)
                    BYB.addDir_file(
                        ItemColor('{} {}'.format(local_string(30073),
                                                 AddonTitle)), dependacy, 103,
                        AddonIcon, AddonFanart,
                        '{} {}'.format(local_string(30073),
                                       AddonTitle), '', '', '')
                except:
                    pass
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
Example #3
0
def handle_login():
    try:
        """ get username and password and do login with them """
        """ also get whether to hide successful login notification """
        username = ownAddon.getSetting('username')
        password = ownAddon.getSetting('password')

        login_message_style = ownAddon.getSetting('login_message_style')
        login_welcome_msg = ownAddon.getSetting('login_welcome_msg')
        login_failed_msg = ownAddon.getSetting('login_failed_msg')
        login_required_msg = ownAddon.getSetting('login_required_msg')

        if username == '' or password == '':
            koding.Add_Dir(name=_(login_required_msg),
                           url=_(login_required_msg),
                           mode="message",
                           folder=False,
                           icon=xbmcaddon.Addon().getAddonInfo("icon"),
                           fanart=xbmcaddon.Addon().getAddonInfo("fanart"),
                           content_type="")
            return None

        true_path = koding.Physical_Path(
            ('special://home/addons/%s/' % (addon_id)))
        expiration = ownAddon.getSetting('WEBLOGIN_EXPIRES_AT')
        if time.time() > expiration or expiration == '':
            logged_in = weblogin.verify_login(true_path, username, password)
            if logged_in == True:
                login_message = login_welcome_msg
                expires_at = time.time() + 60 * 60 * int(session_length)
                expiration = expires_at
                ownAddon.setSetting("WEBLOGIN_EXPIRES_AT", str(expires_at))
                display_menu = True
            else:
                login_message = login_failed_msg
                display_menu = False

            if '%s' in login_message:
                login_message = login_message % (username)

            if 'notification' in login_message_style:
                xbmcgui.Dialog().notification(
                    'Login Update', login_message,
                    xbmcaddon.Addon().getAddonInfo("icon"), 4000)
            elif 'popup' in login_message_style:
                xbmcgui.Dialog().ok('Login Update', login_message)
        else:
            display_menu = True
    except:
        failure = traceback.format_exc()
        xbmcgui.Dialog().textviewer(
            'Handle Login Exception - Report this to the developer',
            str(failure))
        display_menu = False
    return display_menu
Example #4
0
def xml_item_count(source, block, tag_to_count):
	''' source == route to file can either be a url or special path
	block == master tag 
	tag_to_count == tag you wish to count
	returns a int value of count
	'''
	count = 0 
	if source.startswith('http'):
		source = koding.Open_URL(url=source,cookiejar=source)
	elif source.startswith('special'):
		source = koding.Physical_Path(source)
		source = koding.Text_File(source,'r')
	else:
		message = 'xml %s source not correct unable to count'%source
		koding.dolog(message,line_info=True)
		xbmc_executebuiltin.Notify(message=message)
	source_details = koding.Parse_XML(source, block, tag_to_count)
	for items in source_details:
		count += 1
	return count
def LOGIN(username, password, hidesuccess):
    root_xml_url = "http://laffinatcha.stream/xml/main.xml"
    uc = username[0].upper() + username[1:]
    lc = username.lower()
    true_path = koding.Physical_Path(
        'special://home/addons/plugin.video.auryn/')
    logged_in = weblogin.doLogin(true_path, username, password)

    if logged_in == True:
        Notify('Welcome', uc + '', '4000')
        get_list(root_xml_url)
    elif logged_in == False:

        Notify('Login Failure', uc + ' could not login', '4000')
        koding.Add_Dir(name=_("You must be logged in"),
                       url=_("You are not logged in"),
                       mode="message",
                       folder=True,
                       icon=xbmcaddon.Addon().getAddonInfo("icon"),
                       fanart=xbmcaddon.Addon().getAddonInfo("fanart"),
                       content_type="")
Example #6
0
import byb_modules as BYB
import _Edit  
import koding
import os 
import sys
import xbmc
import xbmcaddon
import xbmcgui
import xbmcplugin


addon          = _Edit.addon
profile        = xbmc.translatePath(addon.getAddonInfo('profile').decode('utf-8'))
true_profile   = koding.Physical_Path(profile)
COOKIES        = os.path.join(true_profile,'cookies')
pDialog        = xbmcgui.DialogProgress()

def index(iconimage,fanart):
	BYB.addDir_file('Open settings','',100,iconimage,fanart,'Open settings for addon','','','')
	BYB.addDir_file('Delete Cookies','',101,iconimage,fanart,'Clear all Cookies from Cookie cache','','','')
	xbmcplugin.endOfDirectory(int(sys.argv[1]))


def Modes(mode):
	if mode==100:
		koding.dolog('Opening Settings',line_info=True)
		xbmcaddon.Addon().openSettings()
		xbmcplugin.endOfDirectory(int(sys.argv[1]))
	elif mode==101:
		koding.dolog('Clearing Cookies',line_info=True)
		clear_cookies()
Example #7
0
import koding
import os 
from koding import Addon_Info


#Addon paths
''' author, changelog, description, disclaimer, fanart, icon, id, name,
    path, profile, stars, summary, type, version'''

addon             = Addon_Info(id='name')
addon_path        = Addon_Info(id='path')
icon              = Addon_Info(id='icon')
fanart            = Addon_Info(id='fanart')
profile_path      = Addon_Info(id='profile')#path as special
real_profile_path = koding.Physical_Path(profile_path) # path as real c://kodi 
koding.dolog('addon= %s addon_path= %s icon= %s fanart= %s profile_path= %s real_profile_path= %s'%(addon,addon_path,icon,fanart,profile_path,real_profile_path),line_info=True)


#Folder paths







#File Paths
CACHE_DB = os.path.join(real_profile_path,'cache.db')