当前位置: 首页>>代码示例>>Python>>正文


Python Net.save_cookies方法代码示例

本文整理汇总了Python中t0mm0.common.net.Net.save_cookies方法的典型用法代码示例。如果您正苦于以下问题:Python Net.save_cookies方法的具体用法?Python Net.save_cookies怎么用?Python Net.save_cookies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在t0mm0.common.net.Net的用法示例。


在下文中一共展示了Net.save_cookies方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: login_docspt

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import save_cookies [as 别名]
def login_docspt():
      print "Sem cookie. A iniciar login"
      try:
            from t0mm0.common.net import Net
            net=Net()
            #form_d = {'user':username,'passwrd':password,'cookieneverexp':'on','hash_passwrd':token}
            form_d={'user':username,'passwrd':password,'cookielength':-1}
            ref_data = {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Content-Type': 'application/x-www-form-urlencoded','Host':'www.docspt.com','Origin': 'http://www.docspt.com', 'Referer': 'http://www.docspt.com/index.php?action=login2','User-Agent':user_agent}
            endlogin=MainURL + 'index.php?action=login2'
            try:
                  logintest= net.http_POST(endlogin,form_data=form_d,headers=ref_data).content.encode('latin-1','ignore')
            except: logintest='Erro'
      except:
            link='Erro'
            logintest='Erro'

      if selfAddon.getSetting('docspt-username')== '':
            ok = mensagemok('docsPT','Necessitas de criar conta em','docsPT.com')
            entrarnovamente(1)
      else:    
            if re.search('<p class="error">A password est',logintest):
                  mensagemok('docsPT','Password incorrecta.')
                  entrarnovamente(1)
            elif re.search('<p class="error">Esse utilizador n',logintest):
                  mensagemok('docsPT','Esse utilizador não existe.')
                  entrarnovamente(1)
            elif re.search(username+'!</li>',logintest):
                  xbmc.executebuiltin("XBMC.Notification(docsPT,Sessão iniciada com sucesso,'500000','')")
                  net.save_cookies(cookies)
                  menu_principal(1)
            
            elif re.search('Erro',logintest) or link=='Erro':
                  opcao= xbmcgui.Dialog().yesno('docsPT', 'Sem acesso à internet.', "", "","Tentar novamente", 'OK')
                  if opcao: menu_principal(0)
                  else: login_docspt()                
开发者ID:KODeKarnage,项目名称:fightnight-addons,代码行数:37,代码来源:default.py

示例2: install_metapack

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import save_cookies [as 别名]
def install_metapack(pack):
	packs = metapacks.list()
	pack_details = packs[pack]
	mc = metacontainers.MetaContainer()
	work_path  = mc.work_path
	cache_path = mc.cache_path
	zip = os.path.join(work_path, pack)

	net = Net()
	cookiejar = ADDON.get_profile()
	cookiejar = os.path.join(cookiejar,'cookies')

	html = net.http_GET(pack_details[0]).content
	net.save_cookies(cookiejar)
	name = re.sub('-', r'\\\\u002D', pack)

	r = '"name": "%s".*?"id": "([^\s]*?)".*?"secure_prefix":"(.*?)",' % name
	r = re.search(r,html)
	pack_url  = 'http://i.minus.com'
	pack_url += r.group(2)
	pack_url += '/d' + r.group(1) + '.zip'

	complete = download_metapack(pack_url, zip, displayname=pack)
	extract_zip(zip, work_path)
	xbmc.sleep(5000)
	copy_meta_contents(work_path, cache_path)
	for table in mc.table_list:
		install = mc._insert_metadata(table)
开发者ID:zpanderson,项目名称:1Channel,代码行数:30,代码来源:default.py

示例3: TVShowSeasonList

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import save_cookies [as 别名]
def TVShowSeasonList(url, title, year, update=''): #4000
	print 'Seasons for TV Show %s' % url
	net = Net()
	cookiejar = ADDON.get_profile()
	cookiejar = os.path.join(cookiejar,'cookies')
	html = net.http_GET(url).content
	net.save_cookies(cookiejar)
	adultregex = '<div class="offensive_material">.+<a href="(.+)">I understand'
	r = re.search(adultregex, html, re.DOTALL)
	if r:
		print 'Adult content url detected'
		adulturl = BASE_URL + r.group(1)
		headers = {'Referer': url}
		net.set_cookies(cookiejar)
		html = net.http_GET(adulturl, headers=headers).content #.encode('utf-8', 'ignore')

	cnxn = sqlite.connect( DB )
	cnxn.text_factory = str
	cursor = cnxn.cursor()
	if year: title = title +'('+year+')'
	try:
		imdbnum = re.search('mlink_imdb">.+?href="http://www.imdb.com/title/(tt[0-9]{7})"', html).group(1)
	except: imdbnum = ''
	seasons = re.search('tv_container(.+?)<div class="clearer', html, re.DOTALL)
	if not seasons: ADDON.log_error('couldn\'t find seasons')
	else:
		season_container = seasons.group(1)
		season_nums = re.compile('<a href=".+?">Season ([0-9]{1,2})').findall(season_container)
		if imdbnum and META_ON == 'true': 
			metaget.update_meta('tvshow', title, imdbnum, year=year)
			season_meta = metaget.get_seasons(title, imdbnum, season_nums)
			if update:
				metaget.update_meta('tvshow', title, imdb_id='',
									new_imdb_id=imdbnum, year=year)
		seasonList = season_container.split('<h2>')
		num = 0
		temp = {}
		for eplist in seasonList:
			r = re.search('<a.+?>(.+?)</a>', eplist)
			if r:
				season_name = r.group(1)
				try: 	temp = season_meta[num]
				except: temp['cover_url'] = ''
				listitem = xbmcgui.ListItem(season_name, iconImage=temp['cover_url'], thumbnailImage=temp['cover_url'])
				listitem.setInfo(type="Video", infoLabels=temp)
				try: listitem.setProperty('fanart_image', temp['backdrop_url'])
				except: pass
				season_name = unicode_urlencode(season_name).lower()
				cursor.execute('INSERT or REPLACE into seasons (season,contents) VALUES(?,?);',
								(season_name, eplist))
				url = sys.argv[0]+ '?mode=5000'+'&season=' +season_name+ '&imdbnum='+imdbnum
				xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=listitem, 
											isFolder=True)
				cnxn.commit()
				num += 1
		setView('seasons', 'seasons-view')
		xbmcplugin.endOfDirectory(int(sys.argv[1]))
		cnxn.close()
