コード例 #1
0
ファイル: menuhelper.py プロジェクト: n3wb13/OpenNfrGui-5.0-1
	def mh_buildMenu(self, url):
		self.d_print("mh_buildMenu:")
		self.mh_menuListe = []
		self.mh_menuListe.append((_('Please wait...'),None))
		self.ml.setList(map(self.mh_menuListentry, self.mh_menuListe))
		self.mh_lastPageUrl = url
		twAgentGetPage(url, agent=None, cookieJar=self.mh_cookieJar, headers=std_headers).addCallback(self.mh_parseCategorys).addErrback(self.mh_dataError)
コード例 #2
0
        def resolve(self, service, uri):
            Log.i(uri)
            uri = uri.replace('mp_euronews://', '').lower().strip()
            if uri == 'en':
                uri = 'www'
            uri = "https://%s.euronews.com/api/watchlive.json" % uri

            def onUrlReady(uri):
                try:
                    if not service.ptrValid():
                        Log.w("Service became invalid!")
                        return
                    if uri:
                        service.setResolvedUri(uri, eServiceReference.idGST)
                    else:
                        service.failedToResolveUri()
                except:
                    service.failedToResolveUri()

            if uri:
                twAgentGetPage(uri).addCallback(self.parseLive, service)
            else:
                service.failedToResolveUri()

            return True
コード例 #3
0
 def parseLive(self, data, service):
     data = data.replace('\/', '/')
     urls = re.findall('m3u8_url":"(.*?)"', data, re.S)
     if urls:
         uri = urls[-1]
     try:
         if not service.ptrValid():
             Log.w("Service became invalid!")
             return
         if uri:
             twAgentGetPage(uri).addCallback(self.parseData, service)
         else:
             service.failedToResolveUri()
     except:
         service.failedToResolveUri()
コード例 #4
0
 def mh_buildMenu(self,
                  url,
                  addlocation=False,
                  agent=None,
                  headers=std_headers):
     self.mh_menuListe = []
     self.mh_menuListe.append((_('Please wait...'), None))
     self.ml.setList(map(self.mh_menuListentry, self.mh_menuListe))
     self.mh_lastPageUrl = url
     self.d_print("mh_buildMenu:", url)
     if not url:
         self.mh_parseCategorys(None)
     else:
         try:
             import requests
             s = requests.session()
             headers = {'User-Agent': agent}
             page = s.get(url, cookies=self.mh_cookieJar, headers=headers)
             return self.mh_parseCategorys(page.content)
         except:
             return twAgentGetPage(url,
                                   agent=agent,
                                   cookieJar=self.mh_cookieJar,
                                   headers=headers,
                                   addlocation=addlocation,
                                   timeout=(10, 30)).addCallback(
                                       self.mh_parseCategorys).addErrback(
                                           self.mh_dataError)
コード例 #5
0
	def _get_page(self, url):
		url = url.encode("utf-8")
		if 'HLS_RESET_COOKIES' in os.environ.keys():
			self._cookies.clear()

		timeout = 10
		return twAgentGetPage(url, agent=self.agent, cookieJar=self._cookies, headers=self.hls_headers, timeout=timeout, pool=self._poolHelper._pool, proxy_url=self.purl, p_user=self.puser, p_pass=self.ppass)
コード例 #6
0
	def getNTStream(self, country):
		if country == "nl":
			self.base_url = "utopiatv.nl"
		else:
			self.base_url = "utopya.com.tr"
		auth_url = 'https://token.%s/api/2/GetLongLivedAuthToken/?callback=&authToken=&_=' % self.base_url
		return twAgentGetPage(auth_url, timeout=10).addCallback(self.getNTAuth).addErrback(self.getNTAuth, True)
コード例 #7
0
	def downloadPage(self, url, path):
		d = twAgentGetPage(url)
		f = open(path, 'wb')
		d.addCallback(lambda x: f.write(x))
		d.addBoth(lambda _: f.close())
		d.addCallback(lambda _: path)
		return d
コード例 #8
0
	def _get_page(self, url):
		url = url.encode("utf-8")
		if 'HLS_RESET_COOKIES' in os.environ.keys():
			self._cookies.clear()

		timeout = 10
		return twAgentGetPage(url, agent=self.agent, cookieJar=self._cookies, headers=self.hls_headers, timeout=timeout, pool=self._poolHelper._pool, proxy_url=self.purl, p_user=self.puser, p_pass=self.ppass)
コード例 #9
0
	def getNTAuth(self, jdata, err=False):
		try:
			auth_token = re.search('authToken":"(.*?)"', jdata).group(1)
			stream_url = 'https://token.%s/api/2/GetToken/?callback=&authToken=%s&streamKey=stream_live_1&platform=web&_=' % (self.base_url, auth_token)
		except:
			raise Exception('Cannot get utopia authToken!')
		else:
			return twAgentGetPage(stream_url, timeout=10).addCallback(self.getNTM3U8URL)
コード例 #10
0
 def _getWebPage(self, result, url, no_token=True):
     if no_token:
         if self.connected:
             self._sessionTimeoutTimer.start(1000 * self.SESSION_TIMEOUT, True)
         url = url.replace("%TOKEN%", self.session_token)
     return twAgentGetPage(
         url, agent=self.USER_AGENT, cookieJar=self.cookies, headers=Headers(self.agent_headers), timeout=15
     )
コード例 #11
0
 def getNTStream(self, country):
     if country == "nl":
         self.base_url = "utopiatv.nl"
     else:
         self.base_url = "utopya.com.tr"
     auth_url = 'https://token.%s/api/2/GetLongLivedAuthToken/?callback=&authToken=&_=' % self.base_url
     return twAgentGetPage(auth_url, timeout=10).addCallback(
         self.getNTAuth).addErrback(self.getNTAuth, True)
