Beispiel #1
0
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)
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()                
Beispiel #3
0
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)
Beispiel #4
0
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()
Beispiel #5
0
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)
Beispiel #6
0
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
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
Beispiel #8
0
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)
Beispiel #9
0
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
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)
Beispiel #11
0
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()
Beispiel #12
0
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()
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
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)
Beispiel #15
0
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)
Beispiel #16
0
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
class MovreelResolver(Plugin, UrlResolver, SiteAuth, PluginSettings):
    implements = [UrlResolver, SiteAuth, PluginSettings]
    name = "movreel"
    profile_path = common.profile_path
    cookie_file = os.path.join(profile_path, '%s.cookies' % name)
    

    def __init__(self):
        p = self.get_setting('priority') or 100
        self.priority = int(p)
        self.net = Net()
        try:
            os.makedirs(os.path.dirname(self.cookie_file))
        except OSError:
            pass
        

    def login(self):

        if self.get_setting('login') == 'true':
            loginurl = 'http://movreel.com/login.html'
            data = {'op': 'login', 'login': self.get_setting('username'), 'password': self.get_setting('password')}
            html = net.http_POST(loginurl, data).content
            if re.search('op=logout', html):
                common.addon.log('LOGIN SUCCESSFUL')
                self.net.save_cookies(self.cookie_file)
                return True
            else:
                common.addon.log('LOGIN FAILED')
                return False
        else:
            common.addon.log('No account info entered')
            return False
        

    def get_media_url(self, host, media_id):
               
        try:

            self.net.set_cookies(self.cookie_file)
            
            url = self.get_url(host, media_id)
            html = self.net.http_GET(url).content
            dialog = xbmcgui.DialogProgress()
            dialog.create('Resolving', 'Resolving Movreel Link...')
            dialog.update(0)
        
            common.addon.log('Movreel - Requesting GET URL: %s' % url)
            html = net.http_GET(url).content
        
            dialog.update(33)
        
            if re.search('This server is in maintenance mode', html):
                common.addon.log('***** Movreel - Site reported maintenance mode')
                raise Exception('File is currently unavailable on the host')

            op = re.search('<input type="hidden" name="op" value="(.+?)">', html).group(1)
            postid = re.search('<input type="hidden" name="id" value="(.+?)">', html).group(1)
            method_free = re.search('<input type="(submit|hidden)" name="method_free" (style=".*?" )*value="(.*?)">', html).group(3)
            method_premium = re.search('<input type="(hidden|submit)" name="method_premium" (style=".*?" )*value="(.*?)">', html).group(3)
            
            if method_free:
                usr_login = ''
                fname = re.search('<input type="hidden" name="fname" value="(.+?)">', html).group(1)
                data = {'op': op, 'usr_login': usr_login, 'id': postid, 'referer': url, 'fname': fname, 'method_free': method_free}
            else:
                rand = re.search('<input type="hidden" name="rand" value="(.+?)">', html).group(1)
                data = {'op': op, 'id': postid, 'referer': url, 'rand': rand, 'method_premium': method_premium}
        
            print 'Movreel - Requesting POST URL: %s DATA: %s' % (url, data)
            html = net.http_POST(url, data).content

            if method_free:
                if re.search('<p class="err">.+?</p>', html):
                    common.addon.log('***** Download limit reached')
                    errortxt = re.search('<p class="err">(.+?)</p>', html).group(1)
                    raise Exception(errortxt)
    
                dialog.update(66)
            
                op = re.search('<input type="hidden" name="op" value="(.+?)">', html).group(1)
                postid = re.search('<input type="hidden" name="id" value="(.+?)">', html).group(1)
                rand = re.search('<input type="hidden" name="rand" value="(.+?)">', html).group(1)
                method_free = re.search('<input type="hidden" name="method_free" value="(.+?)">', html).group(1)
            
                data = {'op': op, 'id': postid, 'rand': rand, 'referer': url, 'method_free': method_free, 'down_direct': 1}
    
                common.addon.log('Movreel - Requesting POST URL: %s DATA: %s' % (url, data))
                html = net.http_POST(url, data).content

            dialog.update(100)
            dialog.close()
            link = re.search('<a id="lnk_download" href="(.+?)">Download Original Video</a>', html, re.DOTALL).group(1)
            return link

        except Exception, e:
            common.addon.log_error('**** Movreel Error occured: %s' % e)
            return False
Beispiel #18
0
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)

            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)
class RealDebridResolver(Plugin, UrlResolver, SiteAuth, PluginSettings):
    implements = [UrlResolver, SiteAuth, PluginSettings]
    name = "realdebrid"
    domains = ["*"]
    profile_path = common.profile_path
    cookie_file = os.path.join(profile_path, "%s.cookies" % name)
    media_url = None

    def __init__(self):
        p = self.get_setting("priority") or 1
        self.priority = int(p)
        self.net = Net()
        self.hosters = None
        self.hosts = None
        try:
            os.makedirs(os.path.dirname(self.cookie_file))
        except OSError:
            pass

    # UrlResolver methods
    def get_media_url(self, host, media_id):
        dialog = xbmcgui.Dialog()
        url = "https://real-debrid.com/ajax/unrestrict.php?link=%s" % media_id.replace(
            "|User-Agent=Mozilla%2F5.0%20(Windows%20NT%206.1%3B%20rv%3A11.0)%20Gecko%2F20100101%20Firefox%2F11.0", ""
        )
        source = self.net.http_GET(url).content
        jsonresult = json.loads(source)
        if "generated_links" in jsonresult:
            generated_links = jsonresult["generated_links"]
            if len(generated_links) == 1:
                return generated_links[0][2].encode("utf-8")
            line = []
            for link in generated_links:
                extension = link[0].split(".")[-1]
                line.append(extension.encode("utf-8"))
            result = dialog.select("Choose the link", line)
            if result != -1:
                link = generated_links[result][2]
                return link.encode("utf-8")
            else:
                raise UrlResolver.ResolverError("No generated_link")
        elif "main_link" in jsonresult:
            return jsonresult["main_link"].encode("utf-8")
        else:
            if "message" in jsonresult:
                raise UrlResolver.ResolverError(jsonresult["message"].encode("utf-8"))
            else:
                raise UrlResolver.ResolverError("No generated_link and no main_link")

    def get_url(self, host, media_id):
        return media_id

    def get_host_and_id(self, url):
        return "www.real-debrid.com", url

    def get_all_hosters(self):
        if self.hosters is None:
            try:
                url = "http://www.real-debrid.com/api/regex.php?type=all"
                response = self.net.http_GET(url).content.lstrip("/").rstrip("/g")
                delim = "/g,/|/g\|-\|/"
                self.hosters = [re.compile(host) for host in re.split(delim, response)]
            except:
                self.hosters = []
        common.addon.log_debug("RealDebrid hosters : %s" % self.hosters)
        return self.hosters

    def get_hosts(self):
        if self.hosts is None:
            try:
                url = "https://real-debrid.com/api/hosters.php"
                response = self.net.http_GET(url).content
                response = response[1:-1]
                self.hosts = response.split('","')
            except:
                self.hosts = []
        common.addon.log_debug("RealDebrid hosts : %s" % self.hosts)

    def valid_url(self, url, host):
        if self.get_setting("enabled") == "false":
            return False
        if self.get_setting("login") == "false":
            return False
        common.addon.log_debug("in valid_url %s : %s" % (url, host))
        if url:
            self.get_all_hosters()
            for host in self.hosters:
                # common.addon.log_debug('RealDebrid checking host : %s' %str(host))
                if re.search(host, url):
                    common.addon.log_debug("RealDebrid Match found")
                    return True
        elif host:
            self.get_hosts()
            if host in self.hosts or any(item in host for item in self.hosts):
                return True
        return False

    def checkLogin(self):
        url = "https://real-debrid.com/api/account.php"
        if not os.path.exists(self.cookie_file):
            return True
        self.net.set_cookies(self.cookie_file)
        source = self.net.http_GET(url).content
        common.addon.log_debug(source)
        if re.search("expiration", source):
            common.addon.log_debug("checkLogin returning False")
            return False
        else:
            common.addon.log_debug("checkLogin returning True")
            return True

    # SiteAuth methods
    def login(self):
        if self.checkLogin():
            try:
                common.addon.log_debug("Need to login since session is invalid")
                import hashlib

                login_data = urllib.urlencode(
                    {
                        "user": self.get_setting("username"),
                        "pass": hashlib.md5(self.get_setting("password")).hexdigest(),
                    }
                )
                url = "https://real-debrid.com/ajax/login.php?" + login_data
                source = self.net.http_GET(url).content
                if re.search("OK", source):
                    self.net.save_cookies(self.cookie_file)
                    self.net.set_cookies(self.cookie_file)
                    return True
            except:
                common.addon.log_debug("error with http_GET")
                dialog = xbmcgui.Dialog()
                dialog.ok(" Real-Debrid ", " Unexpected error, Please try again.", "", "")
            else:
                return False
        else:
            return True

    # PluginSettings methods
    def get_settings_xml(self):
        xml = PluginSettings.get_settings_xml(self)
        xml += '<setting id="RealDebridResolver_login" '
        xml += 'type="bool" label="login" default="false"/>\n'
        xml += '<setting id="RealDebridResolver_username" enable="eq(-1,true)" '
        xml += 'type="text" label="username" default=""/>\n'
        xml += '<setting id="RealDebridResolver_password" enable="eq(-2,true)" '
        xml += 'type="text" label="password" option="hidden" default=""/>\n'
        return xml

    # to indicate if this is a universal resolver
    def isUniversal(self):
        return True
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
Beispiel #21
0
class MovreelResolver(Plugin, UrlResolver, SiteAuth, PluginSettings):
    implements = [UrlResolver, SiteAuth, PluginSettings]
    name = "movreel"
    profile_path = common.profile_path
    cookie_file = os.path.join(profile_path, '%s.cookies' % name)

    def __init__(self):
        p = self.get_setting('priority') or 100
        self.priority = int(p)
        self.net = Net()
        try:
            os.makedirs(os.path.dirname(self.cookie_file))
        except OSError:
            pass

    def login(self):

        if self.get_setting('login') == 'true':
            loginurl = 'http://movreel.com/login.html'
            data = {
                'op': 'login',
                'login': self.get_setting('username'),
                'password': self.get_setting('password')
            }
            html = net.http_POST(loginurl, data).content
            if re.search('op=logout', html):
                common.addon.log('LOGIN SUCCESSFUL')
                self.net.save_cookies(self.cookie_file)
                return True
            else:
                common.addon.log('LOGIN FAILED')
                return False
        else:
            common.addon.log('No account info entered')
            return False

    def get_media_url(self, host, media_id):

        try:

            self.net.set_cookies(self.cookie_file)

            url = self.get_url(host, media_id)
            html = self.net.http_GET(url).content
            dialog = xbmcgui.DialogProgress()
            dialog.create('Resolving', 'Resolving Movreel Link...')
            dialog.update(0)

            common.addon.log('Movreel - Requesting GET URL: %s' % url)
            html = net.http_GET(url).content

            dialog.update(33)

            if re.search('This server is in maintenance mode', html):
                common.addon.log(
                    '***** Movreel - Site reported maintenance mode')
                raise Exception('File is currently unavailable on the host')

            op = re.search('<input type="hidden" name="op" value="(.+?)">',
                           html).group(1)
            postid = re.search('<input type="hidden" name="id" value="(.+?)">',
                               html).group(1)
            method_free = re.search(
                '<input type="(submit|hidden)" name="method_free" (style=".*?" )*value="(.*?)">',
                html).group(3)
            method_premium = re.search(
                '<input type="(hidden|submit)" name="method_premium" (style=".*?" )*value="(.*?)">',
                html).group(3)

            if method_free:
                usr_login = ''
                fname = re.search(
                    '<input type="hidden" name="fname" value="(.+?)">',
                    html).group(1)
                data = {
                    'op': op,
                    'usr_login': usr_login,
                    'id': postid,
                    'referer': url,
                    'fname': fname,
                    'method_free': method_free
                }
            else:
                rand = re.search(
                    '<input type="hidden" name="rand" value="(.+?)">',
                    html).group(1)
                data = {
                    'op': op,
                    'id': postid,
                    'referer': url,
                    'rand': rand,
                    'method_premium': method_premium
                }

            print 'Movreel - Requesting POST URL: %s DATA: %s' % (url, data)
            html = net.http_POST(url, data).content

            if method_free:
                if re.search('<p class="err">.+?</p>', html):
                    common.addon.log('***** Download limit reached')
                    errortxt = re.search('<p class="err">(.+?)</p>',
                                         html).group(1)
                    raise Exception(errortxt)

                dialog.update(66)

                op = re.search('<input type="hidden" name="op" value="(.+?)">',
                               html).group(1)
                postid = re.search(
                    '<input type="hidden" name="id" value="(.+?)">',
                    html).group(1)
                rand = re.search(
                    '<input type="hidden" name="rand" value="(.+?)">',
                    html).group(1)
                method_free = re.search(
                    '<input type="hidden" name="method_free" value="(.+?)">',
                    html).group(1)

                data = {
                    'op': op,
                    'id': postid,
                    'rand': rand,
                    'referer': url,
                    'method_free': method_free,
                    'down_direct': 1
                }

                common.addon.log('Movreel - Requesting POST URL: %s DATA: %s' %
                                 (url, data))
                html = net.http_POST(url, data).content

            dialog.update(100)
            dialog.close()
            link = re.search(
                '<a id="lnk_download" href="(.+?)">Download Original Video</a>',
                html, re.DOTALL).group(1)
            return link

        except Exception, e:
            common.addon.log_error('**** Movreel Error occured: %s' % e)
            return False