开发者ID:zpanderson,项目名称:1Channel,代码行数:60,代码来源:default.py

示例4: EcostreamResolver

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import save_cookies [as 别名]
class EcostreamResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "ecostream"
    profile_path = common.profile_path
    cookie_file = os.path.join(profile_path, 'ecostream.cookies')

    def __init__(self):
        p = self.get_setting('priority') or 100
        self.priority = int(p)
        self.net = Net()
        self.pattern = 'http://((?:www.)?ecostream.tv)/(?:stream|embed)?/([0-9a-zA-Z]+).html'


    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        try:
            html = self.net.http_GET(web_url).content
            if re.search('>File not found!<',html):
                msg = 'File Not Found or removed'
                common.addon.show_small_popup(title='[B][COLOR white]ECOSTREAM[/COLOR][/B]', msg='[COLOR red]%s[/COLOR]'
                % msg, delay=5000, image=error_logo)
                return self.unresolvable(code = 1, msg = msg)
            self.net.save_cookies(self.cookie_file)
            r = re.search("anlytcs='([^']+)'", html)
            if not r:
                raise Exception ('Formvalue not found')
            part1 = r.group(1)
            r = re.search("superslots='([^']+)';", html)
            if not r:
                raise Exception ('Formvalue not found')
            part2 = r.group(1)
            tpm = part1+part2
            # emulate click on button "Start Stream"
            postHeader = ({'Referer':web_url, 'X-Requested-With':'XMLHttpRequest'})
            web_url = 'http://www.ecostream.tv/xhr/video/vidureis'
            self.net.set_cookies(self.cookie_file)
            html = self.net.http_POST(web_url,{'id':media_id, 'tpm':tpm}, headers = postHeader).content
            sPattern = '"url":"([^"]+)"'
            r = re.search(sPattern, html)
            if not r:
                raise Exception ('Unable to resolve Ecostream link. Filelink not found.')
            sLinkToFile = 'http://www.ecostream.tv'+r.group(1)
            return urllib2.unquote(sLinkToFile)

        except urllib2.URLError, e:
            common.addon.log_error(self.name + ': got http error %d fetching %s' %
                                    (e.code, web_url))
            common.addon.show_small_popup('Error','Http error: '+str(e), 8000, error_logo)
            return self.unresolvable(code=3, msg='Exception: %s' % e)
        except Exception, e:
            common.addon.log('**** Ecostream Error occured: %s' % e)
            common.addon.show_small_popup(title='[B][COLOR white]ECOSTREAM[/COLOR][/B]', msg='[COLOR red]%s[/COLOR]'
            % e, delay=5000, image=error_logo)
            return self.unresolvable(code=0, msg='Exception: %s' % e)
开发者ID:TinyHTPC,项目名称:xbmc-packs,代码行数:56,代码来源:ecostream.py