コード例 #12
0
	def mh_buildMenu(self, url, addlocation=False, agent=None, headers=std_headers):
		self.mh_menuListe = []
		self.mh_menuListe.append((_('Please wait...'),None))
		self.ml.setList(map(self.mh_menuListentry, self.mh_menuListe))
		self.mh_lastPageUrl = url
		self.d_print("mh_buildMenu:",url)
		if not url:
			self.mh_parseCategorys(None)
		else:
			return twAgentGetPage(url, agent=agent, cookieJar=self.mh_cookieJar, headers=headers, addlocation=addlocation, timeout=(10,30)).addCallback(self.mh_parseCategorys).addErrback(self.mh_dataError)
コード例 #13
0
 def getNTAuth(self, jdata, err=False):
     try:
         auth_token = re.search('authToken":"(.*?)"', jdata).group(1)
         stream_url = 'https://token.%s/api/2/GetToken/?callback=&authToken=%s&streamKey=stream_live_1&platform=web&_=' % (
             self.base_url, auth_token)
     except:
         raise Exception('Cannot get utopia authToken!')
     else:
         return twAgentGetPage(stream_url,
                               timeout=10).addCallback(self.getNTM3U8URL)
コード例 #14
0
        def resolve(self, service, uri):
            Log.i(uri)
            uri = uri.replace('mp_livestreamcom://', '').lower().strip()

            def onUrlReady(uri):
                try:
                    if not service.ptrValid():
                        Log.w("Service became invalid!")
                        return
                    if uri:
                        service.setResolvedUri(uri, eServiceReference.idGST)
                    else:
                        service.failedToResolveUri()
                except:
                    service.failedToResolveUri()

            if uri:
                twAgentGetPage(uri).addCallback(self.parseLive, service)
            else:
                service.failedToResolveUri()

            return True
コード例 #15
0
	def getATVStream(self, station):
		if station == "atv":
			self.url = 'http://www.atv.com.tr/webtv/secure?url=http://trkvz-live.ercdn.net/atvhd/atvhd.m3u8'
		elif station == "aspor":
			self.url = 'http://www.aspor.com.tr/webtv/secure?url=http://trkvz-live.ercdn.net/asporhd/asporhd.m3u8'
		elif station == "ahaber":
			self.url = 'http://www.ahaber.com.tr/webtv/secure?url=http://trkvz-live.ercdn.net/ahaberhd/ahaberhd.m3u8'
		elif station == "atvavrupa":
			self.url = 'http://www.atv.com.tr/webtv/secure?url=http://trkvz-live.ercdn.net/atvavrupa/atvavrupa.m3u8'
		elif station == "minikacocuk":
			self.url = 'http://www.minikacocuk.com.tr/webtv/secure?url=http://trkvz-live.ercdn.net/minikagococuk/minikagococuk.m3u8'
		elif station == "minikago":
			self.url = 'http://www.minikago.com.tr/webtv/secure?url=http://trkvz-live.ercdn.net/minikago/minikago.m3u8'
		return twAgentGetPage(self.url, timeout=10, agent=agent).addCallback(self.getATVAuthUrl).addErrback(self.getATVAuthUrl, True)
コード例 #16
0
 def getATVStream(self, station):
     if station == "atv":
         self.url = 'http://www.atv.com.tr/webtv/secure?url=http://trkvz-live.ercdn.net/atvhd/atvhd.m3u8'
     elif station == "aspor":
         self.url = 'http://www.aspor.com.tr/webtv/secure?url=http://trkvz-live.ercdn.net/asporhd/asporhd.m3u8'
     elif station == "ahaber":
         self.url = 'http://www.ahaber.com.tr/webtv/secure?url=http://trkvz-live.ercdn.net/ahaberhd/ahaberhd.m3u8'
     elif station == "atvavrupa":
         self.url = 'http://www.atv.com.tr/webtv/secure?url=http://trkvz-live.ercdn.net/atvavrupa/atvavrupa.m3u8'
     elif station == "minikacocuk":
         self.url = 'http://www.minikacocuk.com.tr/webtv/secure?url=http://trkvz-live.ercdn.net/minikagococuk/minikagococuk.m3u8'
     elif station == "minikago":
         self.url = 'http://www.minikago.com.tr/webtv/secure?url=http://trkvz-live.ercdn.net/minikago/minikago.m3u8'
     return twAgentGetPage(self.url, timeout=10, agent=agent).addCallback(
         self.getATVAuthUrl).addErrback(self.getATVAuthUrl, True)
コード例 #17
0
 def requestM3U8(self, url):
     d = twAgentGetPage(str(url), agent=self.USER_AGENT)
     d.addCallback(self._getM3U8List)
     d.addCallback(self._getBestVideoUrl, url).addErrback(self.dataError)
     return d
コード例 #18
0
def r_getPage(url, *args, **kwargs):
    def retry(err):
        return getPage(url.replace('https:', 'http:'), *args, **kwargs)

    return twAgentGetPage(url, *args, **kwargs).addErrback(retry)
コード例 #19
0
 def checkforupdate(self):
     update_agent = getUserAgent()
     update_url = getUpdateUrl()
     twAgentGetPage(update_url, agent=update_agent, timeout=60).addCallback(
         self.gotUpdateInfo).addErrback(self.gotError)
コード例 #20
0
	def checkforupdate(self):
		update_agent = getUserAgent()
		update_url = getUpdateUrl()
		twAgentGetPage(update_url, agent=update_agent, timeout=60).addCallback(self.gotUpdateInfo).addErrback(self.gotError)