本文整理汇总了Python中Plugins.Extensions.MediaPortal.resources.twagenthelper.TwAgentHelper.getWebPage方法的典型用法代码示例。如果您正苦于以下问题:Python TwAgentHelper.getWebPage方法的具体用法?Python TwAgentHelper.getWebPage怎么用?Python TwAgentHelper.getWebPage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plugins.Extensions.MediaPortal.resources.twagenthelper.TwAgentHelper
的用法示例。
在下文中一共展示了TwAgentHelper.getWebPage方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: IStreamStreams
# 需要导入模块: from Plugins.Extensions.MediaPortal.resources.twagenthelper import TwAgentHelper [as 别名]
# 或者: from Plugins.Extensions.MediaPortal.resources.twagenthelper.TwAgentHelper import getWebPage [as 别名]
class IStreamStreams(Screen, ConfigListScreen):
def __init__(self, session, filmUrl, filmName, imageLink):
self.session = session
self.filmUrl = filmUrl
self.filmName = filmName
self.imageUrl = imageLink
self.plugin_path = mp_globals.pluginPath
self.skin_path = mp_globals.pluginPath + "/skins"
path = "%s/%s/defaultListScreen.xml" % (self.skin_path, config.mediaportal.skin.value)
if not fileExists(path):
path = self.skin_path + "/original/defaultListScreen.xml"
print path
with open(path, "r") as f:
self.skin = f.read()
f.close()
Screen.__init__(self, session)
self["actions"] = ActionMap(
[
"OkCancelActions",
"ShortcutActions",
"EPGSelectActions",
"WizardActions",
"ColorActions",
"NumberActions",
"MenuActions",
"MoviePlayerActions",
"InfobarSeekActions",
],
{
"red": self.keyTxtPageUp,
"blue": self.keyTxtPageDown,
"ok": self.keyOK,
"info": self.keyTMDbInfo,
"cancel": self.keyCancel,
},
-1,
)
self["title"] = Label(IS_Version)
self["ContentTitle"] = Label("Stream Auswahl")
self["coverArt"] = Pixmap()
self["handlung"] = ScrollLabel("")
self["name"] = Label(filmName)
self["Page"] = Label("")
self["page"] = Label("")
self["F1"] = Label("Text-")
self["F2"] = Label("")
self["F3"] = Label("")
self["F4"] = Label("Text+")
self.tw_agent_hlp = TwAgentHelper()
self.streamListe = []
self.streamMenuList = MenuList([], enableWrapAround=True, content=eListboxPythonMultiContent)
self.streamMenuList.l.setFont(0, gFont("mediaportal", 24))
self.streamMenuList.l.setItemHeight(25)
self["liste"] = self.streamMenuList
self.keyLocked = True
self.onLayoutFinish.append(self.loadPage)
def loadPage(self):
print "loadPage:"
streamUrl = self.filmUrl
# print "FilmUrl: %s" % self.filmUrl
# print "FilmName: %s" % self.filmName
self.tw_agent_hlp.getWebPage(self.parseData, self.dataError, streamUrl, False)
def parseData(self, data):
print "parseData:"
streams = re.findall('a class="hoster-button.*?href="(.*?)".*?title=".*?\[(.*?)\](.*?)"', data)
mdesc = re.search('class="desc">(.*?)<br />', data, re.S)
if mdesc:
print "Descr. found"
desc = mdesc.group(1).strip()
else:
desc = "Keine weiteren Info's !"
self.streamListe = []
if streams:
print "Streams found"
for (isUrl, isStream, streamPart) in streams:
if re.match(
".*?(putlocker|sockshare|streamclou|xvidstage|filenuke|movreel|nowvideo|xvidstream|uploadc|vreer|MonsterUploads|Novamov|Videoweed|Divxstage|Ginbig|Flashstrea|Movshare|yesload|faststream|Vidstream|PrimeShare|flashx|Divxmov|Putme|Click.*?Play|BitShare)",
isStream,
re.S | re.I,
):
# print isUrl
# print isStream,streamPart
self.streamListe.append((isStream, isUrl, streamPart))
else:
print "No supported hoster:"
print isStream
print isUrl
else:
print "No Streams found"
self.streamListe.append(("No streams found!", "", ""))
#.........这里部分代码省略.........
示例2: youpornFilmScreen
# 需要导入模块: from Plugins.Extensions.MediaPortal.resources.twagenthelper import TwAgentHelper [as 别名]
# 或者: from Plugins.Extensions.MediaPortal.resources.twagenthelper.TwAgentHelper import getWebPage [as 别名]
Link = self['liste'].getCurrent()[0][1]
self.session.open(youpornFilmScreen, Link, Name)
class youpornFilmScreen(MPScreen, ThumbsHelper):
def __init__(self, session, Link, Name):
self.Link = Link
self.Name = Name
self.plugin_path = mp_globals.pluginPath
self.skin_path = mp_globals.pluginPath + mp_globals.skinsPath
path = "%s/%s/defaultListWideScreen.xml" % (self.skin_path, config.mediaportal.skin.value)
if not fileExists(path):
path = self.skin_path + mp_globals.skinFallback + "/defaultListWideScreen.xml"
with open(path, "r") as f:
self.skin = f.read()
f.close()
MPScreen.__init__(self, session)
ThumbsHelper.__init__(self)
self["actions"] = ActionMap(["MP_Actions"], {
"ok" : self.keyOK,
"0" : self.closeAll,
"cancel" : self.keyCancel,
"5" : self.keyShowThumb,
"up" : self.keyUp,
"down" : self.keyDown,
"right" : self.keyRight,
"left" : self.keyLeft,
"nextBouquet" : self.keyPageUp,
"prevBouquet" : self.keyPageDown,
"green" : self.keyPageNumber
}, -1)
self['title'] = Label("YouPorn.com")
self['ContentTitle'] = Label("Genre: %s" % self.Name)
self['F2'] = Label(_("Page"))
self['Page'] = Label(_("Page:"))
self.keyLocked = True
self.page = 1
self.lastpage = 1
self.tw_agent_hlp = TwAgentHelper(redir_agent=True)
self.tw_agent_hlp.headers.addRawHeader('Cookie','age_verified=1')
self.filmliste = []
self.ml = MenuList([], enableWrapAround=True, content=eListboxPythonMultiContent)
self['liste'] = self.ml
self.onLayoutFinish.append(self.loadPage)
def loadPage(self):
self.keyLocked = True
self['name'].setText(_('Please wait...'))
self.filmliste = []
url = "%s%s" % (self.Link, str(self.page))
self.tw_agent_hlp.getWebPage(url).addCallback(self.loadData).addErrback(self.dataError)
def loadData(self, data):
self.getLastPage(data, 'id="pagination">(.*?)</nav>')
parse = re.search('Sub menu dropdown.*?/Sub menu dropdown(.*?)Our Friends', data, re.S)
if not parse:
parse = re.search('Sub menu dropdown.*?/Sub menu dropdown(.*?)pagination', data, re.S)
if parse:
Movies = re.findall('class="videoBox.*?<a\shref="(.*?)">.*?<img\ssrc=".*?"\salt="(.*?)".*?data-thumbnail="(.*?)".*?class="duration">(.*?)</span>.*?class="rating\sup"><i>(.*?)</i>', parse.group(1), re.S)
if Movies:
for (Url, Title, Image, Runtime, Rating) in Movies:
Url = Url.replace("&","&")
self.filmliste.append((decodeHtml(Title), Url, Image, Runtime, Rating))
if len(self.filmliste) == 0:
self.filmliste.append(('Keine Filme gefunden.', '', None, '', ''))
self.ml.setList(map(self._defaultlistleft, self.filmliste))
self.ml.moveToIndex(0)
self.keyLocked = False
self.th_ThumbsQuery(self.filmliste, 0, 1, 2, None, None, self.page, self.lastpage, mode=1)
self.showInfos()
def showInfos(self):
title = self['liste'].getCurrent()[0][0]
pic = self['liste'].getCurrent()[0][2]
runtime = self['liste'].getCurrent()[0][3]
rating = self['liste'].getCurrent()[0][4]
self['name'].setText(title)
self['handlung'].setText("Runtime: %s\nRating: %s" % (runtime, rating))
CoverHelper(self['coverArt']).getCover(pic)
def keyOK(self):
if self.keyLocked:
return
Link = 'http://www.youporn.com' + self['liste'].getCurrent()[0][1]
self.keyLocked = True
getPage(Link, headers={'Cookie': 'age_verified=1', 'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.getVideoPage).addErrback(self.dataError)
def getVideoPage(self, data):
videoPage = None
Title = self['liste'].getCurrent()[0][0]
encrypted_links = re.findall(r'encryptedQuality720URL\s=\s\'([a-zA-Z0-9+/]+={0,2})\',', data)
for encrypted_link in encrypted_links:
videoPage = aes_decrypt_text(encrypted_link, Title, 32)
if videoPage:
#.........这里部分代码省略.........
示例3: IStreamFilmListeScreen
# 需要导入模块: from Plugins.Extensions.MediaPortal.resources.twagenthelper import TwAgentHelper [as 别名]
# 或者: from Plugins.Extensions.MediaPortal.resources.twagenthelper.TwAgentHelper import getWebPage [as 别名]
#.........这里部分代码省略.........
self["ContentTitle"].setText("%s%s%s" % (self.genreTitle, self.genreName, self.sortOrderStrGenre))
def loadPage(self):
print "loadPage:"
if not self.sucheFilme:
url = "%s%d%s" % (self.genreLink, self.page, self.sortParStr[self.sortOrder])
else:
url = self.genreLink
if self.page:
self["page"].setText("%d / %d" % (self.page, self.pages))
self.filmQ.put(url)
print "eventL ", self.eventL.is_set()
if not self.eventL.is_set():
self.eventL.set()
self.loadPageQueued()
else:
self["name"].setText("Bitte warten...")
self["handlung"].setText("")
self["coverArt"].hide()
print "eventL ", self.eventL.is_set()
def loadPageQueued(self):
print "loadPageQueued:"
self["name"].setText("Bitte warten...")
self["handlung"].setText("")
self["coverArt"].hide()
while not self.filmQ.empty():
url = self.filmQ.get_nowait()
print url
self.tw_agent_hlp.getWebPage(self.loadPageData, self.dataError, url, False)
def dataError(self, error):
self.eventL.clear()
print "dataError:"
printl(error, self, "E")
self.filmListe.append(("No movies found !", ""))
self.chooseMenuList.setList(map(IStreamFilmListEntry, self.filmListe))
def loadPageData(self, data):
print "loadPageData:", len(data)
self.filmListe = []
if not self.neueFilme:
filme = re.findall(
'<div class="cover">.*?<a href="(.*?)" rel=.*?title="(.*?)">.*?data-original="(.*?)"', data, re.S
)
else:
print "Parse new movies"
filme = re.findall('<div class="voting".*?<a href="(.*?)".*?title="(.*?)">.*?data-original="(.*?)"', data)
if filme:
print "Movies found !"
if not self.pages:
m = re.findall("<span class='pages'>Seite 1 von (.*?)</", data)
if m:
self.pages = int(m[0])
else:
self.pages = 1
self.page = 1
print "Page: %d / %d" % (self.page, self.pages)
self["page"].setText("%d / %d" % (self.page, self.pages))
示例4: streamitStreams
# 需要导入模块: from Plugins.Extensions.MediaPortal.resources.twagenthelper import TwAgentHelper [as 别名]
# 或者: from Plugins.Extensions.MediaPortal.resources.twagenthelper.TwAgentHelper import getWebPage [as 别名]
class streamitStreams(Screen, ConfigListScreen):
def __init__(self, session, filmUrl, filmName, imageLink):
self.session = session
self.filmUrl = filmUrl
self.filmName = filmName
self.imageUrl = imageLink
self.plugin_path = mp_globals.pluginPath
self.skin_path = mp_globals.pluginPath + "/skins"
path = "%s/%s/defaultListScreen.xml" % (self.skin_path, config.mediaportal.skin.value)
if not fileExists(path):
path = self.skin_path + "/original/defaultListScreen.xml"
print path
with open(path, "r") as f:
self.skin = f.read()
f.close()
Screen.__init__(self, session)
self["actions"] = ActionMap(["OkCancelActions", "ShortcutActions", "EPGSelectActions", "WizardActions", "ColorActions", "NumberActions", "MenuActions", "MoviePlayerActions", "InfobarSeekActions"], {
"red" : self.keyTxtPageUp,
"blue" : self.keyTxtPageDown,
"green" : self.keyTrailer,
"ok" : self.keyOK,
"info" : self.keyTMDbInfo,
"cancel" : self.keyCancel
}, -1)
self['title'] = Label(IS_Version)
self['ContentTitle'] = Label("Stream Auswahl")
self['coverArt'] = Pixmap()
self['handlung'] = ScrollLabel("")
self['name'] = Label(filmName)
self['Page'] = Label("")
self['page'] = Label("")
self['F1'] = Label("Text-")
self['F2'] = Label("")
self['F3'] = Label("")
self['F4'] = Label("Text+")
self.trailerId = None
self.tw_agent_hlp = TwAgentHelper()
self.streamListe = []
self.streamMenuList = MenuList([], enableWrapAround=True, content=eListboxPythonMultiContent)
self.streamMenuList.l.setFont(0, gFont('mediaportal', 24))
self.streamMenuList.l.setItemHeight(25)
self['liste'] = self.streamMenuList
self.keyLocked = True
self.onLayoutFinish.append(self.loadPage)
def loadPage(self):
print "loadPage:"
streamUrl = self.filmUrl
#print "FilmUrl: %s" % self.filmUrl
#print "FilmName: %s" % self.filmName
self.tw_agent_hlp.getWebPage(self.parseData, self.dataError, streamUrl, False)
def parseData(self, data):
print "parseData:"
m = re.search('<div id="stream">(.*?)</div>',data, re.S)
if not m:
m = re.search('<strong><h2>Hoster:</h2></strong>(.*?)</div>',data, re.S)
if m:
streams = re.findall('\s\s<a href="(.*?)".*?value="(.*?)"', m.group(1), re.S)
else:
streams = None
m = re.search('href="http://www.youtube.com/(.*?)\?', data)
if m:
s = m.group(1).split('/')
try:
self.trailerId = m.group(1).split('/')[-1]
except:
pass
else:
self['F2'].setText('Trailer')
mdesc = re.search('\s{4}(.*?…)',data)
if mdesc:
print "Descr. found"
desc = mdesc.group(1).strip()
else:
desc = "Keine weiteren Info's !"
#print desc
self.streamListe = []
if streams:
print "Streams found"
for (isUrl,isStream) in streams:
if re.search('(putlocker|sockshare|streamclou|xvidstage|filenuke|movreel|nowvideo|xvidstream|uploadc|vreer|MonsterUploads|Novamov|Videoweed|Divxstage|Ginbig|Flashstrea|Movshare|yesload|faststream|Vidstream|PrimeShare|flashx|Divxmov|Putme|Click.*?Play|BitShare)', isStream, re.S|re.I):
streamPart = ''
isUrl = isUrl.replace('\n','')
isUrl = isUrl.replace('\r','')
print isUrl
print isStream,streamPart
self.streamListe.append((isStream,isUrl,streamPart))
else:
#.........这里部分代码省略.........
示例5: rlstoGenreScreen
# 需要导入模块: from Plugins.Extensions.MediaPortal.resources.twagenthelper import TwAgentHelper [as 别名]
# 或者: from Plugins.Extensions.MediaPortal.resources.twagenthelper.TwAgentHelper import getWebPage [as 别名]
class rlstoGenreScreen(MPScreen):
def __init__(self, session):
self.plugin_path = mp_globals.pluginPath
self.skin_path = mp_globals.pluginPath + mp_globals.skinsPath
path = "%s/%s/defaultGenreScreen.xml" % (self.skin_path, config.mediaportal.skin.value)
if not fileExists(path):
path = self.skin_path + mp_globals.skinFallback + "/defaultGenreScreen.xml"
with open(path, "r") as f:
self.skin = f.read()
f.close()
MPScreen.__init__(self, session)
self["actions"] = ActionMap(
["MP_Actions"], {"ok": self.keyOK, "0": self.closeAll, "cancel": self.keyCancel}, -1
)
self["title"] = Label(BASE_NAME)
self["ContentTitle"] = Label("Genre:")
self.keyLocked = True
self.suchString = ""
self.tw_agent_hlp = TwAgentHelper(followRedirect=True)
self.filmliste = []
self.ml = MenuList([], enableWrapAround=True, content=eListboxPythonMultiContent)
self["liste"] = self.ml
self.onLayoutFinish.append(self.layoutFinished)
def layoutFinished(self):
url = "http://rls.to/a"
self.tw_agent_hlp.getWebPage(url).addCallback(self.parseData).addErrback(self.dataError)
def parseData(self, data):
parse = re.search('class="right">(.*?)</ul>', data, re.S)
raw = re.findall('class="menu-item.*?href="(.*?)">(.*?)</a>', parse.group(1), re.S)
if raw:
for (Url, Title) in raw:
self.filmliste.append((decodeHtml(Title), Url))
self.filmliste.insert(0, ("--- Search ---", None))
self.ml.setList(map(self._defaultlistcenter, self.filmliste))
self.keyLocked = False
def SuchenCallback(self, callback=None, entry=None):
if callback is not None and len(callback):
self.suchString = callback.replace(" ", "+")
Name = "--- Search ---"
Link = self.suchString
self.session.open(rlstoListScreen, Link, Name)
def keyOK(self):
if self.keyLocked:
return
if not config.mediaportal.premiumize_use.value and not config.mediaportal.realdebrid_use.value:
message = self.session.open(
MessageBoxExt,
_("%s only works with enabled MP premiumize.me or Real-Debrid.com option (MP Setup)!" % BASE_NAME),
MessageBoxExt.TYPE_INFO,
timeout=10,
)
return
Name = self["liste"].getCurrent()[0][0]
Link = self["liste"].getCurrent()[0][1]
if Name == "--- Search ---":
self.suchen()
else:
self.session.open(rlstoListScreen, Link, Name)
示例6: IStreamStreams
# 需要导入模块: from Plugins.Extensions.MediaPortal.resources.twagenthelper import TwAgentHelper [as 别名]
# 或者: from Plugins.Extensions.MediaPortal.resources.twagenthelper.TwAgentHelper import getWebPage [as 别名]
class IStreamStreams(Screen, ConfigListScreen):
def __init__(self, session, filmUrl, filmName, imageLink):
self.session = session
self.filmUrl = filmUrl
self.filmName = filmName
self.imageUrl = imageLink
self.plugin_path = mp_globals.pluginPath
self.skin_path = mp_globals.pluginPath + "/skins"
path = "%s/%s/defaultListScreen.xml" % (self.skin_path, config.mediaportal.skin.value)
if not fileExists(path):
path = self.skin_path + "/original/defaultListScreen.xml"
print path
with open(path, "r") as f:
self.skin = f.read()
f.close()
Screen.__init__(self, session)
self["actions"] = ActionMap(["OkCancelActions", "ShortcutActions", "EPGSelectActions", "WizardActions", "ColorActions", "NumberActions", "MenuActions", "MoviePlayerActions", "InfobarSeekActions"], {
"red" : self.keyTxtPageUp,
"blue" : self.keyTxtPageDown,
"ok" : self.keyOK,
"cancel" : self.keyCancel
}, -1)
self['title'] = Label(IS_Version)
self['ContentTitle'] = Label("Stream Auswahl")
self['coverArt'] = Pixmap()
self['handlung'] = ScrollLabel("")
self['name'] = Label(filmName)
self['Page'] = Label("")
self['page'] = Label("")
self['F1'] = Label("Text-")
self['F2'] = Label("")
self['F3'] = Label("")
self['F4'] = Label("Text+")
self.tw_agent_hlp = TwAgentHelper()
self.streamListe = []
self.streamMenuList = MenuList([], enableWrapAround=True, content=eListboxPythonMultiContent)
self.streamMenuList.l.setFont(0, gFont('mediaportal', 24))
self.streamMenuList.l.setItemHeight(25)
self['liste'] = self.streamMenuList
self.keyLocked = True
self.onLayoutFinish.append(self.loadPage)
def loadPage(self):
print "loadPage:"
streamUrl = self.filmUrl
#print "FilmUrl: %s" % self.filmUrl
#print "FilmName: %s" % self.filmName
#getPage(streamUrl, headers={'Content-Type':'application/x-www-form-urlencoded'}).addCallback(self.parseData).addErrback(self.dataError)
self.tw_agent_hlp.getWebPage(self.parseData, self.dataError, streamUrl, False)
def parseData(self, data):
print "parseData:"
streams = re.findall('a class="hoster-button.*?href="(.*?)".*?title=".*?\[(.*?)\](.*?)"', data)
mdesc = re.search('class="desc">(.*?)<br />',data, re.S)
if mdesc:
print "Descr. found"
desc = mdesc.group(1).strip()
else:
desc = "Keine weiteren Info's !"
self.streamListe = []
if streams:
print "Streams found"
for (isUrl,isStream,streamPart) in streams:
if re.match('.*?(putlocker|sockshare|flash strea|streamclou|xvidstage|filenuke|movreel|nowvideo|xvidstream|uploadc|vreer|MonsterUploads|Novamov|Videoweed|Divxstage|Ginbig|Flashstrea|Movshare|yesload|faststream|Vidstream|PrimeShare|flashx|Divxmov|Putme|Zooupload|Click.*?Play|BitShare)', isStream, re.S|re.I):
#print isUrl
#print isStream,streamPart
self.streamListe.append((isStream,isUrl,streamPart))
else:
print "No supported hoster:"
print isStream
print isUrl
else:
print "No Streams found"
self.streamListe.append(("No streams found !","",""))
self.streamMenuList.setList(map(IStreamStreamListEntry, self.streamListe))
self['handlung'].setText(decodeHtml(desc))
self.keyLocked = False
print "imageUrl: ",self.imageUrl
if self.imageUrl:
downloadPage(self.imageUrl, "/tmp/Icon.jpg").addCallback(self.ShowCover)
def ShowCover(self, picData):
print "ShowCover:"
if fileExists("/tmp/Icon.jpg"):
self['coverArt'].instance.setPixmap(gPixmapPtr())
self.scale = AVSwitch().getFramebufferScale()
self.picload = ePicLoad()
size = self['coverArt'].instance.size()
self.picload.setPara((size.width(), size.height(), self.scale[0], self.scale[1], False, 1, "#FF000000"))
if self.picload.startDecode("/tmp/Icon.jpg", 0, 0, False) == 0:
#.........这里部分代码省略.........
示例7: m4kStreamListeScreen
# 需要导入模块: from Plugins.Extensions.MediaPortal.resources.twagenthelper import TwAgentHelper [as 别名]
# 或者: from Plugins.Extensions.MediaPortal.resources.twagenthelper.TwAgentHelper import getWebPage [as 别名]
class m4kStreamListeScreen(MPScreen):
def __init__(self, session, url, name, which):
self.url = url
self.name = name
self.which = which
self.plugin_path = mp_globals.pluginPath
self.skin_path = mp_globals.pluginPath + mp_globals.skinsPath
path = "%s/%s/defaultGenreScreenCover.xml" % (self.skin_path, config.mediaportal.skin.value)
if not fileExists(path):
path = self.skin_path + mp_globals.skinFallback + "/defaultGenreScreenCover.xml"
with open(path, "r") as f:
self.skin = f.read()
f.close()
MPScreen.__init__(self, session)
self["actions"] = ActionMap(["MP_Actions"], {
"ok" : self.keyOK,
"0" : self.closeAll,
"cancel": self.keyCancel
}, -1)
self['title'] = Label(m4k)
self['ContentTitle'] = Label(_("Stream Selection"))
self.coverUrl = None
self.base_url = m4k_url
self.tw_agent_hlp = TwAgentHelper(redir_agent=True)
self.keyLocked = True
self.list = []
self.keckse = {}
self.ml = MenuList([], enableWrapAround=True, content=eListboxPythonMultiContent)
self['liste'] = self.ml
self.onLayoutFinish.append(self.loadPage)
def loadPage(self):
self['name'].setText(_("Please wait..."))
self.tw_agent_hlp.getWebPage(self.url).addCallback(self.loadPageData).addErrback(self.dataError)
def loadPageData(self, data):
if re.match('.*?<img src="https://img.movie4k.*?/thumbs/', data, re.S):
cover = re.findall('<img src="https://img.movie4k.*?/thumbs/(.*?)"', data, re.S)
self.pic = cover[0]
self.cover = "%s%s" %(t_url,self.pic)
CoverHelper(self['coverArt']).getCover(self.cover)
if self.which == "movie":
streams = []
dupe = []
hosters = re.findall('<tr id=.*?tablemoviesindex2.*?>(.*?)</td></tr>', data, re.S)
if hosters:
self.list = []
for hoster_raw in hosters:
hoster_data = re.findall('href.*?"(.*?)">(.*?)<img.*? (.*?)<', hoster_raw)
if hoster_data:
(h_url, h_date, h_name) = hoster_data[0]
hoster_url = "%s%s" % (m4k_url, h_url.replace('\\',''))
if not hoster_url in dupe:
dupe.append(hoster_url)
if isSupportedHoster(h_name, True):
self.list.append((h_name, hoster_url,h_date,'',''))
self['name'].setText(self.name)
else:
hosters = re.findall('<a target="_blank" href="(http://(.*?)\..*?)"><img border=0', data, re.S)
if hosters:
(h_url, h_name) = hosters[0]
print h_url, h_name.capitalize()
if isSupportedHoster(h_name, True):
self.list.append((h_name.capitalize(),h_url,'', '',''))
self['name'].setText(self.name)
else:
hoster = re.findall('"tablemoviesindex2.*?<a href.*?"(.*?.html).*?style.*?src.*?"/img/.*?.[gif|png].*?> \ (.*?)</a></td></tr>', data, re.S)
if hoster:
for url,hostername in hoster:
url = "%s%s" % (m4k_url,url)
if isSupportedHoster(hostername, True):
self.list.append((hostername,url,'','',''))
self['name'].setText(self.name)
if len(self.list) == 0:
self.list.append(("", "", "No supported streams found."))
self.ml.setList(map(self.kxStreamListEntry, self.list))
self.showInfosData(data)
else:
self.ml.setList(map(self.kxStreamListEntry, self.list))
self.keyLocked = False
self.showInfosData(data)
self['name'].setText(self.name)
def keyOK(self):
exist = self['liste'].getCurrent()
if self.keyLocked or exist == None:
return
streamLink = self['liste'].getCurrent()[0][1]
self.tw_agent_hlp.getWebPage(streamLink).addCallback(self.get_streamlink, streamLink).addErrback(self.dataError)
def get_streamlink(self, data, streamLink):
if re.match('.*?(http://img.movie4k.*?/img/parts/teil1_aktiv.png|http://img.movie4k.*?/img/parts/teil1_inaktiv.png|http://img.movie4k.*?/img/parts/part1_active.png|http://img.movie4k.*?/img/parts/part1_inactive.png)', data, re.S):
self.session.open(m4kPartListeScreen, streamLink, self.name)
elif isSupportedHoster(streamLink, True):
get_stream_link(self.session).check_link(streamLink, self.got_link, False)
#.........这里部分代码省略.........
示例8: realdebrid_oauth2
# 需要导入模块: from Plugins.Extensions.MediaPortal.resources.twagenthelper import TwAgentHelper [as 别名]
# 或者: from Plugins.Extensions.MediaPortal.resources.twagenthelper.TwAgentHelper import getWebPage [as 别名]
class realdebrid_oauth2(Screen):
def __init__(self, session, link , calltype='link'):
self.link = link
self.calltype = calltype
self.raccesstoken = config.mediaportal.realdebrid_accesstoken.value
self.rrefreshtoken = config.mediaportal.realdebrid_refreshtoken.value
self.rclient_id = config.mediaportal.realdebrid_rclient_id.value
self.rclient_secret = config.mediaportal.realdebrid_rclient_secret.value
self.rAPPid = "2BKDBPNPA4D3U"
self.rdevicecode = ''
self.mpversion = config.mediaportal.versiontext.value
self.agent = None
Screen.__init__(self, session)
self.onLayoutFinish.append(self.getRealdebrid)
def getRealdebrid(self, loop=False):
self.agent = TwAgentHelper(headers={'User-Agent': 'E2 MediaPortal/%s' % self.mpversion,
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Bearer %s' % self.raccesstoken
})
if self.calltype == 'link':
self.getLink(loop)
elif self.calltype == 'user':
self.getUserInfo(loop)
else:
self.closeall()
def getUserInfo(self, loop=False):
if self.raccesstoken:
url = "https://api.real-debrid.com/rest/1.0/user"
self.agent.getWebPage(url).addCallback(self.getUserInfoData, loop).addErrback(self.getTokenError, loop).addErrback(self.noerrorload)
else:
url = 'https://api.real-debrid.com/oauth/v2/device/code?client_id=%s&new_credentials=yes' % self.rAPPid
self.agent.getWebPage(url).addCallback(self.getAuth).addErrback(self.codeerror, 'getAuth code error')
def getUserInfoData(self, data, loop):
try:
result = json.loads(data)
except:
self.session.open(MessageBoxExt, _("Real-Debrid: Error getting Userdata!"), MessageBoxExt.TYPE_INFO, timeout=5)
self.closeall()
else:
if not 'error' in result:
pmsg = "Real-Debrid.com"
if 'username' in result: pmsg += "\nUser:\t%s" % str(result['username'])
if 'type' in result: pmsg += "\nType:\t%s" % str(result['type'])
if 'expiration' in result: pmsg += "\nExpires: \t%s" % str(result['expiration']).replace('T',' ').replace('.000Z','')
url = "https://api.real-debrid.com/rest/1.0/traffic"
self.agent.getWebPage(url).addCallback(self.getUserTrafficData, pmsg).addErrback(self.noerrorload)
else:
if not loop and result['error_code'] == 8:
self.getRefreshToken()
else:
self.errorResult(result)
def getUserTrafficData(self, data, pmsg=None):
try:
result = json.loads(data)
except:
self.session.open(MessageBoxExt, _("Real-Debrid: Error getting Userdata!"), MessageBoxExt.TYPE_INFO, timeout=3)
self.closeall()
else:
if not 'error' in result:
pmsg += "\nLimits:"
for item in result:
if 'type' in result[item] and item != 'remote':
limittype = str(result[item]['type'])
pmsg += "\n%s\t" % str(item)
if limittype == 'links':
if 'links' in result[item]: pmsg += "Used: %s links" % str(result[item]['links'])
if 'limit' in result[item]: pmsg += "\tLimit: %s links" % str(result[item]['limit'])
if 'reset' in result[item]: pmsg += "/%s" % str(result[item]['reset'])
if limittype == 'gigabytes':
if 'bytes' in result[item]: pmsg += "Used: %s MB" % str(result[item]['bytes']/1024/1024)
if 'left' in result[item]: pmsg += " \tLimit: %s GB" % str(result[item]['left']/1024/1024/1024)
if 'reset' in result[item]: pmsg += "/%s" % str(result[item]['reset'])
self.session.open(MessageBoxExt, pmsg , MessageBoxExt.TYPE_INFO)
self.closeall()
else:
self.session.open(MessageBoxExt, pmsg , MessageBoxExt.TYPE_INFO, timeout=10)
self.errorResult(result)
def errorResult(self, result):
if 'error_code' in result:
if result['error_code'] == 8:
self.session.openWithCallback(self.removetokens, MessageBoxExt, _("Real-Debrid: Error %s. Do you want to remove AuthToken and AccessToken?" % str(result['error'])), MessageBoxExt.TYPE_YESNO)
else:
self.session.open(MessageBoxExt, _("Real-Debrid: Error %s" % str(result['error'])), MessageBoxExt.TYPE_INFO)
self.closeall()
else:
self.closeall()
def removetokens(self, answer):
if answer is True:
self.session.open(MessageBoxExt, _("Real-Debrid: AuthToken and AccessToken removed!"), MessageBoxExt.TYPE_INFO, timeout=5)
config.mediaportal.realdebrid_accesstoken.value = ''
config.mediaportal.realdebrid_accesstoken.save()
self.raccesstoken = ''
#.........这里部分代码省略.........