Beispiel #22
0
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:
Beispiel #23
0
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)
        html = self.net.http_GET(web_url).content
        if re.search('>File not found!<', html):
            raise UrlResolver.ResolverError('File Not Found or removed')
        self.net.save_cookies(self.cookie_file)
        
        web_url = 'http://www.ecostream.tv/js/ecoss.js'
        js = self.net.http_GET(web_url).content
        r = re.search("\$\.post\('([^']+)'[^;]+'#auth'\).html\(''\)", js)
        if not r:
            raise UrlResolver.ResolverError('Posturl not found')

        post_url = r.group(1)
        r = re.search('data\("tpm",([^\)]+)\);', js)
        if not r:
            raise UrlResolver.ResolverError('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 UrlResolver.ResolverError('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 UrlResolver.ResolverError('Unable to resolve Ecostream link. Filelink not found.')
        sLinkToFile = 'http://www.ecostream.tv' + r.group(1)
        return urllib2.unquote(sLinkToFile)

    def get_url(self, host, media_id):
            return 'http://www.ecostream.tv/stream/%s.html' % (media_id)

    def get_host_and_id(self, url):
        r = re.search(self.pattern, url.replace('embed','stream'))
        if r:
            return r.groups()
        else:
            return False

    def valid_url(self, url, host):
        if self.get_setting('enabled') == 'false': return False
        return re.match(self.pattern, url) or self.name in host
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)
        html = self.net.http_GET(web_url).content
        if re.search(">File not found!<", html):
            raise UrlResolver.ResolverError("File Not Found or removed")
        self.net.save_cookies(self.cookie_file)

        web_url = "http://www.ecostream.tv/js/ecoss.js"
        js = self.net.http_GET(web_url).content
        r = re.search("\$\.post\('([^']+)'[^;]+'#auth'\).html\(''\)", js)
        if not r:
            raise UrlResolver.ResolverError("Posturl not found")

        post_url = r.group(1)
        r = re.search('data\("tpm",([^\)]+)\);', js)
        if not r:
            raise UrlResolver.ResolverError("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 UrlResolver.ResolverError("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 UrlResolver.ResolverError("Unable to resolve Ecostream link. Filelink not found.")
        sLinkToFile = "http://www.ecostream.tv" + r.group(1)
        return urllib2.unquote(sLinkToFile)

    def get_url(self, host, media_id):
        return "http://www.ecostream.tv/stream/%s.html" % (media_id)

    def get_host_and_id(self, url):
        r = re.search(self.pattern, url.replace("embed", "stream"))
        if r:
            return r.groups()
        else:
            return False

    def valid_url(self, url, host):
        if self.get_setting("enabled") == "false":
            return False
        return re.match(self.pattern, url) or self.name in host
Beispiel #25
0
def GetSources(url, title='', img=''): #10
	url	  = urllib.unquote_plus(url)
	title = urllib.unquote_plus(title)
	print 'Playing: %s' % url
	net = Net(http_debug=True)
	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')

	#find all sources and their info
	sources = []
#####NEW#####
	for version in re.finditer('<table[^\n]+?class="movie_version">(.*?)</table>',
								html, re.DOTALL|re.IGNORECASE):
		for s in re.finditer('quality_(?!sponsored|unknown)(.*?)></span>.*?'+
							 'url=(.*?)&(?:amp;)?domain=(.*?)&(?:amp;)?(.*?)'+
							 '"version_veiws">(.*?)</',
							 version.group(1), re.DOTALL):
			q, url, host,parts, views = s.groups()
			r = '\[<a href=".*?url=(.*?)&(?:amp;)?.*?".*?>(part [0-9]*)</a>\]'
			additional_parts = re.findall(r, parts, re.DOTALL|re.IGNORECASE)
			verified = s.group(0).find('star.gif') > -1
			label = '[%s]  ' % q.upper()
			label += host.decode('base-64')
			if additional_parts: label += ' Part 1'
			if verified: label += ' [verified]'
			label += ' (%s)' % views.strip()
			url = url.decode('base-64')
			host = host.decode('base-64')
			print 'Source found:\n quality %s\n url %s\n host %s\n views %s\n' % (q, url, host, views)
			try:
				hosted_media = urlresolver.HostedMediaFile(url=url, title=label)
				sources.append(hosted_media)
				if additional_parts:
					for part in additional_parts:
						label = '     [%s]  ' % q.upper()
						label += host
						label += ' ' + part[1]
						if verified: label += ' [verified]'
						#label += ' (%s)' % views.strip()
						url = part[0].decode('base-64')
						hosted_media = urlresolver.HostedMediaFile(url=url, title=label)
						sources.append(hosted_media)
			except:
				print 'Error while trying to determine'
#####OLD#####
	# for s in re.finditer('class="movie_version.+?quality_(?!sponsored|unknown)(.+?)>.+?url=(.+?)' + 
						 # '&domain=(.+?)&.+?"version_veiws">(.+?)</', 
						 # html, re.DOTALL):
		# q, url, host, views = s.groups()
		# verified = s.group(0).find('star.gif') > -1
		# label = '[%s]  ' % q.upper()
		# label += host.decode('base-64')
		# if verified: label += ' [verified]'
		# label += ' (%s)' % views.strip()
		# url = url.decode('base-64')
		# host = host.decode('base-64')
		# print 'Source found:\n quality %s\n url %s\n host %s\n views %s\n' % (q, url, host, views)
		# try:
			# hosted_media = urlresolver.HostedMediaFile(url=url, title=label)
			# sources.append(hosted_media)
		# except:
			# print 'Error while trying to determine'

	source = urlresolver.choose_source(sources)
	if source: stream_url = source.resolve()
	else: stream_url = ''
	profile = ADDON.get_profile()
	if not os.path.isdir(profile):
		os.makedirs(profile)
	mediafile = os.path.join(profile, 'temp.flv')

	playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
	listitem = xbmcgui.ListItem(title, iconImage=img, thumbnailImage=img)
	playlist.add(url=stream_url, listitem=listitem)
	xbmc.Player().play(playlist)
	playlist.clear()
Beispiel #26
0
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)
    
    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': common.IE_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':common.IE_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" '        
        xml += 'type="bool" label="Login" default="false"/>\n'
        xml += '<setting id="ExashareResolver_username" enable="eq(-1,true)" '
        xml += 'type="text" label="     username" default=""/>\n'
        xml += '<setting id="ExashareResolver_password" enable="eq(-2,true)" '
        xml += 'type="text" label="     password" option="hidden" default=""/>\n'
        return xml