示例5: Search

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import save_cookies [as 别名]
def Search(section, query, imdb):
    html = GetURL(BASE_URL)
    r = re.search('input type="hidden" name="key" value="([0-9a-f]*)"', html).group(1)
    search_url = BASE_URL + '/index.php?search_keywords='
    search_url += urllib.quote_plus(query)
    search_url += '&key=' + r
    if section == 'tv':
        search_url += '&search_section=2'
        video_type = 'tvshow'
    else:
        video_type = 'movie'

    html = GetURL(search_url)

    r = 'class="index_item.+?href="(.+?)" title="Watch (.+?)"?\(?([0-9]{4})?\)?"?>.+?src="(.+?)"'
    regex = re.search(r, html, re.DOTALL)
    if regex:
        url,title,year,thumb = regex.groups()
        net = Net()
        cookiejar = addon.get_profile()
        cookiejar = os.path.join(cookiejar,'cookies')
        net.set_cookies(cookiejar)
        html = net.http_GET(BASE_URL + url).content
        net.save_cookies(cookiejar)
        adultregex = '<div class="offensive_material">.+<a href="(.+)">I understand'
        r = re.search(adultregex, html, re.DOTALL)
        if r:
            addon.log('Adult content url detected')
            adulturl = BASE_URL + r.group(1)
            headers = {'Referer': url}
            net.set_cookies(cookiejar)
            html = net.http_GET(adulturl, headers=headers).content
            net.save_cookies(cookiejar)

        for version in re.finditer('<table[^\n]+?class="movie_version(?: movie_version_alt)?">(.*?)</table>',
                                    html, re.DOTALL|re.IGNORECASE):
            for s in re.finditer('quality_(?!sponsored|unknown)(.*?)></span>.*?'+
                                  'url=(.*?)&(?:amp;)?domain=(.*?)&(?:amp;)?(.*?)'+
                                 '"version_veiws"> ([\d]+) views</',
                                 version.group(1), re.DOTALL):
                q, url, host, parts, views = s.groups()
                q = q.upper()
                url = url.decode('base-64')
                host = host.decode('base-64')
                disp_title = '[%s] %s (%s views)' %(q, host, views)
                result = {'tag':tag, 'provider_name':display_name}
                qs = {'url':url, 'title':title, 'img':thumb, 'year':year, 'imdbnum':imdb}
                qs['video_type'] = video_type
                qs['strm'] = True
                qs['mode'] = 'PlaySource'
                result['li_url'] = 'plugin://plugin.video.1channel/?%s' %urllib.urlencode(qs)
                print result['li_url']
                result['info_labels'] = {'title':disp_title}
                yield result
开发者ID:rollysalvana,项目名称:pampereo-xbmc-plugins,代码行数:56,代码来源:1Channel_provider.py

示例6: EcostreamResolver

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import save_cookies [as 别名]
class EcostreamResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "ecostream"
    profile_path = common.profile_path
    cookie_file = os.path.join(profile_path, "ecostream.cookies")

    def __init__(self):
        p = self.get_setting("priority") or 100
        self.priority = int(p)
        self.net = Net()
        self.pattern = "http://((?:www.)?ecostream.tv)/(?:stream|embed)?/([0-9a-zA-Z]+).html"

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        try:
            html = self.net.http_GET(web_url).content()
            if re.search(">File not found!<", html):
                msg = "File Not Found or removed"
                common.addon.show_small_popup(
                    title="[B][COLOR white]ECOSTREAM[/COLOR][/B]",
                    msg="[COLOR red]%s[/COLOR]" % msg,
                    delay=5000,
                    image=error_logo,
                )
                return self.unresolvable(code=1, msg=msg)
            self.net.save_cookies(self.cookie_file)
            # emulate click on button "Start Stream"
            postHeader = {"Referer": web_url, "X-Requested-With": "XMLHttpRequest"}
            web_url = "http://www.ecostream.tv/xhr/video/get"
            self.net.set_cookies(self.cookie_file)
            html = self.net.http_POST(web_url, {"id": media_id}, headers=postHeader).content
            sPattern = '"url":"([^"]+)"'
            r = re.search(sPattern, html)
            if not r:
                raise Exception("Unable to resolve Ecostream link. Filelink not found.")
            sLinkToFile = "http://www.ecostream.tv" + r.group(1)
            return urllib2.unquote(sLinkToFile)

        except urllib2.URLError, e:
            common.addon.log_error(self.name + ": got http error %d fetching %s" % (e.code, web_url))
            common.addon.show_small_popup("Error", "Http error: " + str(e), 8000, error_logo)
            return self.unresolvable(code=3, msg="Exception: %s" % e)
        except Exception, e:
            common.addon.log("**** Ecostream Error occured: %s" % e)
            common.addon.show_small_popup(
                title="[B][COLOR white]ECOSTREAM[/COLOR][/B]",
                msg="[COLOR red]%s[/COLOR]" % e,
                delay=5000,
                image=error_logo,
            )
            return self.unresolvable(code=0, msg="Exception: %s" % e)
