我们从Python开源项目中,提取了以下16个代码示例,用于说明如何使用xbmcplugin.SORT_METHOD_VIDEO_TITLE。
def MyRecordings(url,group): net.set_cookies(cookie_jar) url='http://www.filmon.com/my/recordings' html = net.http_GET(url).content link = html.encode('ascii', 'ignore') match=re.compile('"stream_url":"(.+?),"stream_name":"(.+?)","id":".+?","title":"(.+?)","description":"(.+?)","channel_id":"(.+?)"').findall(link) for a, playPath, name, description, channel in match: url1=str(a).replace('\/','/') url2=str(a).replace('\/','/').replace('"','') regex = re.compile('rtmp://(.+?)/(.+?)/(.+?)/(.+?)/(.+?)/(.+?)/(.+?)"') match1 = regex.search(url1) try: app = '%s/%s/%s/%s/%s/%s' %(match1.group(2), match1.group(3),match1.group(4),match1.group(5),match1.group(6),match1.group(7)) except: app='' tcUrl=str(url2) iconimage='https://static.filmon.com/couch/channels/%s/big_logo.png' % str(channel) swfUrl= 'http://www.filmon.com/tv/modules/FilmOnTV/files/flashapp/filmon/FilmonPlayer.swf' pageUrl = 'http://www.filmon.com/my/recordings' url= str(url2)+'/'+str(playPath)+' playpath='+str(playPath)+' app='+str(app)+' swfUrl='+str(swfUrl)+' tcUrl='+str(tcUrl)+' pageurl='+str(pageUrl) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE) addLink(name,url,iconimage,playPath,app,pageUrl,swfUrl,tcUrl,description) setView('movies', 'epg')
def TG4_CATCHUP(name): link= OPEN_URL('http://www.tg4.ie/wp-content/themes/tg4-starter/assets/json/tg4data.json')#.encode('utf8') #print link.encode('ascii','ignore') import json data=json.loads(link) uniques=[] for field in data: id= field['id'] iconimage=field['videoStillURL'] description=htmlcleaner.cleanUnicode(field['shortDescription']) name=htmlcleaner.cleanUnicode(field['customFields']['seriestitle']) if name not in uniques: uniques.append(name) try:addDir(name,'url',12,iconimage,description) except:pass xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE)
def GetContent(url): CHANNEL = url xunity='http://vschedules.uktv.co.uk/mobile/v2/most_popular?channel=%s&carousel_limit=100&platform=ios&app_ver=4.1.0' % CHANNEL response=OPEN_URL(xunity) link=json.loads(response) #data=link['brands'] for field in link: name= field['brand_name'].encode("utf-8") iconimage= field['brand_image'].encode("utf-8") channel=field['channel'].encode("utf-8") try:desc=field['teaser_text'].encode("utf-8") except:desc='' brand_id=field['brand_id'] if CHANNEL in channel: addDir(name.strip(),str(brand_id),2,iconimage,desc) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE) setView('movies', 'default')
def GetCat(url): xunity='http://vschedules.uktv.co.uk/mobile/v2/genres?platform=ios&app_ver=4.1.0' response=OPEN_URL(xunity) link=json.loads(response) #data=link['data'] for field in link: name= field['title'].encode("utf-8") iconimage= field['image'].encode("utf-8") brand_id=field['name'] addDir(name.strip(),str(brand_id),4,iconimage,'') xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE) setView('movies', 'default')
def GetEpisodes(url): xunity='http://vschedules.uktv.co.uk/mapi/branddata/?format=json&brand_id='+url response=OPEN_URL(xunity) link=json.loads(response) data=link['videos'] for field in data: name= 'S'+field['series_txt']+'E'+field['episode_txt']+' - '+field['brand_name'].encode("utf-8") iconimage= field['episode_img_cached'].encode("utf-8") channel=field['channel'].encode("utf-8") desc=field['teaser_text'].encode("utf-8") brightcove=field['brightcove_video_id'] addDir(name,str(brightcove),200,iconimage,desc) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE) setView('movies', 'default')
def LIST_MOVIES(filter='', value=False, sortcol=False, sortaz=True, search=False, cmmode=0): import movies as moviesDB if 'year' in filter: value = value.replace('0 -', '') movies = moviesDB.loadMoviedb(movie_filter=filter, value=value, sortcol=sortcol) count = 0 for moviedata in movies: count += 1 ADD_MOVIE_ITEM(moviedata, cmmode=cmmode) if not search: if sortaz: if 'year' not in filter: xbmcplugin.addSortMethod(common.pluginhandle, xbmcplugin.SORT_METHOD_VIDEO_TITLE) xbmcplugin.addSortMethod(common.pluginhandle, xbmcplugin.SORT_METHOD_VIDEO_YEAR) xbmcplugin.addSortMethod(common.pluginhandle, xbmcplugin.SORT_METHOD_VIDEO_RUNTIME) xbmcplugin.addSortMethod(common.pluginhandle, xbmcplugin.SORT_METHOD_VIDEO_RATING) xbmcplugin.addSortMethod(common.pluginhandle, xbmcplugin.SORT_METHOD_DURATION) xbmcplugin.addSortMethod(common.pluginhandle, xbmcplugin.SORT_METHOD_STUDIO_IGNORE_THE) common.SetView('movies') return count
def Channels(url,name,group): r='<li class="channel i-box-sizing".+?channel_id="(.+?)">.+?"channel_logo" src="(.+?)" title="(.+?)"' net.set_cookies(cookie_jar) html = OPEN_URL('http://www.filmon.com'+url) match=re.compile(r,re.DOTALL).findall(html) for id , iconimage , name in match: addDir(name,'http://www.filmon.com'+url.replace('channel','tv'),2,iconimage,id,group) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE) setView('movies', 'default') #GA('None',group)
def filmon_epg(url,group): url1='http://www.filmon.com/tvguide/' html = net.http_GET(url1).content link1 = html.encode('ascii', 'ignore') link=str(link1).replace('\n','') match=re.compile('bottom">(.+?)</h3>.+?href="(.+?)" > <img src="(.+?)".+?.+?div class="title">.+?</div>.+?h4>(.+?)/h4>.+?"description">(.+?)/div>').findall(link) for name, url1, iconimage, showname, description in match: cleandesc=str(description).replace('",','').replace(' ','').replace('<a class="read-more" href="/tvguide/','').replace('">Read more... →</a>','').replace('\xc3','').replace('\xa2','').replace('\xe2','').replace('\x82','').replace('\xac','').replace('\x84','').replace('\xa2s','').replace('\xc2','').replace('\x9d','').replace('<','') showname = str(showname).replace('<','') description = '[B]%s [/B]\n\n%s' % (showname,cleandesc) url = 'http://www.filmon.com'+str(url1) addDir(name,url,2,iconimage,description,'TV Guide') xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE) setView('movies', 'epg')
def GetCatList(url): xunity='http://vschedules.uktv.co.uk/mobile/v2/genre_items?genre_name=%s&platform=ios&app_ver=4.1.0' % url.upper() response=OPEN_URL(xunity) link=json.loads(response) #data=link['data'] for field in link: count=field['video_count'] channel=field['channel'].encode("utf-8") color='grey' if 'Dave' in channel: color='green' if 'Drama' in channel: color='red' if 'Yesterday' in channel: color='yellow' if 'Really' in channel: color='orange' name= field['brand_name'].encode("utf-8") + ' (%s Episodes) - [COLOR %s]%s[/COLOR]' % (str(count),color,channel) iconimage= field['brand_image'].encode("utf-8") brand_id=field['brand_id'] addDir(name.strip(),str(brand_id),2,iconimage,'') xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE) setView('movies', 'default')
def AtoZ(): nameurl=[] urlurl=[] for name in char_range('A', 'Z'): nameurl.append(name) urlurl.append(name.upper()) URL = 'http://vschedules.uktv.co.uk/mobile/v2/brand_list?channel=&letter=%s&&platform=ios&app_ver=4.1.0' % urlurl[xbmcgui.Dialog().select('Please Select', nameurl)] response=OPEN_URL(URL) link=json.loads(response) for field in link: count=field['video_count'] channel=field['channel'].encode("utf-8") color='grey' if 'Dave' in channel: color='green' if 'Drama' in channel: color='red' if 'Yesterday' in channel: color='yellow' if 'Really' in channel: color='orange' name= field['brand_name'].encode("utf-8") + ' (%s Episodes) - [COLOR %s]%s[/COLOR]' % (str(count),color,channel) iconimage= field['brand_image'].encode("utf-8") brand_id=field['brand_id'] addDir(name.strip(),str(brand_id),2,iconimage,'') xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE) setView('movies', 'default')
def parse_listas(item, patron): logger.info() # Descarga la pagina headers = {"X-Requested-With": "XMLHttpRequest"} data = httptools.downloadpage(item.url, headers=headers).data logger.debug("data="+data) # Extrae las entradas (carpetas) json_object = jsontools.load_json(data) logger.debug("html="+json_object["html"]) data = json_object["html"] matches = re.compile(patron,re.DOTALL).findall(data) itemlist = [] for scrapedurl,scrapedtitle,scrapeduser,scrapedfichas in matches: title = scrapertools.htmlclean(scrapedtitle + ' (' + scrapedfichas + ' fichas, por ' + scrapeduser + ')') url = urlparse.urljoin(item.url,scrapedurl) + "/offset/0/loadmedia" thumbnail = "" itemlist.append( Item(channel=item.channel, action="lista" , title=title , url=url)) logger.debug("title=["+title+"], url=["+url+"], thumbnail=["+thumbnail+"]") nextpage = scrapertools.find_single_match(data,'data-url="(/lists/loadlists/offset/[^"]+)"') if nextpage != '': url = urlparse.urljoin(item.url,nextpage) itemlist.append( Item(channel=item.channel, action="listas_sigues" , title=">> Página siguiente" , extra=item.extra, url=url)) try: import xbmcplugin xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_UNSORTED) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE) except: pass return itemlist
def CATEGORIES(): EST =Zone(0,False,'GMT') EST= datetime.now(EST).strftime('%Y-%m-%dT%H:%M:%S') URL='http://api.tvplayer.com/api/v2/epg/?service=1&platform=ios-staging&from=%s&hours=1' %str(EST) response=OPEN_URL(URL) link=json.loads(response) data=link['tvplayer']['response']['channels'] uniques=[] for field in data: id= str(field['id']) name= field['name'] icon= field['logo']['colour'] title=field['programmes'][0]['title'] GENRE=field["genre"] try:desc=field['programmes'][0]['synopsis'].encode("utf-8") except:desc='' if field['type']=='free': add='' else: add=' [COLOR magenta] - (Premium)[/COLOR]' name = '[COLOR royalblue]'+name.encode("utf-8")+'[/COLOR] - [COLOR white]'+title.encode("utf-8")+'[/COLOR]'+add status = field['status'] fanart=field['programmes'][0]['thumbnail'] if status=='online': if ADDON.getSetting('genre')== 'false': if ADDON.getSetting('premium')== 'true': addDir(name,id,200,icon,desc,fanart,GENRE) else: if field['type']=='free': addDir(name,id,200,icon,desc,fanart,GENRE) else: if GENRE not in uniques: uniques.append(GENRE) addDir(GENRE,'url',2,'',GENRE,'') if ADDON.getSetting('sort')== 'true': xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE) setView('movies', 'default')
def setView(content, viewType): ''' Why recode whats allready written and works well, Thanks go to Eldrado for it ''' if content: xbmcplugin.setContent(int(sys.argv[1]), content) if ADDON.getSetting('auto-view') == 'true': print ADDON.getSetting(viewType) if ADDON.getSetting(viewType) == 'Info': VT = '504' elif ADDON.getSetting(viewType) == 'Info2': VT = '503' elif ADDON.getSetting(viewType) == 'Info3': VT = '515' elif ADDON.getSetting(viewType) == 'Fanart': VT = '508' elif ADDON.getSetting(viewType) == 'Poster Wrap': VT = '501' elif ADDON.getSetting(viewType) == 'Big List': VT = '51' elif ADDON.getSetting(viewType) == 'Low List': VT = '724' elif ADDON.getSetting(viewType) == 'List': VT = '50' elif ADDON.getSetting(viewType) == 'Default Menu View': VT = ADDON.getSetting('default-view1') elif ADDON.getSetting(viewType) == 'Default TV Shows View': VT = ADDON.getSetting('default-view2') elif ADDON.getSetting(viewType) == 'Default Episodes View': VT = ADDON.getSetting('default-view3') elif ADDON.getSetting(viewType) == 'Default Movies View': VT = ADDON.getSetting('default-view4') elif ADDON.getSetting(viewType) == 'Default Docs View': VT = ADDON.getSetting('default-view5') elif ADDON.getSetting(viewType) == 'Default Cartoons View': VT = ADDON.getSetting('default-view6') elif ADDON.getSetting(viewType) == 'Default Anime View': VT = ADDON.getSetting('default-view7') xbmc.executebuiltin("Container.SetViewMode(%s)" % ( int(VT) ) ) xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_UNSORTED ) xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_TITLE ) xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_VIDEO_TITLE )
def parse_mixed_results(item,data): patron = '<a class="defaultLink extended" href="([^"]+)"[^<]+' patron += '<div class="coverMini shadow tiptip" title="([^"]+)"[^<]+' patron += '<img class="centeredPic.*?src="([^"]+)"' patron += '[^<]+<img[^<]+<div class="extra-info">' patron += '<span class="year">([^<]+)</span>' patron += '<span class="value"><i class="icon-star"></i>([^<]+)</span>' matches = re.compile(patron,re.DOTALL).findall(data) itemlist = [] for scrapedurl,scrapedtitle,scrapedthumbnail,scrapedyear,scrapedvalue in matches: title = scrapertools.htmlclean(scrapedtitle) if scrapedyear != '': title += " ("+scrapedyear+")" fulltitle = title if scrapedvalue != '': title += " ("+scrapedvalue+")" thumbnail = urlparse.urljoin(item.url,scrapedthumbnail) fanart = thumbnail.replace("mediathumb","mediabigcover") plot = "" #http://www.pordede.com/peli/the-lego-movie #http://www.pordede.com/links/view/slug/the-lego-movie/what/peli?popup=1 if "/peli/" in scrapedurl or "/docu/" in scrapedurl: #sectionStr = "peli" if "/peli/" in scrapedurl else "docu" if "/peli/" in scrapedurl: sectionStr = "peli" else: sectionStr = "docu" referer = urlparse.urljoin(item.url,scrapedurl) url = referer.replace("/{0}/".format(sectionStr),"/links/view/slug/")+"/what/{0}".format(sectionStr) logger.debug("title=["+title+"], url=["+url+"], thumbnail=["+thumbnail+"]") itemlist.append( Item(channel=item.channel, action="findvideos" , title=title , extra=referer, url=url, thumbnail=thumbnail, plot=plot, fulltitle=fulltitle, fanart=fanart, contentTitle=scrapedtitle, contentType="movie", context=["buscar_trailer"])) else: referer = item.url url = urlparse.urljoin(item.url,scrapedurl) itemlist.append( Item(channel=item.channel, action="episodios" , title=title , extra=referer, url=url, thumbnail=thumbnail, plot=plot, fulltitle=fulltitle, show=title, fanart=fanart, contentTitle=scrapedtitle, contentType="tvshow", context=["buscar_trailer"])) next_page = scrapertools.find_single_match(data, '<div class="loadingBar" data-url="([^"]+)"') if next_page != "": url = urlparse.urljoin("http://www.pordede.com", next_page) itemlist.append( Item(channel=item.channel, action="lista", title=">> Página siguiente", extra=item.extra, url=url)) try: import xbmcplugin xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_UNSORTED) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE) except: pass return itemlist
def parse_listas(item, bloque_lista): logger.info() if item.tipo == "populares": patron = '<div class="lista(.*?)</div>\s*</h4>' else: patron = '<div class="lista(.*?)</h4>\s*</div>' matches = re.compile(patron,re.DOTALL).findall(bloque_lista) itemlist = [] for lista in matches: scrapedurl = scrapertools.htmlclean(scrapertools.find_single_match(lista,'<a href="([^"]+)">[^<]+</a>')) scrapedtitle = scrapertools.find_single_match(lista, '<a href="[^"]+">([^<]+)</a>') scrapedfollowers = scrapertools.find_single_match(lista, 'Follow: <span class="number">([^<]+)') scrapedseries = scrapertools.find_single_match(lista, '<div class="lista-stat badge">Series: ([^<]+)') scrapedpelis = scrapertools.find_single_match(lista, '<div class="lista-stat badge">Pelis: ([^<]+)') title = scrapertools.htmlclean(scrapedtitle) + ' (' if scrapedpelis != '': title += scrapedpelis + ' pelis, ' if scrapedseries != '': title += scrapedseries + ' series, ' if scrapedfollowers != '': title += scrapedfollowers+' seguidores' title += ')' url = urlparse.urljoin("https://www.plusdede.com",scrapedurl) thumbnail = "" itemlist.append( Item(channel=item.channel, action="peliculas" , token=item.token, tipo="lista", title=title , url=url)) logger.debug("title=["+title+"], url=["+url+"], thumbnail=["+thumbnail+"], tipo =[lista]") nextpage = scrapertools.find_single_match(bloque_lista,'<div class="onclick load-more-icon no-json" data-action="replace" data-url="([^"]+)"') if nextpage != '': url = urlparse.urljoin("https://www.plusdede.com",nextpage) itemlist.append( Item(channel=item.channel, action="lista_sig", tipo=item.tipo , title=">> Página siguiente" , extra=item.extra, url=url)) try: import xbmcplugin xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_UNSORTED) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE) except: pass return itemlist
def parse_listas(item, bloque_lista): logger.info() if item.tipo == "populares": patron = '<div class="lista(.*?)</div>\s*</h4>' else: patron = '<div class="lista(.*?)</h4>\s*</div>' matches = re.compile(patron, re.DOTALL).findall(bloque_lista) itemlist = [] for lista in matches: scrapedurl = scrapertools.htmlclean(scrapertools.find_single_match(lista, '<a href="([^"]+)">[^<]+</a>')) scrapedtitle = scrapertools.find_single_match(lista, '<a href="[^"]+">([^<]+)</a>') scrapedfollowers = scrapertools.find_single_match(lista, 'Follow: <span class="number">([^<]+)') scrapedseries = scrapertools.find_single_match(lista, '<div class="lista-stat badge">Series: ([^<]+)') scrapedpelis = scrapertools.find_single_match(lista, '<div class="lista-stat badge">Pelis: ([^<]+)') title = scrapertools.htmlclean(scrapedtitle) + ' (' if scrapedpelis != '': title += scrapedpelis + ' pelis, ' if scrapedseries != '': title += scrapedseries + ' series, ' if scrapedfollowers != '': title += scrapedfollowers + ' seguidores' title += ')' url = urlparse.urljoin("https://www.plusdede.com", scrapedurl) thumbnail = "" itemlist.append( Item(channel=item.channel, action="peliculas", token=item.token, tipo="lista", title=title, url=url)) nextpage = scrapertools.find_single_match(bloque_lista, '<div class="onclick load-more-icon no-json" data-action="replace" data-url="([^"]+)"') if nextpage != '': url = urlparse.urljoin("https://www.plusdede.com", nextpage) itemlist.append(Item(channel=item.channel, action="lista_sig", token=item.token, tipo=item.tipo, title=">> Página siguiente", extra=item.extra, url=url)) try: import xbmcplugin xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_UNSORTED) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE) except: pass return itemlist