class YouWatchResolver(Plugin, UrlResolver, SiteAuth, PluginSettings):
    implements = [UrlResolver, SiteAuth, PluginSettings]
    name = "youwatch"
    domains = ["youwatch.org"]
    profile_path = common.profile_path
    cookie_file = os.path.join(profile_path, '%s.cookies' % name)

    def __init__(self):
        p = self.get_setting('priority') or 100
        self.priority = int(p)
        self.net = Net()
        try:
            os.makedirs(os.path.dirname(self.cookie_file))
        except OSError:
            pass
            
    def get_media_url(self, host, media_id):
        base_url = 'http://'+host+'.org/embed-'+media_id+'.html'
        soup = self.net.http_GET(base_url).content
        html = soup.decode('utf-8')
        jscript = re.findall("""function\(p,a,c,k,e,d\).*return p\}(.*)\)""", html)
        if jscript:
            lsParam = eval(jscript[0].encode('utf-8'))
            flashvars = self.exec_javascript(lsParam)
            r = re.findall('file:"(.*)",provider', flashvars)
            if r:
                stream_url = r[0].encode('utf-8')
                if self.get_setting('login') == 'true':
                    cookies = {}
                    for cookie in self.net._cj:
                        cookies[cookie.name] = cookie.value
                    stream_url = stream_url + '|' + urllib.urlencode({'Cookie' :urllib.urlencode(cookies)})
                    common.addon.log_debug('stream_URL : ' + stream_url)
            else:
                raise UrlResolver.ResolverError('File Not Found or removed')
        else:
            raise UrlResolver.ResolverError('File Not Found or removed')
        return stream_url

    def get_url(self, host, media_id):
        return 'http://youwatch.org/%s' % media_id

    def get_host_and_id(self, url):
        r = re.search('http://(www.)?(.+?).org/embed-(.+?)-[0-9A-Za-z]+.html', url)
        if not r:
            r = re.search('http://(www.)?(.+?).org/([0-9A-Za-z]+)', url)
        if r:
            ls = r.groups()
            if ls[0] == 'www.' or ls[0] == None :
                ls = (ls[1],ls[2])
            return ls
        else :
            return False

    def exec_javascript(self,lsParam) :
        return re.sub('[a-zA-Z0-9]+',Base36(lsParam[3]).param36decode,str(lsParam[0]))
    
    def valid_url(self, url, host):
        if self.get_setting('enabled') == 'false': 
            return False
        return re.match('http://(www.)?youwatch.org/(embed-(.+?).html|[0-9A-Za-z]+)',url) or 'youwatch' in host    

    def login(self):
        if self.get_setting('login') == 'true':
            try:
                common.addon.log_debug('login to youwatch')
                url = 'http://youwatch.org'
                data = {'op':'login', 'login' : self.get_setting('username'), 'password' : self.get_setting('password')}
                source = self.net.http_POST(url,data).content
                if re.search('<b>Registred</b>', source):
                    self.net.save_cookies(self.cookie_file)
                    self.net.set_cookies(self.cookie_file)
                    return True
                elif re.search('Incorrect Login or Password', source) :
                    common.addon.log_error('**** Youwatch Error occured on login: Incorrect Login or Password')
                    return False
                else:
                    common.addon.log_error('**** Youwatch Error occured on login: not logged')
                    return False
            except Exception as e :
                common.addon.log_error('**** Youwatch Error occured on login: %s' % e)
        else:
            return True

    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
Beispiel #28
0
            episodename = name1
            firstaired = aired
            
        if addon.get_setting('usemetadata') == 'true':
            addon.add_directory({'mode': 'hosting_sites', 'url': main_url + url, 'section': 'tvshows', 'imdb_id': imdb_id, 'episode': num + 1, 'fanart': fa, 'episodeart': filename} ,{'title':episode+' '+episodename+' ('+firstaired+')', 'plot': overview}, img=filename, fanart=fa, total_items=len(match))
        else:
            addon.add_directory({'mode': 'hosting_sites', 'url': main_url + url, 'section': 'tvshows', 'imdb_id': imdb_id, 'episode': num + 1}, {'title':episode+' '+episodename+' ('+firstaired+')'}, img='', total_items=len(match))
    addon.end_of_directory()

elif mode == 'hosting_sites':
    try:
        # Get the episode id from the url
        match = re.compile('-(.+?).html').findall(url)[0]
        # load the main url so the cookie gets set properly. Otherwise we will not resolve properly
        html = net.http_GET(url).content
        net.save_cookies(profile_path+'cookie.txt')
        # Fetch the links
        html = net.http_GET(main_url+'/getlinks.php?q='+match+'&domain=all').content
    except urllib2.URLError, e:
        html = ''

    try:
        fa = addon.queries['fanart']
        filename = addon.queries['episodeart']
    except:
        fa = ''
        filename = ''
    
    hosts = re.finditer('<div class="site">\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(.+?)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t\t\t\t\t\t<div class="siteparts">\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<a href="..(.+?)" target="_blank".+?class="user">(.+?)</div>', html, re.DOTALL)
                         
    sources = []
class CraftsyPlugin():
    addon = None
    net = None
    logo = None
    profile_path = None
    cookie_file = None
    base_url = None
    free_url = 'http://www.craftsy.com.edgesuite.net/'
    pay_url = 'http://cd1.craftsy.com/'

    def __init__(self):
        self.addon = Addon('plugin.video.craftsy', sys.argv)
        self.net = Net()

        self.logo = os.path.join(self.addon.get_path(), 'art','logo.jpg')

        self.profile_path = self.addon.get_profile()
        self.cookie_file = os.path.join(self.profile_path, 'craftsy.cookies')

        try:
            os.makedirs(os.path.dirname(self.cookie_file))
        except OSError:
            pass

        self.net.set_cookies(self.cookie_file)
        self.base_url = 'http://www.craftsy.com'

    def __get_image(self, url):
        fname = os.path.join(self.profile_path, md5.new(url).digest())
        print fname
        if os.path.isfile(fname):
            return fname
        return url

    def __check_link(self, url):
        if (re.match('^/', url)):
            return 'http:' + url
        return url

    def __fetch_regexp_idx(self, r, idx, default = None):
        if (r == None):
            return default
        if (len(r.groups()) < idx + 1):
            return default

        return r.groups()[idx]

    def check_login(self):
        source = self.net.http_GET(self.base_url + '/my/home?NAVIGATION_PAGE_CONTEXT_ATTR=NONE').content
        r = re.search('<title>([^<]+)</title>', source)
        title = r.groups()[0]
        
        if title == 'Welcome Back to Craftsy!':
            return False
        return True

    def __get_url(self, url):
        return self.net.http_GET(url).content.encode('utf8').replace("\n", "").replace("\r", "")

    def add_classes(self):
        source = self.__get_url(self.base_url + '/my/home?NAVIGATION_PAGE_CONTEXT_ATTR=NONE')
        source = re.sub('<div class="classCard mostRecent".*?</div>.*?</div>.*?</div>.*?</div>', '', source)
        source = re.sub('<div class="continueArea".*?</div>.*?</div>', '', source)
        # parts = re.split('<div class="classBot myClassBot">', source)
        r = re.findall('<a href="(/lecture[^\"]+)"(.*?)</a>[ \s\t]*<div class="classBot myClassBot">.*?<a href="([^"]+)"', source)
        for i in r:
            url = i[2]
            if (re.match('^/', url)):
                url = self.base_url + url
            t = re.search('<h4>([^<]+)</h4>', i[1])
            title = 'N/A'
            title = self.__fetch_regexp_idx(t, 0, 'N/A')
            img = self.base_url + '/images/craftsy/noImageTitleCard.png'
            t = re.search('<img src="([^"]+)" alt="[^"]+" onerror', i[1])
            _u = self.__fetch_regexp_idx(t, 0)
            if (_u != None):
                img = self.__check_link(_u)

            # print self.__get_image(img)
            self.addon.add_directory({'mode': 'classes', 'url': url}, {'title': title}, fanart=img, img=img)

    def __try_resolve(self, pattern, video):
        r = re.search(pattern, video)
        return self.__fetch_regexp_idx(r, 0)

    def resolve_url(self, lesson_url):
        pattern = '&([0-9]+)&(pay|free)$'
        l = re.search(pattern, lesson_url)
        lesson_id = self.__fetch_regexp_idx(l, 0)
        lesson_type = self.__fetch_regexp_idx(l, 1, 'pay')
        lesson_url = re.sub(pattern, '', lesson_url)

        q = self.addon.get_setting('quality')
        t = self.addon.get_setting('type')

        source = self.__get_url(lesson_url)

        uid = re.search('/([0-9]+)\\.html(\\?t=[0-9]*){0,1}$', lesson_url)
        url_id = self.__fetch_regexp_idx(uid, 0)
        if (url_id == None):
            return None

        r = re.search('arbitraryId = ([0-9]+),', source)
        arbitraryId = self.__fetch_regexp_idx(r, 0)
        if (arbitraryId != None):
            url_id = arbitraryId

        suffix = lesson_id + '/' + url_id + '/' + url_id + '-' + q + '.' + t
        if lesson_type == 'free':
            print "THE URL TO PLAY IS " + self.free_url + suffix
            return self.free_url + suffix
        else:
            return self.pay_url + suffix

        # r = re.search('(<video.*?</video>)', source)

        # if (len(r.groups()) == 0):
        #     return None
        # else:
        #     video = r.groups()[0]
        #     video_url = self.__try_resolve('<source src="([^"]+-' + q + '\\.' + t + ')"', video)
        #     if (video_url == None):
        #         video_url = self.__try_resolve('<source src="([^"]+-' + q + '\\.[^\\.]+)"', video)
        #         if (video_url == None):
        #             video_url = self.__try_resolve('<source src="([^"]+)"', video)

        #     return video_url


    def add_lessons(self, class_url):
        source = self.__get_url(class_url) # self.net.http_GET(class_url).content
        l = re.search('\,([0-9]+)$', class_url)
        lesson_id = self.__fetch_regexp_idx(l, 0)
        if (lesson_id == None):
            self.addon.show_error_dialog(['Could not fetch the lesson ID']);
            return None
        r = re.findall('(<tr class="classLesson.*?</tr>)', source)
        first = True
        lesson_type = 'pay'
        for i in r:
            text = i 
            el = re.search('<td class="lessonName">.*?<a href="([^"]+)">(.*?)</a>', text)
            href = self.__fetch_regexp_idx(el, 0)
            if href != None:
                href = self.__check_link(href)
                title = self.__fetch_regexp_idx(el, 1, 'N/A')
                if (first):
                    if (title.lower() == 'welcome to your free mini-class!'):
                        lesson_type = 'free'
                im = re.search('<td class="lessonImage">.*?<img src="([^"]+)"', text)
                img = self.__check_link(self.__fetch_regexp_idx(im, 0, os.path.join(self.addon.get_path(), 'art','no-img.jpg')))

                self.addon.add_video_item({'url': href + '&' + lesson_id + '&' + lesson_type}, {'title': title}, img = img, fanart = img)
            first = False

    def do_login(self):
        try:
            if self.check_login():
                return True
            data=(('email', self.addon.get_setting('username')), ('password', self.addon.get_setting('password')), ('forwardUrl', '/'))
            source = self.net.http_POST(self.base_url + '/doLogin.json?isCraftsyAjax=true', data).content
            response = JSONDecoder().decode(source)
            self.net.save_cookies(self.cookie_file)
            self.net.set_cookies(self.cookie_file)
            return response.get("success")
        except Exception as e:
            print e
            return False