开发者ID:pi3man,项目名称:script.module.urlresolver,代码行数:53,代码来源:ecostream.py

示例7: login_abelhas

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import save_cookies [as 别名]
def login_abelhas():
      print "Sem cookie. A iniciar login"
      from t0mm0.common.net import Net
      net=Net()
      try:
            link=abrir_url(MainURL)
            token=re.compile('<input name="__RequestVerificationToken" type="hidden" value="(.+?)" />').findall(link)[0]
            form_d = {'RedirectUrl':'','Redirect':'True','FileId':0,'Login':username,'Password':password,'RememberMe':'true','__RequestVerificationToken':token}
            ref_data = {'Accept': '*/*', 'Content-Type': 'application/x-www-form-urlencoded','Origin': 'http://abelhas.pt', 'X-Requested-With': 'XMLHttpRequest', 'Referer': 'http://abelhas.pt/','User-Agent':user_agent}
            endlogin=MainURL + 'action/login/login'
            try:
                  logintest= net.http_POST(endlogin,form_data=form_d,headers=ref_data).content.encode('latin-1','ignore')
            except: logintest='Erro'
      except:
            link='Erro'
            logintest='Erro'

      if selfAddon.getSetting('abelhas-username')== '':
            ok = mensagemok('Karaoke Português',traducao(40000),traducao(40001))
            entrarnovamente(1)
      else:    
            if re.search('003eA senha indicada n',logintest):
                  mensagemok('Karaoke Português',traducao(40002))
                  entrarnovamente(1)
            elif re.search('existe. Certifica-te que indicaste o nome correcto.',logintest):
                  mensagemok('Karaoke Português',traducao(40003))
                  entrarnovamente(1)
            elif re.search(username,logintest):
                  #xbmc.executebuiltin("XBMC.Notification(Karaoke Português,"+traducao(40004)+",'500000',"+iconpequeno.encode('utf-8')+")")
                  net.save_cookies(cookies)
                  conteudo=clean(abrir_url_cookie(MainURL + str(entrada.decode('rot13'))))
                  if re.search('ProtectedFolderChomikLogin',conteudo):
                        chomikid=re.compile('<input id="ChomikId" name="ChomikId" type="hidden" value="(.+?)" />').findall(conteudo)[0]
                        folderid=re.compile('<input id="FolderId" name="FolderId" type="hidden" value="(.+?)" />').findall(conteudo)[0]
                        foldername=re.compile('<input id="FolderName" name="FolderName" type="hidden" value="(.+?)" />').findall(conteudo)[0]
                        token=re.compile('<input name="__RequestVerificationToken" type="hidden" value="(.+?)" />').findall(conteudo)[0]
                        routinas1='Cnffjbeq'; routinas2='enzobvn'
                        form_d = {'ChomikId':chomikid,'FolderId':folderid,'FolderName':foldername,str(routinas1.decode('rot13')):str(routinas2.decode('rot13')),'Remember':'true','__RequestVerificationToken':token}
                        ref_data = {'Accept':'*/*','Content-Type':'application/x-www-form-urlencoded','Host':'abelhas.pt','Origin':'http://abelhas.pt','Referer':url,'User-Agent':user_agent,'X-Requested-With':'XMLHttpRequest'}
                        endlogin=MainURL + 'action/Files/LoginToFolder'
                        teste= net.http_POST(endlogin,form_data=form_d,headers=ref_data).content.encode('latin-1','ignore')

                  verificarbd()                 
                  menu_principal(1)
            
            elif re.search('Erro',logintest) or link=='Erro':
                  opcao= xbmcgui.Dialog().yesno('Karaoke Português', traducao(40005), "", "",traducao(40006), 'OK')
                  if opcao: menu_principal(0)
                  else: login_abelhas()
开发者ID:Thewallguy,项目名称:fightnight-addons,代码行数:51,代码来源:default.py

