def playVideo(params): content=util.getURL(params['url'].encode('utf-8'), hdr) if content!=False: """if "https://openload" in content: xbmc.log("openload", xbmc.LOGERROR) download=util.extract(content, '<iframe src="https://openload', '"') openloadurl ='http://openload'+download.encode('utf-8') videourl=resolve(openloadurl) ol=util.getURL(openloadurl, hdr) videourl=util.extract(ol, '<source type="video/mp4" src="', '"') """ if 'videourl' not in locals() and "http://videowood.tv/embed/" in content: xbmc.log("videowood", xbmc.LOGERROR) download=util.extract(content, 'http://videowood.tv/embed/', '"') videowoodurl='http://videowood.tv/embed/'+download vw=util.getURL(videowoodurl, hdr) #xbmc.log(vw, xbmc.LOGERROR) videourls=util.extractAll(vw, "file: '", "',") for vid in videourls: if '.mp4' in vid: videourl=vid break try: videourl except: result="eval("+util.extract(vw, "eval(", "</script") xbmc.log(result, xbmc.LOGERROR) result=jsunpack.unpack(result) xbmc.log(result, xbmc.LOGERROR) if 'videourl' not in locals() and "videomega.tv" in content: xbmc.log("videomega", xbmc.LOGERROR) videosource=content if re.search("videomega.tv/iframe.js", videosource, re.DOTALL | re.IGNORECASE): hashref = re.compile("""javascript["']>ref=['"]([^'"]+)""", re.DOTALL | re.IGNORECASE).findall(videosource) elif re.search("videomega.tv/iframe.php", videosource, re.DOTALL | re.IGNORECASE): hashref = re.compile(r"iframe\.php\?ref=([^&]+)&", re.DOTALL | re.IGNORECASE).findall(videosource) else: hashkey = re.compile("""hashkey=([^"']+)""", re.DOTALL | re.IGNORECASE).findall(videosource) if len(hashkey) > 1: i = 1 hashlist = [] for x in hashkey: hashlist.append('Part ' + str(i)) i += 1 vmvideo = dialog.select('Multiple parts found', hashlist) hashkey = hashkey[vmvideo] else: hashkey = hashkey[0] hashpage = getHtml('http://videomega.tv/validatehash.php?hashkey='+hashkey, params['url'].encode('utf-8')) hashref = re.compile('ref="([^"]+)', re.DOTALL | re.IGNORECASE).findall(hashpage) videopage = getHtml('http://videomega.tv/view.php?ref='+hashref[0], params['url'].encode('utf-8')) videourl = re.compile('<source src="([^"]+)"', re.DOTALL | re.IGNORECASE).findall(videopage) videourl = videourl[0] xbmc.log(videourl, xbmc.LOGERROR) util.playMedia(params['name'], params['poster'],videourl, "Video")
def playVideo(params): content = util.getURL(params['url'], hdr) xbmc.log("0", xbmc.LOGERROR) if content != False: video = util.extract(content, '<div id="post_in">', '</div>') url = util.extract(video, '<iframe src="', '"') xbmc.log("0.5 URL > " + url, xbmc.LOGERROR) content2 = util.getURL(url, hdr) xbmc.log("1", xbmc.LOGERROR) if content2 != False: if '<iframe src="' in content2: url = util.extract(content2, '<iframe src="', '"') xbmc.log("2", xbmc.LOGERROR) content3 = util.getURL(url, hdr) if content3 != False: if '<iframe src="' in content3: url = util.extract(content3, '<iframe src="', '"') xbmc.log("3", xbmc.LOGERROR) content4 = util.getURL(url, hdr) if content4 != False: xbmc.log("4", xbmc.LOGERROR) url = util.extract(content4, "script.setAttribute('src', '", "'") content5 = util.getURL(url.decode('string_escape'), hdr) if content5 != False: mp4_240 = util.extract(content5, '"mp4_240":"', '"') mp4_360 = util.extract(content5, '"mp4_360":"', '"') mp4_720 = util.extract(content5, '"mp4_720":"', '"') mp4_1080 = util.extract( content5, '"mp4_1080":"', '"') if mp4_1080 != None: url = mp4_1080.replace("\\", "") elif mp4_720 != None: url = mp4_720.replace("\\", "") elif mp4_360 != None: url = mp4_360.replace("\\", "") elif mp4_240 != None: url = mp4_240.replace("\\", "") xbmc.log("FINAL: " + makeAscii(url), xbmc.LOGERROR) else: xbmc.log("1.5", xbmc.LOGERROR) if '<source src="' in content2: url = util.extract(content2, '<source src="', '"') elif "file: '" in content2: url = util.extract(content2, "file: '", "'") else: url = util.extract(content2, '<source src="', '"') util.playMedia(params['name'], params['poster'], url, "Video")
def playVideo(params): download=params['url'] ol=util.getURL('https://api.openload.io/1/file/dlticket?file='+download+fileInfo(), hdr) jsonResponse=json.loads(ol) if jsonResponse['status']!=200: util.alert(str(jsonResponse['msg'])) else: ol=util.getURL('https://api.openload.io/1/file/dl?file='+download+'&ticket='+jsonResponse['result']['ticket'], hdr) jsonResponse=json.loads(ol) if jsonResponse['status']!=200: util.alert(str(jsonResponse['msg'])) else: util.playMedia(params['name'], params['poster'],jsonResponse['result']['url'], "Video")
def playVideo(params): content=util.getURL(params['url'], hdr) xbmc.log("0", xbmc.LOGERROR) if content!=False: video=util.extract(content, '<div id="post_in">', '</div>') url=util.extract(video, '<iframe src="', '"') xbmc.log("0.5 URL > "+url, xbmc.LOGERROR) content2=util.getURL(url, hdr) xbmc.log("1", xbmc.LOGERROR) if content2!=False: if '<iframe src="' in content2 : url=util.extract(content2, '<iframe src="', '"') xbmc.log("2", xbmc.LOGERROR) content3=util.getURL(url, hdr) if content3!=False: if '<iframe src="' in content3 : url=util.extract(content3, '<iframe src="', '"') xbmc.log("3", xbmc.LOGERROR) content4=util.getURL(url, hdr) if content4!=False: xbmc.log("4", xbmc.LOGERROR) url=util.extract(content4, "script.setAttribute('src', '", "'") content5=util.getURL(url.decode('string_escape'), hdr) if content5!=False: mp4_240=util.extract(content5, '"mp4_240":"', '"') mp4_360=util.extract(content5, '"mp4_360":"', '"') mp4_720=util.extract(content5, '"mp4_720":"', '"') mp4_1080=util.extract(content5, '"mp4_1080":"', '"') if mp4_1080!=None: url=mp4_1080.replace("\\", "") elif mp4_720!=None: url=mp4_720.replace("\\", "") elif mp4_360!=None: url=mp4_360.replace("\\", "") elif mp4_240!=None: url=mp4_240.replace("\\", "") xbmc.log("FINAL: "+makeAscii(url), xbmc.LOGERROR) else: xbmc.log("1.5", xbmc.LOGERROR) if '<source src="' in content2: url=util.extract(content2, '<source src="', '"') elif "file: '" in content2: url=util.extract(content2, "file: '", "'") else: url=util.extract(content2, '<source src="', '"') util.playMedia(params['name'], params['poster'], url, "Video")
def showVideos(url, hdr): content=util.getURL(url, hdr) toReturn=[] if content!=False: gs = goslate.Goslate() allfilms=util.extract(content, '<div class="nag cf">', '<!-- end .loop-content -->') if allfilms!=None: films=util.extractAll(allfilms, '<div id="post-', '<!-- end #post-') for film in films: details=util.extract(film, '<div class="thumb">', '</div>') title=util.replaceHTMLCodes(util.extract(details, 'title="', ' href')) if '[' in title and ']' in title: videoCode=util.extract(title.encode("utf-8"), "[", "]") videoTitle=gs.translate(util.extract(title.encode('utf-8'), "]", '"'), 'en').title() title=util.makeAscii("["+videoCode+"] ")+videoTitle.encode('utf-8') plot="no plot" starring="no starring" studio="no studio" date="no date" url=util.extract(film, 'href="', '"') poster=util.extract(film, '<img src="', '" alt').replace("pl.jpg", "ps.jpg") fanart=poster.replace("ps.jpg", "pl.jpg") toReturn.append([title, plot, starring, studio, date, url, poster, fanart]) checkNext=util.extract(content, '<a class="nextpostslink" rel="next" href="', '"') if checkNext!=None: toReturn.append(['next', checkNext]) return toReturn
def getPopular(url, hdr): toReturn=[] content=util.getURL(url, hdr) if content!=False: gs = goslate.Goslate() popularFilms=util.extract(content, '<div id="dp-widget-posts-2" class="widget widget-posts">', '<!--end #sidebar-->') films=util.extractAll(popularFilms, '<div class="thumb">', '</div>') for film in films: title=util.extract(film, 'title="', 'href') if '[' in title and ']' in title: videoCode=util.extract(title.encode("utf-8"), "[", "]") videoTitle=gs.translate(util.extract(title.encode('utf-8'), "]", '"'), 'en').title() title=util.makeAscii("["+videoCode+"] ")+videoTitle.encode('utf-8') else: title=gs.translate(title.encode('utf-8').replace('"', ""), 'en').title() plot="no plot" starring="no starring" studio="no studio" date="no date" url=util.extract(film, 'href="', '"') poster=util.extract(film, '<img src="', '" alt') fanart=poster.replace("ps.jpg", "pl.jpg") toReturn.append([title, plot, starring, studio, date, url, poster, fanart]) return toReturn
def showVideos(url, hdr): content=util.getURL(url, hdr) toReturn=[] if content!=False: gs = goslate.Goslate() allfilms=util.extract(content, '<div class="items">', '<div class="lateral">') films=util.extractAll(allfilms, '<div class="item">', '<div class="item">') for film in films: title=util.replaceHTMLCodes(util.extract(film, '<h2>', 'h2>')) if '[' in title and ']' in title: videoCode=util.extract(title.encode("utf-8"), "[", "]") videoTitle=gs.translate(util.extract(title.encode('utf-8'), "]", '</'), 'en').title() title=util.makeAscii("["+videoCode+"] ")+videoTitle.encode('utf-8') else: title=gs.translate(title.encode('utf-8').replace("</", ""), 'en').title() plot="no plot" starring="no starring" studio="no studio" date="no date" url=util.extract(film, '<a href="', '"') poster=util.extract(film, '<img src="', '" alt') fanart=poster.replace("ps.jpg", "pl.jpg") toReturn.append([title, plot, starring, studio, date, url, poster, fanart]) if '<link rel="next" href="' in content: toReturn.append(["next", util.extract(content, '<link rel="next" href="', '"')]) return toReturn
def getPopular(url, hdr): param={'play':1} toReturn=[] content=util.getURL(url, hdr) if content!=False: gs = goslate.Goslate() popularFilms=util.extract(content, '<div id="slider1"', '<div class="peliculas">') films=util.extractAll(popularFilms, '<a href', '</a>') for film in films: title=util.extract(film, 'alt="', 'width=') if '[' in title and ']' in title: videoCode=util.extract(title.encode("utf-8"), "[", "]") videoTitle=gs.translate(util.extract(title.encode('utf-8'), "]", '"'), 'en').title() title=util.makeAscii("["+videoCode+"] ")+videoTitle.encode('utf-8') else: title=gs.translate(title.encode('utf-8').replace("width=", ""), 'en').title() plot="no plot" starring="no starring" studio="no studio" date="no date" url=util.extract(film, '="', '"') poster=util.extract(film, '<img src="', '" alt') fanart=poster.replace("ps.jpg", "pl.jpg") toReturn.append([title, plot, starring, studio, date, url, poster, fanart]) return toReturn
def getCategories(url): param = {'category': 1} content = util.getURL(url, hdr) if content != False: cats = util.extractAll(content, '<div class="item">', '<div class="item">') for film in cats: param['title'] = makeAscii(util.extract(film, 'title="', '"')) param['url'] = 'http://www.likuoo.com' + util.extract( film, '<a href="', '" title="') param['poster'] = util.extract(film, 'src="', '" title="') param['fanart'] = param['poster'] xbmc.log("Play URL:" + param['url'], xbmc.LOGERROR) if param['url'] != None: u = sys.argv[0] + "?url=" + param[ 'url'] + "&mode=2&name=" + urllib.quote_plus( param['title']) + "&poster=" + param['poster'] liz = xbmcgui.ListItem(param['title'], iconImage="DefaultVideo.png", thumbnailImage=param['poster']) liz.setInfo(type="Video", infoLabels={ "Title": param['title'], "Plot": "" }) liz.setProperty("Poster_Image", param['poster']) ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=True) xbmcplugin.endOfDirectory(int(sysarg))
def getVids(params) : param={'play':1} content=util.getURL(params['url'], hdr) if content!=False: films=util.extractAll(content, '<div class="item">', '<div class="item">') for film in films: param['title']=makeAscii(util.extract(film, 'title="', '"')) param['url']=util.extract(film, '<a href="', '" title="') param['poster']=util.extract(film, 'src="', '" title="') param['fanart']=param['poster'] if param['url']!=None: u=sys.argv[0]+"?url="+param['url']+"&play="+str(4)+"&name="+urllib.quote_plus(param['title'])+"&poster="+param['poster'] liz=xbmcgui.ListItem(param['title'], iconImage="DefaultVideo.png", thumbnailImage=param['poster']) liz.setInfo( type="Video", infoLabels={ "Title": param['title'],"Plot": ""} ) liz.setProperty("Poster_Image", param['poster']) ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True) next=util.extract(content, '<span class="current">', '</span>') #xbmc.log(">>>>>"+str(next), xbmc.LOGERROR) if next!=None: next=int(next)+1 #xbmc.log('http://www.likuoo.com/new/'+str(next), xbmc.LOGERROR) if 'http://www.likuoo.com/new/'+str(next) in content: util.addDir("Next >", 'http://www.likuoo.com/new/'+str(next), 2, "","") xbmcplugin.endOfDirectory(int(sysarg))
def newElem(type='post'): '''Create a new XML element. Args: type: The type of element to create (post or page). Returns: A default XML element of the given type. ''' now = datetime.datetime.utcnow() now = now.replace(microsecond = 0) nowSpace = now.isoformat(' ') slug = util.onlyAlphaNum(now.isoformat('_'),'-') filepath = util.getContentFilepath(now, slug) while os.path.exists(filepath): nowSpace = "%s0"%(nowSpace) slug = "%s0"%(slug) filepath = util.getContentFilepath(now, slug) item = { 'date': nowSpace, 'name': slug, 'title': nowSpace, 'type': type, 'status': 'hidden', 'filepath': util.getContentFilepath(now, slug), 'url': util.getURL(now, slug, type), 'parent': '', 'trash': '' } new_elem = ET.Element(type) updateElem(new_elem, item) return new_elem
def getCategories(params) : param={'categories':1} content=util.getURL(params['url'], hdr) if content!=False: contents=util.extract(content, '<ul class="small-block-grid-4 videos-cats">', '</ul>') films=util.extractAll(contents, '<li>', '</li>') for film in films: title=util.extract(film, '<div class="media-panel-title category-title">', '</div>') param['title']=util.extract(title, '">', '</a>') param['plot']=util.extract(film, '<div class="media-panel-info">', '</div>') param['url']=util.extract(title, '<a href="', '"') param['poster']=util.extract(film, '<img src="', '" />') param['fanart']=param['poster'] if param['url']!=None: u=sys.argv[0]+"?url="+param['url']+"&mode=2&name="+urllib.quote_plus(param['title'])+"&poster="+param['poster'] liz=xbmcgui.ListItem(param['title'], iconImage="DefaultVideo.png", thumbnailImage=param['poster']) liz.setInfo( type="Video", infoLabels={ "Title": param['title'],"Plot": param['plot']} ) liz.setProperty("Fanart_Image", param['fanart']) liz.setProperty("Landscape_Image", param['fanart']) liz.setProperty("Poster_Image", param['poster']) ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True) next=util.extract(content, '<div class="pagination">', '</div>') if next!=None: next=util.extract(next, '<li class="active">', '</a>') if next!=None: url=util.extract(next, '<a href="', '"') util.addDir("Next >", url, 2, "","") xbmcplugin.endOfDirectory(int(sysarg))
def auth(): xbmc.executebuiltin('ActivateWindow(10138)') authData = util.getURL( "https://api.real-debrid.com/oauth/v2/device/code?client_id=" + client_id + "&new_credentials=yes") authThread = threading.Thread(target=verifyThread, args=(authData, )) authThread.start()
def getGenres(url, hdr): content=util.getURL(url, hdr) if content!=False: allGenres=util.extract(content, '<ul class="scrolling cat">', '</ul>') genres=util.extractAll(allGenres, '<a href', 'a>') for genre in genres: util.addDir(util.extract(genre, '>', '</'), util.extract(genre, '="', '"'), 1, "") xbmcplugin.endOfDirectory(int(sysarg))
def playVideo(params): content=util.getURL(params['url'], hdr) if content!=False: vidID=util.extract(content, 'file: "http://videos.woodrocket.com/vid/', '.mp4", label: "480p"') source=util.extract(content, 'sources: [', '],') if 'label: "720p HD"' in source: util.playMedia(params['name'], params['poster'], "http://videos.woodrocket.com/vid/"+vidID+".hd.mp4", "Video") else: util.playMedia(params['name'], params['poster'], "http://videos.woodrocket.com/vid/"+vidID+".mp4", "Video")
def getStudios(url, hdr): content=util.getURL(url, hdr) if content!=False: studios=util.extractAll(content, '<a href="http://ivhunter.com/studios', 'a>') for studio in studios: if util.extract(studio, '">', '</')!="Studios": util.addDir(util.extract(studio, '">', '</'), "http://ivhunter.com/studios/"+util.extract(studio, '/', '/'), 1, "") xbmcplugin.endOfDirectory(int(sysarg))
def buildSubMenu(params): content=util.getURL('http://www.asianteensfor.me/javlist/blank/', hdr) if content!=False: xoxo=util.extract(content, '<ul id="'+params['url']+'">', '</ul>') subOptions=util.extractAll(xoxo, '<li class="cat-item', '</li>') for sub in subOptions: name=util.extract(sub, '/" >', '</a>') url=util.extract(sub, '<a href="', '" >') util.addDir(name, url, 5, "","") xbmcplugin.endOfDirectory(int(sysarg))
def getIdols(url, hdr): content=util.getURL(url, hdr) if content!=False: alphabet=util.extractAll(content, '<ul class="links">', '</ul>') for letter in alphabet: idols=util.extractAll(letter, '<li>', '</li>') for idol in idols: if util.makeAscii(util.extract(idol, 'title="', '"'))!="": util.addDir(util.makeAscii(util.extract(idol, 'title="', '"')), util.extract(idol, 'href="', '"').encode('utf-8'), 1, "") xbmcplugin.endOfDirectory(int(sysarg))
def getStars(params): content=util.getURL(params['url'], hdr) if content!=False: alphabet=util.extractAll(content, "<ul class='small-block-grid-5 stars'>", '</ul>') for letter in alphabet: stars=util.extractAll(letter, '<li>', '</li>') for star in stars: name=util.extract(star, '">', '</a>') url=util.extract(star, 'href="', '"') util.addDir(name, url, 2, "","") xbmcplugin.endOfDirectory(int(sysarg))
def getStars(params): content = util.getURL(params['url'], hdr) if content != False: alphabet = util.extractAll(content, "<ul class='small-block-grid-5 stars'>", '</ul>') for letter in alphabet: stars = util.extractAll(letter, '<li>', '</li>') for star in stars: name = util.extract(star, '">', '</a>') url = util.extract(star, 'href="', '"') util.addDir(name, url, 2, "", "") xbmcplugin.endOfDirectory(int(sysarg))
def getVids(url) : param={'play':1} content=util.getURL(url, hdr) if content!=False: films=util.extractAll(content, '<vid>', '</vid>') movielist = "[" currentrow = 0 itemlist = list() for film in films: param['title']=replaceHTMLCodes(util.extract(film, '<name>', '</name>')) param['plot']=makeAscii(replaceHTMLCodes(util.extract(film, '<plot>', '</plot>'))) param['starring']=makeAscii(replaceHTMLCodes(util.extract(film, '<starring>', '</starring>'))) param['studio']=makeAscii(replaceHTMLCodes(util.extract(film, '<studio>', '</studio>'))) param['date']=util.extract(film, '<date>', '</date>') param['url']=util.extract(film, '<url>', '</url>') param['poster']=util.extract(film, 'class="cover" src="', '" />') param['fanart']=util.extract(film, 'class="preview" src="', '" />') u=sys.argv[0]+"?url="+param['url']+"&play="+str(4)+"&name="+param['title']+"&poster="+param['poster'] liz=xbmcgui.ListItem(param['title'], iconImage="DefaultVideo.png", thumbnailImage=param['poster']) liz.setInfo( type="Video", infoLabels={ "Title": param['title'],"Plot": param['plot']} ) liz.setProperty("Fanart_Image", param['fanart']) liz.setProperty("Landscape_Image", param['fanart']) liz.setProperty("Poster_Image", param['poster']) #moo movielist += json.dumps({ 'title': param["title"], 'url': param["url"] }) + "," linkMenu = [] #reset item context menu for a reason linkMenu.append(('Download', 'RunPlugin(plugin://%s/?action=download&videoname=%s&videourl=%s)' % (ADDON_ID,param['title'],param['url']))) #liz.addContextMenuItems(linkMenu,replaceItems=True) entry = (u,liz,True,linkMenu); itemlist.append(entry) movielist = movielist[:-1] + "]" if len(itemlist) > 0: #movielist = urllib.unquote_plus(str(movielist)) settings.setSetting(id="movielist", value=movielist) for item in itemlist: linkMenu = item[3] linkMenu.append(('Download All', 'RunPlugin(plugin://%s/?action=downloadall)' % (ADDON_ID))) item[1].addContextMenuItems(linkMenu,replaceItems=True) del itemlist[-1] ok=xbmcplugin.addDirectoryItems(handle=int(sys.argv[1]),items=itemlist) if "Older posts" in content: next=util.extract(content, '<div id="next">', '</div>') url=util.extract(next, '"', '"') util.addDir("Next >", url, 5, "","") xbmcplugin.endOfDirectory(int(sysarg))
def buildMainMenu(): util.addDir("Recently Added","Recently Added", 2, "","") # get the rest of the menu items from the website, should be easier to update content=util.getURL('http://www.asianteensfor.me/javlist/blank/', hdr) if content!=False: xoxo=util.extract(content, '<ul class="xoxo">','</body>') headings=util.extractAll(xoxo, '<li id="lc_taxonomy-', '</ul></div></li>') for heading in headings: name=util.extract(heading, '<h3 class="widget-title">', '</h3>') url="lct-widget-"+name.lower() util.addDir(name, url, 3, "","") util.addDir("Search","Search", 4, "","") xbmcplugin.endOfDirectory(int(sysarg))
def getCategories(params): param = {'categories': 1} content = util.getURL(params['url'], hdr) if content != False: contents = util.extract(content, '<ul class="small-block-grid-4 videos-cats">', '</ul>') films = util.extractAll(contents, '<li>', '</li>') for film in films: title = util.extract( film, '<div class="media-panel-title category-title">', '</div>') param['title'] = util.extract(title, '">', '</a>') param['plot'] = util.extract(film, '<div class="media-panel-info">', '</div>') param['url'] = util.extract(title, '<a href="', '"') param['poster'] = util.extract(film, '<img src="', '" />') param['fanart'] = param['poster'] if param['url'] != None: u = sys.argv[0] + "?url=" + param[ 'url'] + "&mode=2&name=" + urllib.quote_plus( param['title']) + "&poster=" + param['poster'] liz = xbmcgui.ListItem(param['title'], iconImage="DefaultVideo.png", thumbnailImage=param['poster']) liz.setInfo(type="Video", infoLabels={ "Title": param['title'], "Plot": param['plot'] }) liz.setProperty("Fanart_Image", param['fanart']) liz.setProperty("Landscape_Image", param['fanart']) liz.setProperty("Poster_Image", param['poster']) ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=True) next = util.extract(content, '<div class="pagination">', '</div>') if next != None: next = util.extract(next, '<li class="active">', '</a>') if next != None: url = util.extract(next, '<a href="', '"') util.addDir("Next >", url, 2, "", "") xbmcplugin.endOfDirectory(int(sysarg))
def playVideo(params): content = util.getURL(params['url'], hdr) if content != False: vidID = util.extract(content, 'file: "http://videos.woodrocket.com/vid/', '.mp4", label: "480p"') source = util.extract(content, 'sources: [', '],') if 'label: "720p HD"' in source: util.playMedia( params['name'], params['poster'], "http://videos.woodrocket.com/vid/" + vidID + ".hd.mp4", "Video") else: util.playMedia( params['name'], params['poster'], "http://videos.woodrocket.com/vid/" + vidID + ".mp4", "Video")
def getCategories(url): param={'category':1} content=util.getURL(url, hdr) if content!=False: cats=util.extractAll(content, '<div class="item">', '<div class="item">') for film in cats: param['title']=makeAscii(util.extract(film, 'title="', '"')) param['url']='http://www.likuoo.com'+util.extract(film, '<a href="', '" title="') param['poster']=util.extract(film, 'src="', '" title="') param['fanart']=param['poster'] xbmc.log("Play URL:"+param['url'], xbmc.LOGERROR) if param['url']!=None: u=sys.argv[0]+"?url="+param['url']+"&mode=2&name="+urllib.quote_plus(param['title'])+"&poster="+param['poster'] liz=xbmcgui.ListItem(param['title'], iconImage="DefaultVideo.png", thumbnailImage=param['poster']) liz.setInfo( type="Video", infoLabels={ "Title": param['title'],"Plot": ""} ) liz.setProperty("Poster_Image", param['poster']) ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True) xbmcplugin.endOfDirectory(int(sysarg))
def getVids(params): param = {'play': 1} content = util.getURL(params['url'], hdr) if content != False: films = util.extractAll(content, '<div class="item">', '<div class="item">') for film in films: param['title'] = makeAscii(util.extract(film, 'title="', '"')) param['url'] = util.extract(film, '<a href="', '" title="') param['poster'] = util.extract(film, 'src="', '" title="') param['fanart'] = param['poster'] if param['url'] != None: u = sys.argv[0] + "?url=" + param['url'] + "&play=" + str( 4) + "&name=" + urllib.quote_plus( param['title']) + "&poster=" + param['poster'] liz = xbmcgui.ListItem(param['title'], iconImage="DefaultVideo.png", thumbnailImage=param['poster']) liz.setInfo(type="Video", infoLabels={ "Title": param['title'], "Plot": "" }) liz.setProperty("Poster_Image", param['poster']) ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=True) next = util.extract(content, '<span class="current">', '</span>') #xbmc.log(">>>>>"+str(next), xbmc.LOGERROR) if next != None: next = int(next) + 1 #xbmc.log('http://www.likuoo.com/new/'+str(next), xbmc.LOGERROR) if 'http://www.likuoo.com/new/' + str(next) in content: util.addDir("Next >", 'http://www.likuoo.com/new/' + str(next), 2, "", "") xbmcplugin.endOfDirectory(int(sysarg))
def formToItem(form, orig_item): '''Convert an EditForm object to an item. Args: form: Form to convert. orig_item: Original item to use for default values. Returns: An item. ''' keys = ['status','categories','name','title','tags','content'] if orig_item['type'] == 'page': keys.append('parent') item = dict((k, form.cleaned_data[k]) for k in keys) date = datetime.datetime.combine(form.cleaned_data['date'], form.cleaned_data['time']) item['date'] = date.isoformat(' ') item['url'] = util.getURL(date, item['name'], orig_item['type']) item['categories'] = util.cleanCSV(item['categories']) item['tags'] = util.cleanCSV(item['tags']) item['type'] = orig_item['type'] item['filepath'] = util.getContentFilepath(date, item['name']) return item
def verifyThread(authData): xbmc.executebuiltin('Dialog.Close(10138)') # convert string to JSON authJSON=json.loads(authData) # create dialog with progress to show information authMsg="To authorise your RealDebrid account, use a browser to browse to [B]"+authJSON['verification_url']+"[/B] and enter the verification code [B]"+authJSON['user_code']+"[/B]" authDialog=util.progressStart("RealDebrid Authentication", authMsg) authorised=False timer=0 credJSON="" while not authorised: time.sleep(2) timer=timer+2 util.progressUpdate(authDialog, timer, authMsg) # check if we need to exit if util.progressCancelled(authDialog)==True: util.progressStop(authDialog) break if timer==100: util.progressStop(authDialog) util.alert("RealDebrid aithentication has timed out. Please try again.") break # all good to carry on lets check auth credentials=util.getURL("https://api.real-debrid.com/oauth/v2/device/credentials?client_id="+client_id+"&code="+authJSON['device_code']) if credentials!=False: try: if "error" in credentials: util.logError(credentials) else: credJSON=json.loads(credentials) #store credentials in settings xbmcaddon.Addon().setSetting('rd_id', credJSON['client_id']) xbmcaddon.Addon().setSetting('rd_secret', credJSON['client_secret']) cj_rd = cookielib.CookieJar() opener_rd = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj_rd)) data_rd = urllib.urlencode({'client_id' : credJSON['client_id'], 'client_secret' : credJSON['client_secret'], 'code': authJSON['device_code'], 'grant_type' : 'http://oauth.net/grant_type/device/1.0'}) try: #util.logError(str(data_rd)) resp = opener_rd.open('https://api.real-debrid.com/oauth/v2/token', data_rd) content=resp.read() credJSON=json.loads(content) xbmcaddon.Addon().setSetting('rd_access', credJSON['access_token']) xbmcaddon.Addon().setSetting('rd_refresh', credJSON['refresh_token']) authorised=True except Exception as e: util.logError(str(e)) except Exception as e: util.logError(str(e)) # check how we exited loop util.progressStop(authDialog) if authorised==True: util.alert("RealDebrid authenticated.") return True else: util.alert("There was an error authenticating with RealDebrid") return False
def auth(): xbmc.executebuiltin('ActivateWindow(10138)') authData=util.getURL("https://api.real-debrid.com/oauth/v2/device/code?client_id="+client_id+"&new_credentials=yes") authThread=threading.Thread(target=verifyThread, args=(authData,)) authThread.start()
def fetch (self): """Retrieve the tile from the cache or load the cache and return""" try: # open file and return f = open(self.filename) self.db.touch (self.tkey) return f.read() except IOError: pass try: self.initForFetch() except OOBException: logger.warning("OOB request. Returning black tile. url={}".format(self.tile_url)) img = Image.new("L", (settings.TILESIZE, settings.TILESIZE)) fileobj = cStringIO.StringIO() img.save(fileobj, "PNG") fileobj.seek(0) return fileobj.read() from tasks import fetchcube # check if there is S3 backend and do the calls accordingly if self.ds.getS3Backend(): s3_backend = s3io.S3IO(self.ds, self.channels) cubedata = s3_backend.getCutout(self.cuboid_url) tile_data = cubedata[:, self.zslab_offset, : ,:] # fetchcube(self.token, self.slice_type, self.channels, self.colors, self.cuboid_url, cubedata) fetchcube.delay (self.token, self.slice_type, self.channels, self.colors, self.cuboid_url, cubedata) ch = self.ds.getChannelObj(self.channels[0]) # checking the channel type to process the data correctly if self.colors: img = mcfc.mcfcPNG (tile_data, self.colors) elif ch.getChannelType() in IMAGE_CHANNELS + TIMESERIES_CHANNELS: if ch.getChannelDataType() in DTYPE_uint8: img = Image.frombuffer('L', tile_data.shape[1:][::-1], tile_data.flatten(), 'raw', 'L', 0, 1) elif ch.getChannelDataType() in DTYPE_uint16: if ch.getWindowRange() != [0,0]: tile_data = np.uint8(tile_data) img = Image.frombuffer('L', tile_data.shape[1:][::-1], tile_data.flatten(), 'raw', 'L', 0, 1) else: img = Image.frombuffer ( 'I;16', tile_data.shape[1:][::-1], tile_data.flatten(), 'raw', 'I;16', 0, 1) img.point(lambda i:i*(1./256)).convert('L') elif ch.getChannelDataType() in DTYPE_uint32 : img = Image.fromarray( tile_data[0,:,:], 'RGBA') elif ch.getChannelType() in ANNOTATION_CHANNELS: tile_data = tile_data[0,:] ndlib.recolor_ctype(tile_data, tile_data) img = Image.frombuffer('RGBA', tile_data.shape[1:][::-1], tile_data.flatten(), 'raw', 'RGBA', 0, 1) fileobj = cStringIO.StringIO() img.save ( fileobj, "PNG" ) fileobj.seek(0) return fileobj.read() else: # call the celery process to fetch the url #fetchurl (self.token, self.slice_type, self.channels, self.colors, self.cuboid_url) fetchcube.delay (self.token, self.slice_type, self.channels, self.colors, self.cuboid_url) # fetchcube (self.token, self.slice_type, self.channels, self.colors, self.cuboid_url) logger.warning("Tile fetch {}".format(self.tile_url)) return getURL(self.tile_url).read()
# ensure only one request of a cube at a time try: self.ds.db.fetchlock(cuboid_url) except Exception, e: logger.warning("Already fetching {}. Returning.".format(cuboid_url)) return # try block to ensure that we call fetchrelease try: if not self.ds.getS3Backend(): try: # Get cube in question # cube_data = test.getCutout(cuboidurl) # get the cutout data cube_data = blosc.unpack_array(getURL(cuboid_url).read()) except urllib2.URLError, e: # release the fetch lock self.ds.db.fetchrelease(cuboid_url) logger.error("Could not fetch the cuboid {}".format(cuboid_url)) raise NDTILECACHEError("Could not fetch the cuboid {}".format(cuboid_url)) # properties [ximagesize, yimagesize, zimagesize] = self.ds.imagesz[res] (xdim, ydim, zdim) = self.ds.cubedim[res] (xsuperdim, ysuperdim, zsuperdim) = self.ds.supercubedim[res] [xoffset, yoffset, zoffset] = self.ds.offset[res] scale = self.ds.scale[res][self.slice_type] if xmax == ximagesize or ymax == yimagesize or zmax == zimagesize:
def resolve(url): html=util.getURL(url, hdr) try: O = { '___': 0, '$$$$': "f", '__$': 1, '$_$_': "a", '_$_': 2, '$_$$': "b", '$$_$': "d", '_$$': 3, '$$$_': "e", '$__': 4, '$_$': 5, '$$__': "c", '$$_': 6, '$$$': 7, '$___': 8, '$__$': 9, '$_': "constructor", '$$': "return", '_$': "o", '_': "u", '__': "t", } result = re.search('<video.*?<script[^>]*>(.*?)</script>.*?</video>', html, re.DOTALL).group(1) result = result.replace(' ','') decodetest = re.search(r"decodeURIComponent\('([^']+)'\)", result, re.DOTALL).group(1) decoderesult = "'" + urllib2.unquote(decodetest).decode('utf8') + "'" result = re.sub(r"(?si)decodeURIComponent\('[^']+'\)", decoderesult, result) result = jsunpack.unpack(result) result = re.search('O\.\$\(O\.\$\((.*?)\)\(\)\)\(\);', result, re.DOTALL | re.IGNORECASE) s1 = result.group(1) s1 = s1.replace('\'+\'', '') s1 = s1.replace(' ', '') s1 = s1.replace('\n', '') s1 = s1.replace('\r', '') s1 = s1.replace('\t', '') s1 = s1.replace('(![]+"")', 'false') s1 = s1.replace('\\\\', '\\') s3 = '' for s2 in s1.split('+'): if s2.startswith('o.'): s3 += str(O[s2[2:]]) elif '[' in s2 and ']' in s2: key = s2[s2.find('[') + 3:-1] s3 += s2[O[key]] else: s3 += s2[1:-1] s3 = s3.replace('\\\\', '\\') s3 = s3.decode('unicode_escape') s3 = s3.replace('\\/', '/') s3 = s3.replace('\\\\"', '"') s3 = s3.replace('\\"', '"') url = re.search('<source.*?src="([^"]+)', s3).group(1) return url except: return "error"
def verifyThread(authData): xbmc.executebuiltin('Dialog.Close(10138)') # convert string to JSON authJSON = json.loads(authData) # create dialog with progress to show information authMsg = "To authorise your RealDebrid account, use a browser to browse to [B]" + authJSON[ 'verification_url'] + "[/B] and enter the verification code [B]" + authJSON[ 'user_code'] + "[/B]" authDialog = util.progressStart("RealDebrid Authentication", authMsg) authorised = False timer = 0 credJSON = "" while not authorised: time.sleep(2) timer = timer + 2 util.progressUpdate(authDialog, timer, authMsg) # check if we need to exit if util.progressCancelled(authDialog) == True: util.progressStop(authDialog) break if timer == 100: util.progressStop(authDialog) util.alert( "RealDebrid aithentication has timed out. Please try again.") break # all good to carry on lets check auth credentials = util.getURL( "https://api.real-debrid.com/oauth/v2/device/credentials?client_id=" + client_id + "&code=" + authJSON['device_code']) if credentials != False: try: if "error" in credentials: util.logError(credentials) else: credJSON = json.loads(credentials) #store credentials in settings xbmcaddon.Addon().setSetting('rd_id', credJSON['client_id']) xbmcaddon.Addon().setSetting('rd_secret', credJSON['client_secret']) cj_rd = cookielib.CookieJar() opener_rd = urllib2.build_opener( urllib2.HTTPCookieProcessor(cj_rd)) data_rd = urllib.urlencode({ 'client_id': credJSON['client_id'], 'client_secret': credJSON['client_secret'], 'code': authJSON['device_code'], 'grant_type': 'http://oauth.net/grant_type/device/1.0' }) try: #util.logError(str(data_rd)) resp = opener_rd.open( 'https://api.real-debrid.com/oauth/v2/token', data_rd) content = resp.read() credJSON = json.loads(content) xbmcaddon.Addon().setSetting('rd_access', credJSON['access_token']) xbmcaddon.Addon().setSetting('rd_refresh', credJSON['refresh_token']) authorised = True except Exception as e: util.logError(str(e)) except Exception as e: util.logError(str(e)) # check how we exited loop util.progressStop(authDialog) if authorised == True: util.alert("RealDebrid authenticated.") return True else: util.alert("There was an error authenticating with RealDebrid") return False