Beispiel #30
0
def GetSources(url, title='', img='', update='', year='', imdbnum='', video_type='', season='', episode=''): #10
	url	  = urllib.unquote(url)
	# xbmcplugin.endOfDirectory(int(sys.argv[1]))
	print 'Playing: %s' % url
	videotype = 'movie'
	match = re.search('tv-\d{1,10}-(.*)/season-(\d{1,4})-episode-(\d{1,4})', url, re.IGNORECASE | re.DOTALL)
	if match:
		videotype = 'episode'
		season = int(match.group(2))
		episode = int(match.group(3))	
	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')

	if update:
		imdbregex = 'mlink_imdb">.+?href="http://www.imdb.com/title/(tt[0-9]{7})"'
		r = re.search(imdbregex, html)
		if r:
			imdbnum = r.group(1)
			metaget.update_meta('movie',title,imdb_id='',
								new_imdb_id=imdbnum,year=year)
	titleregex = '<meta property="og:title" content="(.*?)">'
	r = re.search(titleregex,html)
	title = r.group(1)
	sources = []
	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">(.*?)</',
							 version.group(1), re.DOTALL):
			q, url, host,parts, views = s.groups()
			r = '\[<a href=".*?url=(.*?)&(?:amp;)?.*?".*?>(part [0-9]*)</a>\]'
			additional_parts = re.findall(r, parts, re.DOTALL|re.IGNORECASE)
			verified = s.group(0).find('star.gif') > -1
			label = '[%s]  ' % q.upper()
			label += host.decode('base-64')
			if additional_parts: label += ' Part 1'
			if verified: label += ' [verified]'
			label += ' (%s)' % views.strip()
			url = url.decode('base-64')
			host = host.decode('base-64')
			print 'Source found:\n quality %s\n url %s\n host %s\n views %s\n' % (q, url, host, views)
			try:
				hosted_media = urlresolver.HostedMediaFile(url=url, title=label)
				sources.append(hosted_media)
				if additional_parts:
					for part in additional_parts:
						label = '     [%s]  ' % q.upper()
						label += host
						label += ' ' + part[1]
						if verified: label += ' [verified]'
						url = part[0].decode('base-64')
						hosted_media = urlresolver.HostedMediaFile(url=url, title=label)
						sources.append(hosted_media)
			except:
				print 'Error while trying to resolve %s' % url
	source = urlresolver.choose_source(sources)
	if source:
		stream_url = source.resolve()
		print 'Attempting to play url: %s' % stream_url
		playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
		playlist.clear()
		listitem = xbmcgui.ListItem(title, iconImage=img, thumbnailImage=img)
		if videotype == 'episode':
			try:
				meta = metaget.get_episode_meta(title,imdbnum,season,episode)
				tag = '%sx%s ' %(season,episode)
				meta['title'] = tag + meta['title']
				listitem.setInfo(type="Video", infoLabels=meta)
				listitem.setInfo('video', {'TVShowTitle': title, 'Season': season, 'Episode': episode } )
			except: print 'Failed to get metadata for Title: %s IMDB: %s Season: %s Episode %s' %(title,imdbnum,season,episode)
		addon.resolve_url(stream_url)
		playlist.add(url=stream_url, listitem=listitem)
		player = playback.Player(imdbnum=imdbnum, videotype=videotype, title=title, season=season, episode=episode, year=year)
		# player.play(stream_url, listitem)
		player.play(playlist)
		while player._playbackLock.isSet():
			addon.log('Main function. Playback lock set. Sleeping for 250.')
			xbmc.sleep(250)
class SockshareResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "sockshare"
    domains = ["sockshare.com"]
    profile_path = common.profile_path
    cookie_file = os.path.join(profile_path, 'sockshare.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):
        if self.get_setting('login') == 'true':
            if self.login_stale():
                self.login()
        self.net.set_cookies(self.cookie_file)
        web_url = self.get_url(host, media_id)

        html = self.net.http_GET(web_url).content

        if ">This file doesn't exist, or has been removed.<" in html:
            raise UrlResolver.ResolverError(
                host + ": This file doesn't exist, or has been removed.")
        elif "This file might have been moved, replaced or deleted.<" in html:
            raise UrlResolver.ResolverError(
                host +
                ": 404: This file might have been moved, replaced or deleted.")

        #Shortcut for logged in users
        pattern = '<a href="(/.+?)" class="download_file_link" style="margin:0px 0px;">Download File</a>'
        link = re.search(pattern, html)
        if link:
            common.addon.log_debug('Direct link found: %s' % link.group(1))
            return 'http://www.sockshare.com%s' % link.group(1)

        r = re.search('value="([0-9a-f]+?)" name="hash"', html)
        if r:
            session_hash = r.group(1)
        else:
            raise UrlResolver.ResolverError(
                'sockshare: session hash not found')

        #post session_hash
        html = self.net.http_POST(web_url,
                                  form_data={
                                      'hash': session_hash,
                                      'confirm': 'Continue as Free User'
                                  }).content

        #find playlist code
        r = re.search('\?stream=(.+?)\'', html)
        if r:
            playlist_code = r.group(1)
        else:
            r = re.search('key=(.+?)&', html)
            playlist_code = r.group(1)

        #find download link
        q = self.get_setting('quality')

        #Try to grab highest quality link available
        if q == '1':
            #download & return link.
            if 'sockshare' in host:
                Avi = "http://sockshare.com/get_file.php?stream=%s&original=1" % playlist_code
                html = self.net.http_GET(Avi).content
                final = re.compile('url="(.+?)"').findall(html)[0].replace(
                    '&amp;', '&')
                return "%s|User-Agent=%s" % (
                    final,
                    'Mozilla%2F5.0%20(Windows%20NT%206.1%3B%20rv%3A11.0)%20Gecko%2F20100101%20Firefox%2F11.0'
                )

        #Else grab standard flv link
        else:
            xml_url = re.sub('/(file|embed)/.+', '/get_file.php?stream=',
                             web_url)
            xml_url += playlist_code
            html = self.net.http_GET(xml_url).content

            r = re.search('url="(.+?)"', html)
            if r:
                flv_url = r.group(1)
            else:
                raise UrlResolver.ResolverError(
                    'sockshare: stream url not found')

            return "%s|User-Agent=%s" % (flv_url.replace(
                '&amp;', '&'
            ), 'Mozilla%2F5.0%20(Windows%20NT%206.1%3B%20rv%3A11.0)%20Gecko%2F20100101%20Firefox%2F11.0'
                                         )

    def get_url(self, host, media_id):
        if 'sockshare' in host:
            host = 'www.sockshare.com'
        return 'http://%s/file/%s' % (host, media_id)

    def get_host_and_id(self, url):
        r = re.search('//(.+?)/(?:file|embed)/([0-9A-Z]+)', url)
        if r:
            return r.groups()
        else:
            return False

    def valid_url(self, url, host):
        return (re.match(
            'http://(www.)?(sockshare).com/' + '(file|embed)/[0-9A-Z]+', url)
                or 'sockshare' in host)

    def login_stale(self):
        url = 'http://www.sockshare.com/cp.php'
        if not os.path.exists(self.cookie_file):
            return True
        self.net.set_cookies(self.cookie_file)
        source = self.net.http_GET(url).content
        if re.search(
                '(?:<span class=pro_user>\( Pro \)</span>|<span class="free_user">\( Free \)</span>)',
                source):
            common.addon.log('Putlocker account appears to be logged in.')
            return False
        else:
            return True

    #SiteAuth methods
    def login(self):
        if self.login_stale():
            url = 'http://www.sockshare.com/authenticate.php?login'
            source = self.net.http_GET(url).content
            self.net.save_cookies(self.cookie_file)
            self.net.set_cookies(self.cookie_file)
            captcha_img = re.search(
                '<td>CAPTCHA</td>.+?<td><img src="(.+?)"\s*/><br>', source,
                re.DOTALL).group(1)
            captcha_img = 'http://www.sockshare.com%s' % re.sub(
                '&amp;', '&', captcha_img)
            local_captcha = os.path.join(common.profile_path, "captcha.img")
            localFile = open(local_captcha, "wb")
            localFile.write(self.net.http_GET(captcha_img).content)
            localFile.close()
            solver = InputWindow(captcha=local_captcha)
            solution = solver.get()
            if solution:
                common.addon.log('Solution provided: %s' % solution)
                data = {
                    'user': self.get_setting('username'),
                    'pass': self.get_setting('password'),
                    'captcha_code': solution,
                    'remember': 1,
                    'login_submit': 'Login'
                }
                response = self.net.http_POST(url, form_data=data)
                self.net.save_cookies(self.cookie_file)
                self.net.set_cookies(self.cookie_file)
            else:
                common.addon.log('Dialog was canceled')
                return False

            if re.search('OK', source):
                self.net.save_cookies(self.cookie_file)
                self.net.set_cookies(self.cookie_file)
                xbmc.executebuiltin(
                    "Notification(' sockshare Pro ', ' Login successful')")
                return True
            else:
                return False
        else:
            return True

    #PluginSettings methods
    def get_settings_xml(self):
        xml = PluginSettings.get_settings_xml(self)
        xml += '<setting label="Highest Quality" id="%s_quality" ' % self.__class__.__name__
        xml += 'type="enum" values="FLV|Maximum" default="0" />\n'
        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'
        xml += '<setting id="%s_notify" ' % self.__class__.__name__
        xml += 'type="bool" label="Notify on login" default="false"/>\n'
        return xml
Beispiel #32
0
    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:
Beispiel #33
0
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,
                    'video_type': video_type,
                    'strm': True,
                    '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
Beispiel #34
0
def GetSources(url, title='', img='', update='', year='', imdbnum='', video_type='', season='', episode=''): #10
	url	  = urllib.unquote(url)
	print 'Title befor unquote %s' % title
	#title = urllib.unquote(title)
	#title = title.decode('utf-8')
	print 'Title is %s' % title
	print 'Playing: %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')

	if update:
		imdbregex = 'mlink_imdb">.+?href="http://www.imdb.com/title/(tt[0-9]{7})"'
		r = re.search(imdbregex, html)
		if r:
			imdbnum = r.group(1)
			metaget.update_meta('movie',title,imdb_id='',
								new_imdb_id=imdbnum,year=year)
	titleregex = '<meta property="og:title" content="(.*?)">'
	r = re.search(titleregex,html)
	title = r.group(1)
	sources = []
	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">(.*?)</',
							 version.group(1), re.DOTALL):
			q, url, host,parts, views = s.groups()
			r = '\[<a href=".*?url=(.*?)&(?:amp;)?.*?".*?>(part [0-9]*)</a>\]'
			additional_parts = re.findall(r, parts, re.DOTALL|re.IGNORECASE)
			verified = s.group(0).find('star.gif') > -1
			label = '[%s]  ' % q.upper()
			label += host.decode('base-64')
			if additional_parts: label += ' Part 1'
			if verified: label += ' [verified]'
			label += ' (%s)' % views.strip()
			url = url.decode('base-64')
			host = host.decode('base-64')
			print 'Source found:\n quality %s\n url %s\n host %s\n views %s\n' % (q, url, host, views)
			try:
				hosted_media = urlresolver.HostedMediaFile(url=url, title=label)
				sources.append(hosted_media)
				if additional_parts:
					for part in additional_parts:
						label = '     [%s]  ' % q.upper()
						label += host
						label += ' ' + part[1]
						if verified: label += ' [verified]'
						#label += ' (%s)' % views.strip()
						url = part[0].decode('base-64')
						hosted_media = urlresolver.HostedMediaFile(url=url, title=label)
						sources.append(hosted_media)
			except:
				print 'Error while trying to resolve %s' % url

	source = urlresolver.choose_source(sources)
	if source: 
		stream_url = source.resolve()
		playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
		playlist.clear()
		listitem = xbmcgui.ListItem(title, iconImage=img, thumbnailImage=img)
		playlist.add(url=stream_url, listitem=listitem)
		xbmc.Player().play(playlist)
		if ADDON.get_setting('auto-watch') == 'true':
			Autowatch()
Beispiel #35
0
OO0o = Net()
o0O = 'http://www.filmon.com/ajax/login'
IiiIII111iI = oOooOoO0Oo0O.getSetting('user')
IiII = oOooOoO0Oo0O.getSetting('pass')
iI1Ii11111iIi = {'password': IiII, 'email': IiiIII111iI, 'remember': 1}
i1i1II = {
    'Host': 'www.filmon.com',
    'Origin': 'http://www.filmon.com',
    'Referer': 'http://www.filmon.com/user/login',
    'X-Requested-With': 'XMLHttpRequest'
}
O0oo0OO0 = OO0o.http_POST(o0O, iI1Ii11111iIi, i1i1II)
I1i1iiI1 = os.path.join(Oo, "FilmOn.lwp")
if os.path.exists(Oo) == False:
    os.makedirs(Oo)
OO0o.save_cookies(I1i1iiI1)
if 24 - 24: oOOOO0o0o
if oOooOoO0Oo0O.getSetting('visitor_ga') == '':
    from random import randint
    oOooOoO0Oo0O.setSetting('visitor_ga', str(randint(0, 0x7fffffff)))
    if 40 - 40: II / oo00 * i1I1Ii1iI1ii * o0oOoO00o.i1
oOOoo00O0O = "4.6.1"
i1111 = "FilmOn"
i11 = "UA-3174686-20"
if 41 - 41: O00o0o0000o0o.oOo0oooo00o * I1i1i1ii - IIIII
if 26 - 26: O00OoOoo00.iiiI11 / oooOOOOO * oo00 / iiiI11


def oOO():
    if oOooOoO0Oo0O.getSetting('filmon') == 'true':
        I1iiiiI1iII(
Beispiel #36
0
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)
Beispiel #37
0
def TVShowSeasonList(url, title, year, old_imdb, old_tvdb, 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()

	try:
		new_imdb = re.search('mlink_imdb">.+?href="http://www.imdb.com/title/(tt[0-9]{7})"', html).group(1)
	except: new_imdb = ''
	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)
		title = urllib.unquote(title)
		title = unicode(title, 'latin1')
		fanart = ''
		imdbnum = old_imdb
		if META_ON: 
			if not old_imdb and new_imdb:
				addon.log('Imdb ID not recieved from title search, updating with new id of %s' % new_imdb)
				try:
					addon.log('Title: %s Old IMDB: %s Old TVDB: %s New IMDB %s Year: %s'%(title,old_imdb,old_tvdb,new_imdb, year))
					metaget.update_meta('tvshow', title, old_imdb, old_tvdb,
									new_imdb, year=year)
				except: 
					addon.log('Error while trying to update metadata with:')
					addon.log('Title: %s Old IMDB: %s Old TVDB: %s New IMDB %s Year: %s'%(title,old_imdb,old_tvdb,new_imdb, year))
				imdbnum = new_imdb

			try: season_meta = metaget.get_seasons(title, imdbnum, season_nums)
			except: pass
			if FANART_ON:
				try: fanart = temp['backdrop_url']
				except: pass
		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]
					if META_ON and FANART_ON:
						try: fanart = temp['backdrop_url']
						except: pass
				except: 
					temp['cover_url']    = ''
					temp['backdrop_url'] = ''
				temp['title'] = season_name

				# season_name = unicode_urlencode(season_name).lower()
				addon.log('Season name: %s' %season_name)
				cursor.execute('INSERT or REPLACE into seasons (season,contents) VALUES(?,?)',
								(season_name, eplist))

				addon.add_directory({'mode':'TVShowEpisodeList', 'season':season_name, 'imdbnum':imdbnum, 'title':title},
									temp, img=temp['cover_url'], fanart=fanart,
									total_items=len(seasonList), is_folder=True)

				cnxn.commit()
				num += 1
		xbmcplugin.endOfDirectory(int(sys.argv[1]))
		setView('seasons', 'seasons-view')
		cnxn.close()