示例8: PrimeshareResolver

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import save_cookies [as 别名]
class PrimeshareResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "primeshare"
    domains = ["primeshare.tv"]
    profile_path = common.profile_path
    cookie_file = os.path.join(profile_path, "primeshare.cookies")

    def __init__(self):
        p = self.get_setting("priority") or 100
        self.priority = int(p)
        self.net = Net()

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        html = self.net.http_GET(web_url).content
        if re.search(">File not exist<", html):
            raise UrlResolver.ResolverError("File Not Found or removed")
        self.net.save_cookies(self.cookie_file)
        headers = {"Referer": web_url}
        # wait required
        common.addon.show_countdown(8)
        self.net.set_cookies(self.cookie_file)
        html = self.net.http_POST(web_url, form_data={"hash": media_id}, headers=headers).content
        r = re.compile("clip:.*?url: '([^']+)'", re.DOTALL).findall(html)
        if not r:
            r = re.compile("download\('([^']+)'", re.DOTALL).findall(html)
        if not r:
            raise UrlResolver.ResolverError("Unable to resolve Primeshare link. Filelink not found.")
        return r[0]

    def get_url(self, host, media_id):
        return "http://primeshare.tv/download/%s" % (media_id)

    def get_host_and_id(self, url):
        r = re.search("http://(?:www.)(.+?)/download/([0-9A-Za-z]+)", url)
        if r:
            return r.groups()
        else:
            r = re.search("//(.+?)/download/([0-9A-Za-z]+)", url)
            if r:
                return r.groups()
            else:
                return False

    def valid_url(self, url, host):
        return re.match("http://(www.)?primeshare.tv/download/[0-9A-Za-z]+", url) or "primeshare" in host
开发者ID:schmidthans,项目名称:script.module.urlresolver,代码行数:48,代码来源:primeshare.py

示例9: PrimeshareResolver

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import save_cookies [as 别名]
class PrimeshareResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "primeshare"
    domains = [ "primeshare.tv" ]
    profile_path = common.profile_path
    cookie_file = os.path.join(profile_path, 'primeshare.cookies')

    def __init__(self):
        p = self.get_setting('priority') or 100
        self.priority = int(p)
        self.net = Net()
       

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        try:          
            html = self.net.http_GET(web_url).content
            if re.search('>File not exist<',html):
                msg = 'File Not Found or removed'
                common.addon.show_small_popup(title='[B][COLOR white]PRIMESHARE[/COLOR][/B]', msg='[COLOR red]%s[/COLOR]' 
                % msg, delay=5000, image=error_logo)
                return self.unresolvable(code = 1, msg = msg)          
            self.net.save_cookies(self.cookie_file)
            headers = {'Referer':web_url}
            # wait required
            common.addon.show_countdown(8)
            self.net.set_cookies(self.cookie_file)
            html = self.net.http_POST(web_url, form_data={'hash':media_id}, headers = headers).content
            r = re.compile("clip:.*?url: '([^']+)'",re.DOTALL).findall(html)
            if not r:
                r = re.compile("download\('([^']+)'",re.DOTALL).findall(html)
            if not r:
                raise Exception ('Unable to resolve Primeshare link. Filelink not found.')
            return r[0]
        
        except urllib2.URLError, e:
            common.addon.log_error(self.name + ': got http error %d fetching %s' %
                                    (e.code, web_url))
            common.addon.show_small_popup('Error','Http error: '+str(e), 8000, error_logo)
            return self.unresolvable(code=3, msg='Exception: %s' % e) 
        except Exception, e:
            common.addon.log('**** Primeshare Error occured: %s' % e)
            common.addon.show_small_popup(title='[B][COLOR white]PRIMESHARE[/COLOR][/B]', msg='[COLOR red]%s[/COLOR]' % e, delay=5000, image=error_logo)
            return self.unresolvable(code=0, msg='Exception: %s' % e)
开发者ID:VioletRed,项目名称:script.module.urlresolver,代码行数:46,代码来源:primeshare.py

示例10: karaokanta_LOGIN

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import save_cookies [as 别名]
def karaokanta_LOGIN():
    
    loginurl = 'http://www.karaokantalive.com/login.php?action=process'
    username = ADDON.getSetting('karaokantaliveuser')
    password = ADDON.getSetting('karaokantalivepass')

    html = net.http_GET('http://www.karaokantalive.com').content
    formid=re.compile('name="formid" value="(.+?)"').findall (html)[0]
    data     = {'formid':formid,'password': password,
                                            'email_address': username,
                                            'submit.x':'0','submit.y':'0'}
    headers  = {'Host':'www.karaokantalive.com',
                                            'Origin':'http://www.karaokantalive.com',
                                            'Referer':'http://www.karaokantalive.com'}
    
    html = net.http_POST(loginurl, data, headers).content
  
    if os.path.exists(cookie_path) == False:
            os.makedirs(cookie_path)
    net.save_cookies(cookie_jar)
开发者ID:c0ns0le,项目名称:YCBuilds,代码行数:22,代码来源:default.py

示例11: login

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import save_cookies [as 别名]
def login():
    if __ADDON__.getSetting("email") == '' or __ADDON__.getSetting('password') == '':
        __ALERTA__('MrPiracy.xyz', 'Precisa de definir o seu email e password')
        return False
    else:
        try:

            net = Net()

            dados = {'email': __ADDON__.getSetting("email"), 'password': __ADDON__.getSetting("password"), 'lembrar_senha': 'lembrar'}
            
            codigo_fonte = net.http_POST(__SITE__+'login_bd.php',form_data=dados,headers=__HEADERS__).content.encode('utf-8')

            match = re.compile('class="myAccount">(.+?)<\/a>').findall(codigo_fonte)

        except:
            resultado = False
            __ALERTA__('MrPiracy.xyz', 'Não foi possível abrir a página. Por favor tente novamente')
            match = ''
            return resultado

        if match == []:
            match = re.compile('class="myAccount">(.+?)<\/a>').findall(codigo_fonte)

            if match == []:
                resultado = False
                __ALERTA__('MrPiracy.xyz', 'Email e/ou Password incorretos')
                return resultado
            else:
                resultado = True
                xbmc.executebuiltin("XBMC.Notification(MrPiracy.xyz, Sessão iniciada: "+__ADDON__.getSetting("email") +", '10000', "+__ADDON_FOLDER__+"/icon.png)")
                return resultado
        else:
            net.save_cookies(__COOKIE_FILE__)
            resultado = True
            xbmc.executebuiltin("XBMC.Notification(MrPiracy.xyz, Sessão iniciada: "+__ADDON__.getSetting("email") +", '10000', "+__ADDON_FOLDER__+"/icon.png)")
            return resultado
开发者ID:AMOboxTV,项目名称:AMOBox.LegoBuild,代码行数:39,代码来源:addon.py

示例12: VeeHDResolver

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import save_cookies [as 别名]
class VeeHDResolver(Plugin, UrlResolver, SiteAuth, PluginSettings):
    implements = [UrlResolver, SiteAuth, PluginSettings]
    name = "VeeHD"
    domains = ["veehd.com"]
    profile_path = common.profile_path
    cookie_file = os.path.join(profile_path, '%s.cookies' % name)
    
    def __init__(self):
        p = self.get_setting('priority') or 1
        self.priority = int(p)
        self.net = Net()
        try:
            os.makedirs(os.path.dirname(self.cookie_file))
        except OSError:
            pass

    #UrlResolver methods
    def get_media_url(self, host, media_id):
        if not self.get_setting('login') == 'true' or not (self.get_setting('username') and self.get_setting('password')):
            raise UrlResolver.ResolverError('VeeHD requires a username & password')

        web_url = self.get_url(host, media_id)
        html = self.net.http_GET(web_url).content

        # two possible playeriframe's: stream and download
        for match in re.finditer('playeriframe.+?src\s*:\s*"([^"]+)', html):
            player_url = 'http://%s%s' % (host, match.group(1))
            html = self.net.http_GET(player_url).content
            
            # if the player html contains an iframe the iframe url has to be gotten and then the player_url tried again
            r = re.search('<iframe.*?src="([^"]+)', html)
            if r:
                frame_url = 'http://%s%s' % (host, r.group(1))
                self.net.http_GET(frame_url)
                html = self.net.http_GET(player_url).content

            patterns = ['"video/divx"\s+src="([^"]+)', '"url"\s*:\s*"([^"]+)', 'href="([^"]+(?:mp4|avi))']
            for pattern in patterns:
                r = re.search(pattern, html)
                if r:
                    stream_url = urllib.unquote(r.group(1))
                    return stream_url

        raise UrlResolver.ResolverError('File Not Found or Removed')
        
    def get_url(self, host, media_id):
        return 'http://veehd.com/video/%s' % media_id
        
    def get_host_and_id(self, url):
        r = re.search('//(.+?)/video/([0-9A-Za-z]+)', url)
        if r:
            return r.groups()
        else:
            return False

    def valid_url(self, url, host):
        return (re.match('http://(www.)?veehd.com/' +
                         '[0-9A-Za-z]+', url) or
                         'veehd' in host)
       
    #SiteAuth methods
    def login(self):
        loginurl = 'http://veehd.com/login'
        ref = 'http://veehd.com/'
        submit = 'Login'
        login = self.get_setting('username')
        pword = self.get_setting('password')
        terms = 'on'
        remember = 'on'
        data = {'ref': ref, 'uname': login, 'pword': pword, 'submit': submit, 'terms': terms, 'remember_me': remember}
        html = self.net.http_POST(loginurl, data).content
        self.net.save_cookies(self.cookie_file)
        if re.search('my dashboard', html):
            return True
        else:
            return False
        
    #PluginSettings methods
    def get_settings_xml(self):
        xml = PluginSettings.get_settings_xml(self)
        xml += '<setting id="%s_login" ' % (self.__class__.__name__)
        xml += 'type="bool" label="login" default="false"/>\n'
        xml += '<setting id="%s_username" enable="eq(-1,true)" ' % (self.__class__.__name__)
        xml += 'type="text" label="username" default=""/>\n'
        xml += '<setting id="%s_password" enable="eq(-2,true)" ' % (self.__class__.__name__)
        xml += 'type="text" label="password" option="hidden" default=""/>\n'
        return xml
        
    #to indicate if this is a universal resolver
    def isUniversal(self):
        return False