Beispiel #38
0
class RealDebridResolver(Plugin, UrlResolver, SiteAuth, PluginSettings):
    implements = [UrlResolver, SiteAuth, PluginSettings]
    name = "realdebrid"
    domains = ["*"]
    profile_path = common.profile_path
    cookie_file = os.path.join(profile_path, '%s.cookies' % name)
    media_url = None

    def __init__(self):
        p = self.get_setting('priority') or 1
        self.priority = int(p)
        self.net = Net()
        self.hosters = None
        self.hosts = None
        try:
            os.makedirs(os.path.dirname(self.cookie_file))
        except OSError:
            pass

    # UrlResolver methods
    def get_media_url(self, host, media_id):
        dialog = xbmcgui.Dialog()
        url = 'https://real-debrid.com/ajax/unrestrict.php?link=%s' % media_id.replace(
            '|User-Agent=Mozilla%2F5.0%20(Windows%20NT%206.1%3B%20rv%3A11.0)%20Gecko%2F20100101%20Firefox%2F11.0',
            '')
        source = self.net.http_GET(url).content
        jsonresult = json.loads(source)
        if 'generated_links' in jsonresult:
            generated_links = jsonresult['generated_links']
            if len(generated_links) == 1:
                return generated_links[0][2].encode('utf-8')
            line = []
            for link in generated_links:
                extension = link[0].split('.')[-1]
                line.append(extension.encode('utf-8'))
            result = dialog.select('Choose the link', line)
            if result != -1:
                link = generated_links[result][2]
                return link.encode('utf-8')
            else:
                raise UrlResolver.ResolverError('No generated_link')
        elif 'main_link' in jsonresult:
            return jsonresult['main_link'].encode('utf-8')
        else:
            if 'message' in jsonresult:
                raise UrlResolver.ResolverError(
                    jsonresult['message'].encode('utf-8'))
            else:
                raise UrlResolver.ResolverError(
                    'No generated_link and no main_link')

    def get_url(self, host, media_id):
        return media_id

    def get_host_and_id(self, url):
        return 'www.real-debrid.com', url

    def get_all_hosters(self):
        if self.hosters is None:
            try:
                url = 'http://www.real-debrid.com/api/regex.php?type=all'
                response = self.net.http_GET(url).content.lstrip('/').rstrip(
                    '/g')
                delim = '/g,/|/g\|-\|/'
                self.hosters = [
                    re.compile(host) for host in re.split(delim, response)
                ]
            except:
                self.hosters = []
        common.addon.log_debug('RealDebrid hosters : %s' % self.hosters)
        return self.hosters

    def get_hosts(self):
        if self.hosts is None:
            try:
                url = 'https://real-debrid.com/api/hosters.php'
                response = self.net.http_GET(url).content
                response = response[1:-1]
                self.hosts = response.split('","')
            except:
                self.hosts = []
        common.addon.log_debug('RealDebrid hosts : %s' % self.hosts)

    def valid_url(self, url, host):
        if self.get_setting('enabled') == 'false': return False
        if self.get_setting('login') == 'false': return False
        common.addon.log_debug('in valid_url %s : %s' % (url, host))
        if url:
            self.get_all_hosters()
            for host in self.hosters:
                # common.addon.log_debug('RealDebrid checking host : %s' %str(host))
                if re.search(host, url):
                    common.addon.log_debug('RealDebrid Match found')
                    return True
        elif host:
            self.get_hosts()
            if host in self.hosts or any(item in host for item in self.hosts):
                return True
        return False

    def checkLogin(self):
        url = 'https://real-debrid.com/api/account.php'
        if not os.path.exists(self.cookie_file):
            return True
        self.net.set_cookies(self.cookie_file)
        source = self.net.http_GET(url).content
        common.addon.log_debug(source)
        if re.search('expiration', source):
            common.addon.log_debug('checkLogin returning False')
            return False
        else:
            common.addon.log_debug('checkLogin returning True')
            return True

    # SiteAuth methods
    def login(self):
        if self.checkLogin():
            try:
                common.addon.log_debug(
                    'Need to login since session is invalid')
                import hashlib
                login_data = urllib.urlencode({
                    'user':
                    self.get_setting('username'),
                    'pass':
                    hashlib.md5(self.get_setting('password')).hexdigest()
                })
                url = 'https://real-debrid.com/ajax/login.php?' + login_data
                source = self.net.http_GET(url).content
                if re.search('OK', source):
                    self.net.save_cookies(self.cookie_file)
                    self.net.set_cookies(self.cookie_file)
                    return True
            except:
                common.addon.log_debug('error with http_GET')
                dialog = xbmcgui.Dialog()
                dialog.ok(' Real-Debrid ',
                          ' Unexpected error, Please try again.', '', '')
            else:
                return False
        else:
            return True

    # 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 True