开发者ID:waggy162512,项目名称:script.module.urlresolver,代码行数:93,代码来源:veeHD.py

示例13: ExashareResolver

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import save_cookies [as 别名]
class ExashareResolver(Plugin,UrlResolver,PluginSettings):
    implements   = [UrlResolver,SiteAuth,PluginSettings]
    name         = "exashare"
    domains      = [ "exashare.com" ]
    profile_path = common.profile_path    
    cookie_file  = os.path.join(profile_path,'%s.cookies'%name)
    USER_AGENT   = 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:30.0) Gecko/20100101 Firefox/30.0'
    
    def __init__(self):
        p=self.get_setting('priority') or 100
        self.priority=int(p)
        self.net=Net()
        
    #UrlResolver methods
    def get_media_url(self, host, media_id):
        base_url = 'http://www.' + host + '.com/' + media_id
        headers = {'User-Agent': self.USER_AGENT, 'Referer': 'http://www.' + host + '.com/'}
        try: html = self.net.http_GET(base_url).content
        except: html = self.net.http_GET(base_url, headers=headers).content
        if re.search("""File Not Found""", html):
            raise UrlResolver.ResolverError('File not found or removed')
        POST_Url               = re.findall('form method="POST" action=\'(.*)\'',html)[0]
        POST_Selected          = re.findall('form method="POST" action=(.*)</Form>',html,re.DOTALL)[0]
        POST_Data              = {}
        POST_Data['op']        = re.findall('input type="hidden" name="op" value="(.*)"',POST_Selected)[0]
        POST_Data['usr_login'] = re.findall('input type="hidden" name="usr_login" value="(.*)"',POST_Selected)[0]
        POST_Data['id']        = re.findall('input type="hidden" name="id" value="(.*)"',POST_Selected)[0]
        POST_Data['fname']     = re.findall('input type="hidden" name="fname" value="(.*)"',POST_Selected)[0]
        POST_Data['referer']   = re.findall('input type="hidden" name="referer" value="(.*)"',POST_Selected)[0]
        POST_Data['hash']      = re.findall('input type="hidden" name="hash" value="(.*)"',POST_Selected)[0]
        POST_Data['imhuman']   = 'Proceed to video'
        try : html2 = self.net.http_POST(POST_Url,POST_Data).content
        except : html2 = self.net.http_POST(POST_Url,POST_Data,headers=headers).content
        stream_url = re.findall('file:\s*"([^"]+)"', html2)[0]
        if self.get_setting('login') == 'true':
            cookies = {}
            for cookie in self.net._cj:
                cookies[cookie.name] = cookie.value
            if len(cookies) > 0:
                stream_url = stream_url + '|' + urllib.urlencode({'Cookie': urllib.urlencode(cookies)})
        common.addon.log('stream_url : ' + stream_url)
        xbmc.sleep(7000)
        return stream_url

    def get_url(self,host,media_id):
        return 'http://www.exashare.com/%s' % media_id

    def get_host_and_id(self,url):
        r=re.search('http://(?:www.)?(.+?).com/(?:embed\-)?([0-9A-Za-z_]+)(?:\-[0-9]+x[0-9]+.html)?',url)
        if r:
            ls=r.groups()
            return ls
        else:
            return False

    def valid_url(self, url, host):
        if self.get_setting('enabled')=='false' or self.get_setting('login')=='false': 
            return False
        return re.match('http://(?:www.)?exashare.com/(?:embed\-)?[0-9A-Za-z]+(?:\-[0-9]+x[0-9]+.html)?',url) or 'exashare.com' in host

    #SiteAuth methods
    def needLogin(self):
        url='http://www.exashare.com/?op=my_account'
        if not os.path.exists(self.cookie_file):
            common.addon.log_debug('needLogin returning True')
            return True
        self.net.set_cookies(self.cookie_file)
        source=self.net.http_GET(url).content
        if re.search("""Your username is for logging in and cannot be changed""",source):
            common.addon.log_debug('needLogin returning False')
            return False
        else:
            common.addon.log_debug('needLogin returning True')
            return True
    
    def login(self):
        if (self.get_setting('login')=='true'):
            if self.needLogin():
                common.addon.log('logging in exashare')
                url='http://www.exashare.com/'
                data={'login':self.get_setting('username'),'password':self.get_setting('password'),'op':'login','redirect':'/login.html'}
                headers={'User-Agent':self.USER_AGENT,'Referer':url}
                try: source=self.net.http_POST(url,data).content
                except: source=self.net.http_POST(url,data,headers=headers).content
                if re.search('Your username is for logging in and cannot be changed',source):
                    common.addon.log('logged in exashare')
                    self.net.save_cookies(self.cookie_file)
                    self.net.set_cookies(self.cookie_file)
                    return True
                else:
                    common.addon.log('error logging in exashare')
                    return False
        else:
            if os.path.exists(self.cookie_file): os.remove(self.cookie_file)
            return False
                    
    #PluginSettings methods
    def get_settings_xml(self):
        xml = PluginSettings.get_settings_xml(self)
        xml += '<setting id="ExashareResolver_login" '        