Beispiel #39
0
class MovreelResolver(Plugin, UrlResolver, SiteAuth, PluginSettings):
    implements = [UrlResolver, SiteAuth, PluginSettings]
    name = "movreel"
    domains = ["movreel.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
                
    def get_media_url(self, host, media_id):
        self.net.set_cookies(self.cookie_file)
        web_url = self.get_url(host, media_id)
        html = self.net.http_GET(web_url).content
        if re.search('This server is in maintenance mode', html):
            raise UrlResolver.ResolverError('File is currently unavailable on the host')
        
        data = {}
        r = re.findall(r'type="hidden" name="(.+?)" value="(.+?)"', html)
        if r:
            for name, value in r:
                data[name] = value
            data['referer'] = web_url
        else:
            raise UrlResolver.ResolverError('Cannot find data values')
        data['btn_download'] = 'Continue to Video'
        
        r = re.search('<span id="countdown_str">Wait <span id=".+?">(.+?)</span> seconds</span>', html)
        if r:
            wait_time = r.group(1)
        else:
            wait_time = 2  # default to 2 seconds
        xbmc.sleep(int(wait_time) * 1000)

        html = self.net.http_POST(web_url, data).content
        
        r = re.search('href="([^"]+)">Download Link', html)
        if r:
            return r.group(1)
        else:
            raise UrlResolver.ResolverError('Unable to locate Download Link')

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

    def get_host_and_id(self, url):
        r = re.search('//(.+?)/([0-9a-zA-Z]+)', url)
        if r:
            return r.groups()
        else:
            return False
        return('host', 'media_id')

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

    def login(self):
        if self.get_setting('login') == 'true':
            loginurl = 'http://movreel.com'
            login = self.get_setting('username')
            password = self.get_setting('password')
            data = {'op': 'login', 'login': login, 'password': password}
            html = self.net.http_POST(loginurl, data).content
            if re.search('op=logout', html):
                self.net.save_cookies(self.cookie_file)
                common.addon.log('LOGIN SUCCESSFUL')
                return True
            else:
                common.addon.log('LOGIN FAILED')
                return False
        else:
            common.addon.log('No account info entered')
            return False

    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
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" '        
        xml += 'type="bool" label="Login" default="false"/>\n'
        xml += '<setting id="ExashareResolver_username" enable="eq(-1,true)" '
        xml += 'type="text" label="     username" default=""/>\n'
        xml += '<setting id="ExashareResolver_password" enable="eq(-2,true)" '
        xml += 'type="text" label="     password" option="hidden" default=""/>\n'
        return xml
class SockshareResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "sockshare"
    domains = ["sockshare.com"]
    profile_path = common.profile_path
    cookie_file = os.path.join(profile_path, 'sockshare.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):
        if self.get_setting('login') == 'true':
            if self.login_stale():
                self.login()
        self.net.set_cookies(self.cookie_file)
        web_url = self.get_url(host, media_id)

        html = self.net.http_GET(web_url).content

        if ">This file doesn't exist, or has been removed.<" in html: raise UrlResolver.ResolverError (host+": This file doesn't exist, or has been removed.")
        elif "This file might have been moved, replaced or deleted.<" in html: raise UrlResolver.ResolverError (host+": 404: This file might have been moved, replaced or deleted.")
        
        #Shortcut for logged in users
        pattern = '<a href="(/.+?)" class="download_file_link" style="margin:0px 0px;">Download File</a>'
        link = re.search(pattern, html)
        if link:
            common.addon.log_debug('Direct link found: %s' % link.group(1))
            return 'http://www.sockshare.com%s' % link.group(1)

        r = re.search('value="([0-9a-f]+?)" name="hash"', html)
        if r:
            session_hash = r.group(1)
        else:
            raise UrlResolver.ResolverError('sockshare: session hash not found')

        #post session_hash
        html = self.net.http_POST(web_url, form_data={'hash': session_hash, 
                                                       'confirm': 'Continue as Free User'}).content
    
        #find playlist code  
        r = re.search('\?stream=(.+?)\'', html)
        if r:
            playlist_code = r.group(1)
        else:
            r = re.search('key=(.+?)&',html)
            playlist_code = r.group(1)
    
        #find download link
        q = self.get_setting('quality')
    
        #Try to grab highest quality link available
        if q == '1':
            #download & return link.
            if 'sockshare' in host:
                Avi = "http://sockshare.com/get_file.php?stream=%s&original=1"%playlist_code
                html = self.net.http_GET(Avi).content
                final=re.compile('url="(.+?)"').findall(html)[0].replace('&amp;','&')
                return "%s|User-Agent=%s"%(final,'Mozilla%2F5.0%20(Windows%20NT%206.1%3B%20rv%3A11.0)%20Gecko%2F20100101%20Firefox%2F11.0')

        #Else grab standard flv link
        else:
            xml_url = re.sub('/(file|embed)/.+', '/get_file.php?stream=', web_url)
            xml_url += playlist_code
            html = self.net.http_GET(xml_url).content

            r = re.search('url="(.+?)"', html)
            if r:
                flv_url = r.group(1)
            else:
                raise UrlResolver.ResolverError('sockshare: stream url not found')

            return "%s|User-Agent=%s"%(flv_url.replace('&amp;','&'),'Mozilla%2F5.0%20(Windows%20NT%206.1%3B%20rv%3A11.0)%20Gecko%2F20100101%20Firefox%2F11.0')

    def get_url(self, host, media_id):
            if 'sockshare' in host:
                host = 'www.sockshare.com'
            return 'http://%s/file/%s' % (host, media_id)
            
            
    def get_host_and_id(self, url):
            r = re.search('//(.+?)/(?:file|embed)/([0-9A-Z]+)', url)
            if r:
                return r.groups()
            else:
                return False
            
    def valid_url(self, url, host):
            return (re.match('http://(www.)?(sockshare).com/' +  '(file|embed)/[0-9A-Z]+', url) or 'sockshare' in host)

    def login_stale(self):
            url = 'http://www.sockshare.com/cp.php'
            if not os.path.exists(self.cookie_file):
                return True
            self.net.set_cookies(self.cookie_file)
            source =  self.net.http_GET(url).content
            if re.search('(?:<span class=pro_user>\( Pro \)</span>|<span class="free_user">\( Free \)</span>)', source):
                common.addon.log('Putlocker account appears to be logged in.')
                return False
            else:
                return True

    #SiteAuth methods
    def login(self):
        if self.login_stale():
            url = 'http://www.sockshare.com/authenticate.php?login'
            source = self.net.http_GET(url).content
            self.net.save_cookies(self.cookie_file)
            self.net.set_cookies(self.cookie_file)
            captcha_img = re.search('<td>CAPTCHA</td>.+?<td><img src="(.+?)"\s*/><br>', source, re.DOTALL).group(1)
            captcha_img = 'http://www.sockshare.com%s' %re.sub('&amp;','&',captcha_img)
            local_captcha = os.path.join(common.profile_path, "captcha.img" )
            localFile = open(local_captcha, "wb")
            localFile.write(self.net.http_GET(captcha_img).content)
            localFile.close()
            solver = InputWindow(captcha=local_captcha)
            solution = solver.get()
            if solution:
                common.addon.log('Solution provided: %s' %solution)
                data = {'user':self.get_setting('username'), 'pass':self.get_setting('password'), 'captcha_code':solution, 'remember':1, 'login_submit':'Login'}
                response = self.net.http_POST(url, form_data=data)
                self.net.save_cookies(self.cookie_file)
                self.net.set_cookies(self.cookie_file)
            else:
                common.addon.log('Dialog was canceled')
                return False


            if re.search('OK', source):
                self.net.save_cookies(self.cookie_file)
                self.net.set_cookies(self.cookie_file)
                xbmc.executebuiltin("Notification(' sockshare Pro ', ' Login successful')")  
                return True
            else: return False
        else: return True

    #PluginSettings methods
    def get_settings_xml(self):
        xml = PluginSettings.get_settings_xml(self)
        xml += '<setting label="Highest Quality" id="%s_quality" ' % self.__class__.__name__
        xml += 'type="enum" values="FLV|Maximum" default="0" />\n'
        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'
        xml += '<setting id="%s_notify" ' % self.__class__.__name__
        xml += 'type="bool" label="Notify on login" default="false"/>\n'
        return xml
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
class PurevidResolver(Plugin, UrlResolver, SiteAuth, PluginSettings):
    implements = [UrlResolver, SiteAuth, PluginSettings]
    name = "purevid"
    domains = ["purevid.com"]
    profile_path = common.profile_path
    pv_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.pv_cookie_file))
        except OSError:
            pass

    #UrlResolver methods
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        html = self.net.http_GET(web_url).content
        data = json.loads(html)
        if self.get_setting('quality') == 'FLV':
            url = data['clip']['bitrates'][0]['url']
        else:
            url = data['clip']['bitrates'][-1]['url']
        params = ''
        for val in data['plugins']['lighttpd']['params']:
            params += val['name'] + '=' + val['value'] + '&'
        url = url + '?' + params[:-1]
        cookies = {}
        for cookie in self.net._cj:
            cookies[cookie.name] = cookie.value
        url = url + '|' + urllib.urlencode({'Cookie': urllib.urlencode(cookies)})
        common.addon.log_debug(url)
        return url
                                                                                            
    def get_url(self, host, media_id):
        return 'http://www.purevid.com/?m=video_info_embed_flv&id=%s' % media_id
                        
    def get_host_and_id(self, url):     
        r = re.search('//(.+?)/v/([0-9A-Za-z]+)', url)
        if r:
            return r.groups()
        else:
            return False

    def valid_url(self, url, host):                 
        if self.get_setting('login') == 'false': return False
        return 'purevid' in url

    #SiteAuth methods
    def needLogin(self):
        url = 'http://www.purevid.com/?m=main'
        if not os.path.exists(self.pv_cookie_file):
            return True
        self.net.set_cookies(self.pv_cookie_file)
        source = self.net.http_GET(url).content
        common.addon.log_debug(source.encode('utf-8'))
        if re.search("""<span>Welcome <strong>.*</strong></span>""", 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.needLogin() :
            common.addon.log('login to purevid')
            url = 'http://www.purevid.com/?m=login'
            data = {'username' : self.get_setting('username'), 'password' : self.get_setting('password')}        
            source = self.net.http_POST(url,data).content        
            if re.search(self.get_setting('username'), source):            
                self.net.save_cookies(self.pv_cookie_file)
                self.net.set_cookies(self.pv_cookie_file)
                return True
            else:
                return False
        else :
            return True
                    
    #PluginSettings methods
    def get_settings_xml(self):
        xml = PluginSettings.get_settings_xml(self)
        xml += '<setting id="PurevidResolver_login" '        
        xml += 'type="bool" label="Login" default="false"/>\n'
        xml += '<setting id="PurevidResolver_username" enable="eq(-1,true)" '
        xml += 'type="text" label="     username" default=""/>\n'
        xml += '<setting id="PurevidResolver_password" enable="eq(-2,true)" '
        xml += 'type="text" label="     password" option="hidden" default=""/>\n'
        xml += '<setting label="Video quality" id="PurevidResolver_quality" '
        xml += 'type="labelenum" values="FLV|Maximum" default="Maximum" />\n'
        xml += '<setting label="This plugin calls the Purevid urlresolver - '
        xml += 'change settings there." type="lsep" />\n'
        return xml
class PurevidResolver(Plugin, UrlResolver, SiteAuth, PluginSettings):
    implements = [UrlResolver, SiteAuth, PluginSettings]
    name = "purevid"
    domains = ["purevid.com"]
    pattern = '(?://|\.)(purevid\.com)/v/([0-9A-Za-z]+)'

    profile_path = common.profile_path
    pv_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.pv_cookie_file))
        except OSError:
            pass

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        html = self.net.http_GET(web_url).content
        data = json.loads(html)
        if self.get_setting('quality') == 'FLV':
            url = data['clip']['bitrates'][0]['url']
        else:
            url = data['clip']['bitrates'][-1]['url']
        params = ''
        for val in data['plugins']['lighttpd']['params']:
            params += val['name'] + '=' + val['value'] + '&'
        url = url + '?' + params[:-1]
        cookies = {}
        for cookie in self.net._cj:
            cookies[cookie.name] = cookie.value
        url = url + '|' + urllib.urlencode({'Cookie': urllib.urlencode(cookies)})
        common.addon.log_debug(url)
        return url
                                                                                            
    def get_url(self, host, media_id):
        return 'http://www.purevid.com/?m=video_info_embed_flv&id=%s' % media_id
                        
    def get_host_and_id(self, url):
        r = re.search(self.pattern, url)
        if r:
            return r.groups()
        else:
            return False
    
    def valid_url(self, url, host):
        return re.search(self.pattern, url) or self.name in host

    def needLogin(self):
        url = 'http://www.purevid.com/?m=main'
        if not os.path.exists(self.pv_cookie_file):
            return True
        self.net.set_cookies(self.pv_cookie_file)
        source = self.net.http_GET(url).content
        common.addon.log_debug(source.encode('utf-8'))
        if re.search("""<span>Welcome <strong>.*</strong></span>""", 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.needLogin() :
            common.addon.log('login to purevid')
            url = 'http://www.purevid.com/?m=login'
            data = {'username' : self.get_setting('username'), 'password' : self.get_setting('password')}        
            source = self.net.http_POST(url,data).content        
            if re.search(self.get_setting('username'), source):            
                self.net.save_cookies(self.pv_cookie_file)
                self.net.set_cookies(self.pv_cookie_file)
                return True
            else:
                return False
        else :
            return True

    def get_settings_xml(self):
        xml = PluginSettings.get_settings_xml(self)
        xml += '<setting id="PurevidResolver_login" '        
        xml += 'type="bool" label="Login" default="false"/>\n'
        xml += '<setting id="PurevidResolver_username" enable="eq(-1,true)" '
        xml += 'type="text" label="     username" default=""/>\n'
        xml += '<setting id="PurevidResolver_password" enable="eq(-2,true)" '
        xml += 'type="text" label="     password" option="hidden" default=""/>\n'
        xml += '<setting label="Video quality" id="PurevidResolver_quality" '
        xml += 'type="labelenum" values="FLV|Maximum" default="Maximum" />\n'
        xml += '<setting label="This plugin calls the Purevid urlresolver - '
        xml += 'change settings there." type="lsep" />\n'
        return xml
class RealDebridResolver(Plugin, UrlResolver, SiteAuth, PluginSettings):
    implements = [UrlResolver, SiteAuth, PluginSettings]
    name = "realdebrid"
    domains = ["*"]
    profile_path = common.profile_path
    cookie_file = os.path.join(profile_path, '%s.cookies' % name)
    media_url = None

    def __init__(self):
        p = self.get_setting('priority') or 1
        self.priority = int(p)
        self.net = Net()
        self.hosters = None
        self.hosts = None
        try:
            os.makedirs(os.path.dirname(self.cookie_file))
        except OSError:
            pass

    # UrlResolver methods
    def get_media_url(self, host, media_id):
        dialog = xbmcgui.Dialog()
        url = 'https://real-debrid.com/ajax/unrestrict.php?link=%s' % media_id.replace('|User-Agent=Mozilla%2F5.0%20(Windows%20NT%206.1%3B%20rv%3A11.0)%20Gecko%2F20100101%20Firefox%2F11.0', '')
        source = self.net.http_GET(url).content
        jsonresult = json.loads(source)
        if 'generated_links' in jsonresult:
            generated_links = jsonresult['generated_links']
            if len(generated_links) == 1:
                return generated_links[0][2].encode('utf-8')
            line = []
            for link in generated_links:
                extension = link[0].split('.')[-1]
                line.append(extension.encode('utf-8'))
            result = dialog.select('Choose the link', line)
            if result != -1:
                link = generated_links[result][2]
                return link.encode('utf-8')
            else:
                raise UrlResolver.ResolverError('No generated_link')
        elif 'main_link' in jsonresult:
            return jsonresult['main_link'].encode('utf-8')
        else:
            if 'message' in jsonresult:
                raise UrlResolver.ResolverError(jsonresult['message'].encode('utf-8'))
            else:
                raise UrlResolver.ResolverError('No generated_link and no main_link')

    def get_url(self, host, media_id):
        return media_id

    def get_host_and_id(self, url):
        return 'www.real-debrid.com', url

    def get_all_hosters(self):
        if self.hosters is None:
            try:
                url = 'http://www.real-debrid.com/api/regex.php?type=all'
                response = self.net.http_GET(url).content.lstrip('/').rstrip('/g')
                delim = '/g,/|/g\|-\|/'
                self.hosters = [re.compile(host) for host in re.split(delim, response)]
            except:
                self.hosters = []
        common.addon.log_debug('RealDebrid hosters : %s' % self.hosters)
        return self.hosters

    def get_hosts(self):
        if self.hosts is None:
            try:
                url = 'https://real-debrid.com/api/hosters.php'
                response = self.net.http_GET(url).content
                response = response[1:-1]
                self.hosts = response.split('","')
            except:
                self.hosts = []
        common.addon.log_debug('RealDebrid hosts : %s' % self.hosts)

    def valid_url(self, url, host):
        if self.get_setting('enabled') == 'false': return False
        if self.get_setting('login') == 'false': return False
        common.addon.log_debug('in valid_url %s : %s' % (url, host))
        if url:
            self.get_all_hosters()
            for host in self.hosters:
                # common.addon.log_debug('RealDebrid checking host : %s' %str(host))
                if re.search(host, url):
                    common.addon.log_debug('RealDebrid Match found')
                    return True
        elif host:
            self.get_hosts()
            if host in self.hosts or any(item in host for item in self.hosts):
                return True
        return False

    def checkLogin(self):
        url = 'https://real-debrid.com/api/account.php'
        if not os.path.exists(self.cookie_file):
            return True
        self.net.set_cookies(self.cookie_file)
        source = self.net.http_GET(url).content
        common.addon.log_debug(source)
        if re.search('expiration', source):
            common.addon.log_debug('checkLogin returning False')
            return False
        else:
            common.addon.log_debug('checkLogin returning True')
            return True

    # SiteAuth methods
    def login(self):
        if self.checkLogin():
            try:
                common.addon.log_debug('Need to login since session is invalid')
                import hashlib
                login_data = urllib.urlencode({'user': self.get_setting('username'), 'pass': hashlib.md5(self.get_setting('password')).hexdigest()})
                url = 'https://real-debrid.com/ajax/login.php?' + login_data
                source = self.net.http_GET(url).content
                if re.search('OK', source):
                    self.net.save_cookies(self.cookie_file)
                    self.net.set_cookies(self.cookie_file)
                    return True
            except:
                    common.addon.log_debug('error with http_GET')
                    dialog = xbmcgui.Dialog()
                    dialog.ok(' Real-Debrid ', ' Unexpected error, Please try again.', '', '')
            else:
                return False
        else:
            return True

    # 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 True
Beispiel #46
0
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('Séries Portuguesas', traducao(40000), traducao(40001))
        entrarnovamente(1)
    else:
        if re.search('003eA senha indicada n', logintest):
            mensagemok('Séries Portuguesas', traducao(40002))
            entrarnovamente(1)
        elif re.search('existe. Certifica-te que indicaste o nome correcto.',
                       logintest):
            mensagemok('Séries Portuguesas', traducao(40003))
            entrarnovamente(1)
        elif re.search(username, logintest):
            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('Séries Portuguesas',
                                           traducao(40005), "", "",
                                           traducao(40006), 'OK')
            if opcao: menu_principal(0)
            else: login_abelhas()
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/ecoss.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)
Beispiel #48
0
class movreelResolver(Plugin, UrlResolver, SiteAuth, PluginSettings):
    implements = [UrlResolver, SiteAuth, PluginSettings]
    name = "movreel"
    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
        

    def login(self):
        if self.get_setting('login') == 'true':
            loginurl = 'http://movreel.com/login.html'
            login = self.get_setting('username')
            password = self.get_setting('password')
            data = {'op': 'login', 'login': login, 'password': password}
            html = net.http_POST(loginurl, data).content
            if re.search('op=logout', html):
                self.net.save_cookies(self.cookie_file)
                common.addon.log('LOGIN SUCCESSFUL')
                return True
            else:
                common.addon.log('LOGIN FAILED')
                return False
        else:
            common.addon.log('No account info entered')
            return False
        

    def get_media_url(self, host, media_id):
               
        try:
            url = self.get_url(host, media_id)
            html = self.net.http_GET(url).content
            dialog = xbmcgui.DialogProgress()
            dialog.create('Resolving', 'Resolving Movreel Link...')
            dialog.update(0)
        
            html = net.http_GET(url).content
        
            dialog.update(33)
        
            if re.search('This server is in maintenance mode', html):
                raise Exception('File is currently unavailable on the host')
            
            data = {}
            r = re.findall(r'type="hidden" name="(.+?)"\s* value="?(.+?)">', html)
            method_free = re.search('<input type="(submit|hidden)" name="method_free" (style=".*?" )*value="(.*?)">', html).group(3)
            method_premium = re.search('<input type="(hidden|submit)" name="method_premium" (style=".*?" )*value="(.*?)">', html).group(3)
            
            if method_free:
                for name, value in r:
                    data[name] = value
                    data.update({'method_free':method_free})
            else:
                for name, value in r:
                    data[name] = value
                    data.update({'method_premium':method_premium})
        
            html = net.http_POST(url, data).content

            if method_free:
                if re.search('<p class="err">.+?</p>', html):
                    errortxt = re.search('<p class="err">(.+?)</p>', html).group(1)
                    raise Exception(errortxt)

                data = {}
                r = re.findall(r'type="hidden" name="(.+?)"\s* value="?(.+?)">', html)
                for name, value in r:
                    data[name] = value
                    data.update({'down_direct':1})
    
                html = net.http_POST(url, data).content

            dialog.update(100)
            link = re.search('<a id="lnk_download" href="(.+?)">Download Original Video</a>', html, re.DOTALL).group(1)
            
            dialog.close()
            mediurl = link
        
            return mediurl

        except Exception, e:
            common.addon.log('**** Movreel Error occured: %s' % e)
            common.addon.show_small_popup('Error', str(e), 5000, '')
            return self.unresolvable(code=0, msg='Exception: %s' % e)
Beispiel #49
0
class YouWatchResolver(Plugin, UrlResolver, SiteAuth, PluginSettings):
    implements = [UrlResolver, SiteAuth, PluginSettings]
    name = "youwatch"
    domains = ["youwatch.org"]
    profile_path = common.profile_path
    cookie_file = os.path.join(profile_path, '%s.cookies' % name)

    def __init__(self):
        p = self.get_setting('priority') or 100
        self.priority = int(p)
        self.net = Net()
        try:
            os.makedirs(os.path.dirname(self.cookie_file))
        except OSError:
            pass

    def get_media_url(self, host, media_id):
        base_url = 'http://' + host + '.org/embed-' + media_id + '.html'
        soup = self.net.http_GET(base_url).content
        html = soup.decode('utf-8')
        jscript = re.findall("""function\(p,a,c,k,e,d\).*return p\}(.*)\)""",
                             html)
        if jscript:
            lsParam = eval(jscript[0].encode('utf-8'))
            flashvars = self.exec_javascript(lsParam)
            r = re.findall('file:"(.*)",provider', flashvars)
            if r:
                stream_url = r[0].encode('utf-8')
                if self.get_setting('login') == 'true':
                    cookies = {}
                    for cookie in self.net._cj:
                        cookies[cookie.name] = cookie.value
                    stream_url = stream_url + '|' + urllib.urlencode(
                        {'Cookie': urllib.urlencode(cookies)})
                    common.addon.log_debug('stream_URL : ' + stream_url)
            else:
                raise UrlResolver.ResolverError('File Not Found or removed')
        else:
            raise UrlResolver.ResolverError('File Not Found or removed')
        return stream_url

    def get_url(self, host, media_id):
        return 'http://youwatch.org/%s' % media_id

    def get_host_and_id(self, url):
        r = re.search('http://(www.)?(.+?).org/embed-(.+?)-[0-9A-Za-z]+.html',
                      url)
        if not r:
            r = re.search('http://(www.)?(.+?).org/([0-9A-Za-z]+)', url)
        if r:
            ls = r.groups()
            if ls[0] == 'www.' or ls[0] == None:
                ls = (ls[1], ls[2])
            return ls
        else:
            return False

    def exec_javascript(self, lsParam):
        return re.sub('[a-zA-Z0-9]+',
                      Base36(lsParam[3]).param36decode, str(lsParam[0]))

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

    def login(self):
        if self.get_setting('login') == 'true':
            try:
                common.addon.log_debug('login to youwatch')
                url = 'http://youwatch.org'
                data = {
                    'op': 'login',
                    'login': self.get_setting('username'),
                    'password': self.get_setting('password')
                }
                source = self.net.http_POST(url, data).content
                if re.search('<b>Registred</b>', source):
                    self.net.save_cookies(self.cookie_file)
                    self.net.set_cookies(self.cookie_file)
                    return True
                elif re.search('Incorrect Login or Password', source):
                    common.addon.log_error(
                        '**** Youwatch Error occured on login: Incorrect Login or Password'
                    )
                    return False
                else:
                    common.addon.log_error(
                        '**** Youwatch Error occured on login: not logged')
                    return False
            except Exception as e:
                common.addon.log_error(
                    '**** Youwatch Error occured on login: %s' % e)
        else:
            return True

    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