#.........这里部分代码省略.........
开发者ID:Zanzibar82,项目名称:script.module.urlresolver,代码行数:103,代码来源:exashare.py

示例14: EcostreamResolver

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import save_cookies [as 别名]
class EcostreamResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "ecostream"
    domains = ["ecostream.tv"]
    profile_path = common.profile_path
    cookie_file = os.path.join(profile_path, "ecostream.cookies")

    def __init__(self):
        p = self.get_setting("priority") or 100
        self.priority = int(p)
        self.net = Net()
        self.pattern = "http://((?:www.)?ecostream.tv)/(?:stream|embed)?/([0-9a-zA-Z]+).html"

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        try:
            html = self.net.http_GET(web_url).content
            if re.search(">File not found!<", html):
                msg = "File Not Found or removed"
                common.addon.show_small_popup(
                    title="[B][COLOR white]ECOSTREAM[/COLOR][/B]",
                    msg="[COLOR red]%s[/COLOR]" % msg,
                    delay=5000,
                    image=error_logo,
                )
                return self.unresolvable(code=1, msg=msg)
            self.net.save_cookies(self.cookie_file)

            web_url = "http://www.ecostream.tv/js/ecos.js"
            js = self.net.http_GET(web_url).content
            r = re.search("\$\.post\('([^']+)'[^;]+'#auth'\).html\(''\)", js)
            if not r:
                raise Exception("Posturl not found")
            post_url = r.group(1)
            r = re.search('data\("tpm",([^\)]+)\);', js)
            if not r:
                raise Exception("Postparameterparts not found")
            post_param_parts = r.group(1).split("+")
            found_parts = []
            for part in post_param_parts:
                pattern = "%s='([^']+)'" % part.strip()
                r = re.search(pattern, html)
                if not r:
                    raise Exception("Formvaluepart not found")
                found_parts.append(r.group(1))
            tpm = "".join(found_parts)
            # emulate click on button "Start Stream"
            postHeader = {"Referer": web_url, "X-Requested-With": "XMLHttpRequest"}
            web_url = "http://www.ecostream.tv" + post_url
            self.net.set_cookies(self.cookie_file)
            html = self.net.http_POST(web_url, {"id": media_id, "tpm": tpm}, headers=postHeader).content
            sPattern = '"url":"([^"]+)"'
            r = re.search(sPattern, html)
            if not r:
                raise Exception("Unable to resolve Ecostream link. Filelink not found.")
            sLinkToFile = "http://www.ecostream.tv" + r.group(1)
            return urllib2.unquote(sLinkToFile)

        except urllib2.URLError, e:
            common.addon.log_error(self.name + ": got http error %d fetching %s" % (e.code, web_url))
            common.addon.show_small_popup("Error", "Http error: " + str(e), 8000, error_logo)
            return self.unresolvable(code=3, msg="Exception: %s" % e)
        except Exception, e:
            common.addon.log("**** Ecostream Error occured: %s" % e)
            common.addon.show_small_popup(
                title="[B][COLOR white]ECOSTREAM[/COLOR][/B]",
                msg="[COLOR red]%s[/COLOR]" % e,
                delay=5000,
                image=error_logo,
            )
            return self.unresolvable(code=0, msg="Exception: %s" % e)
开发者ID:wljcom,项目名称:dkodi,代码行数:73,代码来源:ecostream.py

示例15: int

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import save_cookies [as 别名]
except:
    pass
try:
    mode = int(params["mode"])
except:
    pass

print "Mode: " + str(mode)
print "URL: " + str(url)
print "Name: " + str(name)

if mode == None or url == None or len(url) < 1:
    print "Versao Instalada: v" + versao
    selfAddon.setSetting("nada", value="false")  # ugly empty addon_data folder creator
    net.http_GET(MainURL)
    net.save_cookies(cookie_sapo)
    menu_principal()

elif mode == 1:
    tops()
elif mode == 2:
    canais()
elif mode == 3:
    categorias()
elif mode == 4:
    pesquisa()
elif mode == 5:
    captura(name, url)
elif mode == 6:
    request(url)
elif mode == 7:
开发者ID:Thewallguy,项目名称:fightnight-addons,代码行数:33,代码来源:default.py


注:本文中的t0mm0.common.net.Net.save_cookies方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。