def letvSearchList(name, page): p_url = 'http://open.api.letv.com/ms?hl=1&dt=2&ph=420001&from=pcjs&pn=%s&ps=30&wd=%s' p_url = p_url % (page, urllib.quote(name)) link = getHttpData(p_url) li = xbmcgui.ListItem('[COLOR FFFF0000]当前搜索: 第' + page + '页[/COLOR][COLOR FFFFFF00] (' + name + ')[/COLOR]【[COLOR FF00FF00]' + '点此输入新搜索内容' + '[/COLOR]】') u = sys.argv[0] + "?mode=31&name=" + urllib.quote_plus( name) + "&page=" + page xbmcplugin.addDirectoryItem(int(sys.argv[1]), u, li, True) if link == None: li = xbmcgui.ListItem(' 抱歉,没有找到[COLOR FFFF0000] ' + name + ' [/COLOR]的相关视频') xbmcplugin.addDirectoryItem(int(sys.argv[1]), u, li, False) xbmcplugin.endOfDirectory(int(sys.argv[1])) return # fetch and build the video series episode list content = simplejson.loads(link) vlist = content['data_list'] totalItems = len(vlist) for i in range(0, totalItems): vid = str(vlist[i]['vid']) v_url = 'http://www.letv.com/ptv/vplay/%s.html' % vid p_title = vlist[i]['name'].encode('utf-8') try: p_thumb = vlist[i]['images']['150*200'] except KeyError: p_thumb = vlist[i]['images']['160*120'] except: pass p_categoryName = vlist[i]['categoryName'] if (p_categoryName != None): p_list = p_name = str( i + 1) + '. [COLOR FF00FFFF][' + p_categoryName.encode( 'utf-8') + '][/COLOR] ' + p_title + ' ' else: p_list = p_name = str(i + 1) + '. ' + p_title + ' ' try: p_rating = float(vlist[i]['rating']) if (p_rating != None and p_rating > 0.01): p_rating = "%0.1f" % p_rating p_list += '[COLOR FFFF00FF][' + p_rating + '][/COLOR]' except: pass p_dx = int(vlist[i]['duration']) if (p_dx != None): p_duration = "[%02d:%02d]" % (int(p_dx / 60), (p_dx % 60)) p_list += '[COLOR FFFFFF00]' + p_duration + '[/COLOR]' p_artists = vlist[i]['actor'] if ((p_artists != None) and len(p_artists)): p_artist = "" p_list += '[' for key in p_artists: p_artist += p_artists[key].encode('utf-8') + ' ' p_list += p_artist[:-1] + ']' li = xbmcgui.ListItem(p_list, iconImage='', thumbnailImage=p_thumb) u = sys.argv[0] + "?mode=10" + "&name=" + urllib.quote_plus( p_list) + "&url=" + urllib.quote_plus( v_url) + "&thumb=" + urllib.quote_plus(p_thumb) xbmcplugin.addDirectoryItem(int(sys.argv[1]), u, li, False, totalItems) # Fetch and build page selection menu p_itemCount = content['video_count'] p_pageSize = 30 p_pageTotal = (p_itemCount + 29) / p_pageSize p_pageMid = int(p_pageTotal / 2) p_pageNum = int(page) if (p_pageNum <= p_pageMid): p_pageEnd = min(8, p_pageTotal) pages = range(0, p_pageEnd) p_pageFromEnd = max((p_pageTotal - 2), (p_pageEnd + 1)) else: pages = range(2) p_pageFromEnd = max((p_pageTotal - 8), 2) for x in range(p_pageFromEnd, p_pageTotal): pages.append(x) for num in pages: page = num + 1 if (page) != p_pageNum: li = xbmcgui.ListItem("... 第" + str(page) + "页") u = sys.argv[0] + "?mode=32" + "&name=" + urllib.quote_plus( name) + "&page=" + str(page) xbmcplugin.addDirectoryItem(int(sys.argv[1]), u, li, True) xbmcplugin.setContent(int(sys.argv[1]), 'movies') xbmcplugin.endOfDirectory(int(sys.argv[1]))
def getEpisodes(geurl, showName): xbmcplugin.setContent(int(sys.argv[1]), 'episodes') xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_UNSORTED) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_TITLE) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_YEAR) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_EPISODE) ilist = [] html = getRequest('http://www.travelchannel.com%s' % uqp(geurl)) c = re.compile("data\-videoplaylist\-data='(.+?)'>", re.DOTALL).findall(html) mode = 'GV' for a in c: b = json.loads(a) url = b['releaseUrl'] html = getRequest(url) name = h.unescape(b['title']) fanart = 'http://www.travelchannel.com%s' % b['thumbnailUrl'] thumb = 'http://www.travelchannel.com%s' % b['thumbnailUrl'] infoList = {} infoList['Duration'] = b['length'] infoList['Title'] = name infoList['Studio'] = b['publisherId'] months = { 'Jan': '01', 'Feb': '02', 'Mar': '03', 'Apr': '04', 'May': '05', 'Jun': '06', 'Jul': '07', 'Aug': '08', 'Sep': '09', 'Oct': '10', 'Nov': '11', 'Dec': '12' } try: dstr = (re.compile('"premierDate" value="(.+?)"', re.DOTALL).search(html).group(1)).split(' ') dt = '%s-%s-%s' % (dstr[5], months[dstr[1]], dstr[2]) infoList['Date'] = dt infoList['Aired'] = infoList['Date'] except: pass try: infoList['MPAA'] = re.compile( 'ratings="(.+?)"', re.DOTALL).search(html).group(1).split(':', 1)[1] except: infoList['MPAA'] = None try: infoList['Episode'] = int( re.compile('"episodeNumber" value=".(.+?)H"', re.DOTALL).search(html).group(1).replace('Z', ''), 16) except: infoList['Episode'] = None try: infoList['Season'] = int( re.compile('"episodeNumber" value="(.+?)H"', re.DOTALL).search(html).group(1).replace('Z', ''), 16) / 256 except: infoList['Season'] = 1 infoList['Plot'] = h.unescape(b["description"]) infoList['TVShowTitle'] = showName u = '%s?url=%s&name=%s&mode=%s' % (sys.argv[0], qp(url), qp(name), mode) liz = xbmcgui.ListItem(name, '', icon, thumb) liz.setInfo('Video', infoList) liz.addStreamInfo('video', { 'codec': 'avc1', 'width': 1280, 'height': 720, 'aspect': 1.78 }) liz.addStreamInfo('audio', { 'codec': 'aac', 'language': 'en', 'channels': 2 }) liz.addStreamInfo('subtitle', {'language': 'en'}) liz.setProperty('fanart_image', fanart) liz.setProperty('IsPlayable', 'true') ilist.append((u, liz, False)) if len(ilist) != 0: if 'wcmmode=disabled' in geurl: name = '[COLOR red]%s[/COLOR]' % __language__(30012) mode = 'GE' url = '/video/p/%s?wcmmode=disabled' % str(int(geurl[9]) + 1) u = '%s?url=%s&name=%s&mode=%s' % (sys.argv[0], qp(url), qp(name), mode) liz = xbmcgui.ListItem(name, '', 'DefaultFolder.png', icon) liz.setInfo('Video', { "Title": name, "Studio": showName, "Plot": name }) liz.setProperty('fanart_image', addonfanart) ilist.append((u, liz, True)) xbmcplugin.addDirectoryItems(int(sys.argv[1]), ilist, len(ilist)) if addon.getSetting('enable_views') == 'true': xbmc.executebuiltin("Container.SetViewMode(%s)" % addon.getSetting('episode_view')) xbmcplugin.endOfDirectory(int(sys.argv[1]))
def seriesList(name, id,url,thumb): link = getHttpData(url) if url.find('.shtml')>0: match0 = re.compile('var vrs_playlist_id="(.+?)";', re.DOTALL).findall(link) #print 'vrs_playlist_id:' + match0.groups() link = getHttpData('http://hot.vrs.sohu.com/vrs_videolist.action?playlist_id='+match0[0]) match = re.compile('"videoImage":"(.+?)",.+?"videoUrl":"(.+?)".+?"videoOrder":"(.+?)",', re.DOTALL).findall(link) totalItems = len(match) for p_thumb,p_url,p_order in match: p_name = '%s第%s集' % (name, p_order) li = xbmcgui.ListItem(p_name, iconImage = '', thumbnailImage = p_thumb) li.setInfo(type="Video",infoLabels={"Title":p_name, "episode":int(p_order)}) u = sys.argv[0] + "?mode=3&name=" + urllib.quote_plus(p_name) + "&url=" + urllib.quote_plus(p_url)+ "&thumb=" + urllib.quote_plus(p_thumb) xbmcplugin.addDirectoryItem(int(sys.argv[1]), u, li, False, totalItems) else: match0 = re.compile('var pid\s*=\s*(.+?);', re.DOTALL).findall(link) if len(match0)>0: # print 'pid=' + match0[0] pid = match0[0].replace('"','') match0 = re.compile('var vid\s*=\s*(.+?);', re.DOTALL).findall(link) vid = match0[0].replace('"','') if vid == '0': dialog = xbmcgui.Dialog() ok = dialog.ok(__addonname__,'您当前选择的节目暂不能播放,请选择其它节目') return obtype = '2' link = getHttpData("http://search.vrs.sohu.com/avs_i"+vid+"_pr"+pid+"_o"+obtype+"_n_p1000_chltv.sohu.com.json") data = link.replace('var video_album_videos_result=','').decode('raw_unicode_escape') match = simplejson.loads(data)['videos'] totalItems = len(match) for item in match: p_name = item['videoName'].encode('utf-8') p_time = item['videoPublishTime'] p_order = item['playOrder'].encode('utf-8') p_url = item['videoUrl'].encode('utf-8') p_thumb = item['videoBigPic'].encode('utf-8') p_date = datetime.date.fromtimestamp(float(p_time)/1000).strftime('%d.%m.%Y') li = xbmcgui.ListItem(p_name, iconImage = '', thumbnailImage = p_thumb) li.setInfo(type="Video",infoLabels={"Title":p_name, "date":p_date, "episode":int(p_order)}) u = sys.argv[0] + "?mode=3&name=" + urllib.quote_plus(p_name) + "&url=" + urllib.quote_plus(p_url)+ "&thumb=" + urllib.quote_plus(p_thumb) xbmcplugin.addDirectoryItem(int(sys.argv[1]), u, li, False, totalItems) else: match = re.compile('<a([^>]*)><IMG([^>]*)></a>',re.I).findall(link) thumbDict = {} for i in range(0, len(match)): p_url = re.compile('href="(.+?)"').findall(match[i][0]) if len(p_url)>0: p_url = p_url[0] else: p_url = match[i][0] p_thumb = re.compile('src="(.+?)"').findall(match[i][1]) if len(p_thumb)>0: p_thumb = p_thumb[0] else: p_thumb = match[i][1] thumbDict[p_url]=p_thumb #for img in thumbDict.items(): url = 'http://so.tv.sohu.com/mts?c=2&wd=' + urllib.quote_plus(name.decode('utf-8').encode('gbk')) html = getHttpData(url) match = re.compile('class="serie-list(.+?)</div>').findall(html) if not match: return items = re.compile('<a([^>]*)>(.+?)</a>',re.I).findall(match[0]) totalItems = len(items) for item in items: if item[1]=='展开>>': continue href = re.compile('href="(.+?)"').findall(item[0]) if len(href)>0: p_url = href[0] urlKey = re.compile('u=(http.+?.shtml)').search(p_url) if urlKey: urlKey = urllib.unquote(urlKey.group(1)) else: urlKey = p_url #print urlKey p_thumb = thumb try: p_thumb = thumbDict[urlKey] except: pass #title = re.compile('title="(.+?)"').findall(item) #if len(title)>0: #p_name = title[0] p_name = name + '第' + item[1].strip() + '集' li = xbmcgui.ListItem(p_name, iconImage = p_thumb, thumbnailImage = p_thumb) u = sys.argv[0] + "?mode=3&name="+urllib.quote_plus(p_name)+"&id="+id+"&url="+urllib.quote_plus(p_url)+"&thumb="+urllib.quote_plus(p_thumb) xbmcplugin.addDirectoryItem(int(sys.argv[1]), u, li, False) xbmcplugin.setContent(int(sys.argv[1]), 'episodes') xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_EPISODE) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_DATE) xbmcplugin.endOfDirectory(int(sys.argv[1]))
def SXVIDEO_GENERIC_PLAY(sxurl): liz = xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=movies_thumb); liz.setInfo(type="Video", infoLabels={"Title": name}) hmf = urlresolver.HostedMediaFile(url=sxurl, include_disabled=True, include_universal=False) xbmc.Player().play(hmf.resolve(), liz, False)
def start(self, selfGet): # vars self = selfGet list = [ [ 'B4B Radio Club Dance', 'https://radio10.pro-fhi.net/radio/9000/stream', 'https://i46.servimg.com/u/f46/19/40/01/67/c17559.png' ], [ 'E-Dance 90s', 'http://94.23.221.158:9197/stream', 'https://i46.servimg.com/u/f46/19/40/01/67/c17567.png' ], [ 'Hotmixradio 80', 'http://streaming.hotmixradio.fm/hotmixradio-80-128.mp3', 'https://i46.servimg.com/u/f46/19/40/01/67/c17560.png' ], [ 'Hotmixradio FUNKY', 'http://streaming.hotmixradio.fm/hotmixradio-funky-128.mp3', 'https://i46.servimg.com/u/f46/19/40/01/67/c17563.png' ], [ 'Hotmixradio LOUNGE', 'http://streaming.hotmixradio.fm/hotmixradio-lounge-128.mp3', 'https://i46.servimg.com/u/f46/19/40/01/67/c17564.png' ], [ 'Hotmixradio HITS', 'http://streaming.hotmixradio.fm/hotmixradio-hits-128.mp3', 'https://i46.servimg.com/u/f46/19/40/01/67/c17572.png' ], [ 'Hotmixradio 2000', 'http://streaming.hotmixradio.fm/hotmixradio-2k-128.mp3', 'https://i46.servimg.com/u/f46/19/40/01/67/c17573.png' ], [ 'Hotmixradio HOT', 'http://streaming.hotmixradio.fm/hotmixradio-hot-128.mp3', 'https://i46.servimg.com/u/f46/19/40/01/67/c17574.png' ], [ 'NRJ France', 'http://185.52.127.168/fr/30001/mp3_128.mp3', 'https://i46.servimg.com/u/f46/19/40/01/67/c17570.png' ], [ 'Puls Radio - Lounge', 'http://icecast.pulsradio.com/relaxHD.mp3', 'https://i62.servimg.com/u/f62/19/40/01/67/lounfe10.jpg' ], [ 'Roots Legacy Radio', 'http://rootslegacy.fr:8080/stream/1/', 'https://i46.servimg.com/u/f46/19/40/01/67/c17566.png' ], [ 'RTL2', 'http://streaming.radio.rtl2.fr/rtl2-1-48-192', 'https://i46.servimg.com/u/f46/19/40/01/67/c17569.png' ] ] if self.opt2 == '': i = 0 for key in list: listItem = xbmcgui.ListItem(label=key[0], iconImage=key[2]) xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=sys.argv[0] + '?fr_' + str(i), listitem=listItem, isFolder=True) i = i + 1 xbmcplugin.endOfDirectory(int(sys.argv[1])) else: Title = list[int(self.opt2)][0] Icon = list[int(self.opt2)][2] URL = list[int(self.opt2)][1] import radioPlayer as player player.Main().start(Title, Icon, URL)
def playVideo(self, name, url, liz=None): log('playVideo') if not liz: liz = xbmcgui.ListItem(name, path=url) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
def playVideo(self): # # Init # no_url_found = False unplayable_media_file = False have_valid_url = False # # Get current list item details... # # title = unicode(xbmc.getInfoLabel("listitem.Title"), "utf-8") thumbnail_url = xbmc.getInfoImage("list_item.Thumb") # studio = unicode(xbmc.getInfoLabel("list_item.Studio"), "utf-8") plot = unicode(xbmc.getInfoLabel("list_item.Plot"), "utf-8") genre = unicode(xbmc.getInfoLabel("list_item.Genre"), "utf-8") # # Show wait dialog while parsing data... # dialog_wait = xbmcgui.DialogProgress() dialog_wait.create(LANGUAGE(30504), self.title) # wait 1 second xbmc.sleep(1000) # Set cookies for cookie-firewall and nsfw-switch if SETTINGS.getSetting('nsfw') == 'true': cookies = {"Cookie": "cpc=10", "nsfw": "1"} else: cookies = {"Cookie": "cpc=10"} # Make a session sess = requests.session() # Set cookies for cookie-firewall and nsfw-switch if SETTINGS.getSetting('nsfw') == 'true': cookies = {"Cookie": "cpc=10", "nsfw": "1"} else: cookies = {"Cookie": "cpc=10"} # Determine if cloudflare protection is active or not html_source = sess.get(self.video_page_url, cookies=cookies).text if str(html_source).find("cloudflare") >= 0: cloudflare_active = True else: cloudflare_active = False # Get the page if cloudflare_active == True: try: import cfscrape except: xbmcgui.Dialog().ok(LANGUAGE(30000), LANGUAGE(30513)) sys.exit(1) try: # returns a CloudflareScraper instance scraper = cfscrape.create_scraper(sess) except: xbmcgui.Dialog().ok(LANGUAGE(30000), LANGUAGE(30514)) sys.exit(1) try: html_source = scraper.get(self.video_page_url).content except: xbmcgui.Dialog().ok(LANGUAGE(30000), LANGUAGE(30515)) sys.exit(1) soup = BeautifulSoup(html_source) video_url = '' # <div class="videoplayer" id="video1" data-files="eyJmbHYiOiJodHRwOlwvXC9tZWRpYS5kdW1wZXJ0Lm5sXC9mbHZcLzI4OTE2NWRhXzEwMjU1NzUyXzYzODMxODA4OTU1NDc2MV84MTk0MzU3MDVfbi5tcDQuZmx2IiwidGFibGV0IjoiaHR0cDpcL1wvbWVkaWEuZHVtcGVydC5ubFwvdGFibGV0XC8yODkxNjVkYV8xMDI1NTc1Ml82MzgzMTgwODk1NTQ3NjFfODE5NDM1NzA1X24ubXA0Lm1wNCIsIm1vYmlsZSI6Imh0dHA6XC9cL21lZGlhLmR1bXBlcnQubmxcL21vYmlsZVwvMjg5MTY1ZGFfMTAyNTU3NTJfNjM4MzE4MDg5NTU0NzYxXzgxOTQzNTcwNV9uLm1wNC5tcDQiLCJzdGlsbCI6Imh0dHA6XC9cL3N0YXRpYy5kdW1wZXJ0Lm5sXC9zdGlsbHNcLzY1OTM1MjRfMjg5MTY1ZGEuanBnIn0="></div></div> video_urls = soup.findAll('div', attrs={'class': re.compile("video")}, limit=1) if len(video_urls) == 0: no_url_found = True else: video_url_enc = video_urls[0]['data-files'] # base64 decode video_url_dec = str(base64.b64decode(video_url_enc)) # {"flv":"http:\/\/media.dumpert.nl\/flv\/5770e490_Jumbo_KOOP_DAN__Remix.avi.flv","tablet":"http:\/\/media.dumpert.nl\/tablet\/5770e490_Jumbo_KOOP_DAN__Remix.avi.mp4","mobile":"http:\/\/media.dumpert.nl\/mobile\/5770e490_Jumbo_KOOP_DAN__Remix.avi.mp4","720p":"http:\/\/media.dumpert.nl\/720p\/5770e490_Jumbo_KOOP_DAN__Remix.avi.mp4","still":"http:\/\/static.dumpert.nl\/stills\/6593503_5770e490.jpg"} # or # {"embed":"youtube:U89fl5fZETE","still":"http:\/\/static.dumpert.nl\/stills\/6650228_24eed546.jpg"} xbmc.log("[ADDON] %s v%s (%s) debug mode, %s = %s" % ( ADDON, VERSION, DATE, "video_url_dec", str(video_url_dec)), xbmc.LOGDEBUG) # convert string to dictionary video_url_dec_dict = ast.literal_eval(video_url_dec) video_url_embed = '' try: video_url_embed = str(video_url_dec_dict['embed']) embed_found = True except KeyError: embed_found = False video_url = '' if embed_found: # make youtube plugin url youtube_id = video_url_embed.replace("youtube:", "") youtube_url = 'plugin://plugin.video.youtube/play/?video_id=%s' % youtube_id video_url = youtube_url have_valid_url = True xbmc.log("[ADDON] %s v%s (%s) debug mode, %s = %s" % ( ADDON, VERSION, DATE, "video_url1", str(video_url)), xbmc.LOGDEBUG) else: # matching the desired and available quality if self.VIDEO == '0': try: video_url = str(video_url_dec_dict['mobile']) except KeyError: no_url_found = True elif self.VIDEO == '1': try: video_url = str(video_url_dec_dict['tablet']) except KeyError: try: video_url = str(video_url_dec_dict['mobile']) except KeyError: no_url_found = True elif self.VIDEO == '2': try: video_url = str(video_url_dec_dict['720p']) except KeyError: try: video_url = str(video_url_dec_dict['tablet']) except KeyError: try: video_url = str(video_url_dec_dict['mobile']) except KeyError: no_url_found = True if no_url_found: pass else: video_url = video_url.replace('\/', '/') xbmc.log("[ADDON] %s v%s (%s) debug mode, %s = %s" % ( ADDON, VERSION, DATE, "video_url2", str(video_url)), xbmc.LOGDEBUG) # The need for speed: let's guess that the video-url exists have_valid_url = True # Play video... if have_valid_url: list_item = xbmcgui.ListItem(path=video_url) xbmcplugin.setResolvedUrl(self.plugin_handle, True, list_item) # # Alert user # elif no_url_found: xbmcgui.Dialog().ok(LANGUAGE(30000), LANGUAGE(30505)) elif unplayable_media_file: xbmcgui.Dialog().ok(LANGUAGE(30000), LANGUAGE(30506))
def play(url): item = xbmcgui.ListItem(path=url) return xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item)
def bigstar_movies(url): xbmc.log('URL= ' + str(url), level=log_level) page = re.compile('page/(.+?)/limit').findall(url)[0] page = int(page) + 1 nurl = url response = urllib2.urlopen(url) jgdata = json.load(response) for item in jgdata["films"]: film_id = item["id"] item_page = 'http://www.bigstar.tv/mobile/stream/film/' + str( film_id ) + '/ads/1/type/0/version/2/mobileStreams/1/hls/1/os/web/device/75d6a6c6349cfecb9420d6119c51e1ec/lan/default' title = item["title"].encode('utf-8') image = item["cover_large"] fanart = item["imageUrl1"] plot = item["desc"] director = item["director"] writer = item["writer"] cast = '[' + item["cast"].replace('"', '') + ']' #xbmc.log('CAST: ' + str(cast),level=log_level) rating = ["maturity"] duration = ['duration_seconds'] #infoLabels = {'title' : title, 'director': director, 'writer': writer, 'cast': cast, 'mpaa': rating, 'plot': plot, 'duration': duration} tv = str(item["hasEpisodes"]) if 'True' in tv: continue url = 'plugin://plugin.video.bigstar-movies?mode=150&url=' + urllib.quote_plus( item_page) #add_directory(title, item_page, 150, fanart , image, plot=desc) li = xbmcgui.ListItem(title) li.setInfo(type="Video", infoLabels={ "mediatype": "video", "label": title, 'title': title, 'director': director, 'writer': writer, 'rating': rating, 'plot': plot }) #, 'season': season, 'episode':episode}) li.addStreamInfo('video', { 'mpaa': str(rating), 'duration': unicode(duration) }) li.setProperty('IsPlayable', 'True') li.setArt({'thumb': image, 'fanart': fanart}) #li.setCast(cast) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=False) #add_directory(title, item_page, 150, fanart , image, infoLabels) xbmcplugin.setContent(addon_handle, 'movies') next_page = nurl.rsplit('/', 6)[0] next_page = str(next_page) + '/' + str(page) + '/limit/30/os/web/device' xbmc.log('NEXT_PAGE: ' + str(next_page), level=log_level) add_directory2('Next Page>>', next_page, 141, defaultfanart, artbase + 'big-star.png', plot='') #if views != 'false': xbmc.executebuiltin("Container.SetViewMode(" + str(m_views[int(m_view)]) + ")") xbmcplugin.endOfDirectory(addon_handle)
elif v[3]: id = v[3] print id if '/embed-' in id: continue try: url = cloudyvideos.get_quality_video_link( id, None, CVHeader) + '|User-Agent=%s&Referer=%s' % (CVUA, CVRef) except: title = '[COLOR red]Unavailable[/COLOR]: ' + title url = '' else: continue li = xbmcgui.ListItem(title, iconImage='DefaultVideo.png') li.setProperty('IsPlayable', 'true') if url is None: url = '' log(url) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=False) xbmcplugin.endOfDirectory(addon_handle) elif mode[0] == 'next_page': after_post = args['after_post'][0] to_filter = args['to_filter'][0] reddit_base_url = args['reddit_base_url'][0] json_data = get_reddit_json(reddit_base_url + after_post)
def play(url): resolved = url item = xbmcgui.ListItem(path=resolved) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item)
sortArg = args.get('sort', ['']) sort = sortArg[0] searchStringArg = args.get('search_string', ['']) search_string = searchStringArg[0] #open history file for reading and writing search_history_file = os.path.join( xbmcaddon.Addon('plugin.video.rtvslo').getAddonInfo('path'), 'history') #step 1: Collect underpants... if mode == 0: #mode == 0: list main menu (LIVE RADIO, ODDAJE, ARHIV) #LIVE RADIO if contentType == 'audio': li = xbmcgui.ListItem('V živo') url = build_url(base, {'content_type': contentType, 'mode': 1}) xbmcplugin.addDirectoryItem(handle=handle, url=url, listitem=li, isFolder=True) #ISKANJE if contentType == 'video': li = xbmcgui.ListItem('Iskanje') url = build_url(base, { 'content_type': contentType, 'mode': 41 }) xbmcplugin.addDirectoryItem(handle=handle, url=url, listitem=li,
def play_video(id): play_item = xbmcgui.ListItem(path=id) xbmcplugin.setResolvedUrl(_handle, True, listitem=play_item)
def playVideoLetv(name, url, thumb): VIDEO_CODE = [['bHY=', 'bHY/'], ['dg==', 'dj9i'], ['dg==', 'dTgm'], ['Zmx2', 'Zmx2']] dialog = xbmcgui.Dialog() link = getHttpData(url) match = re.compile('{v:\[(.+?)\]').findall(link) # link[0]:"标清-SD" ; link[1]:"高清-HD" if match: matchv = re.compile('"(.+?)"').findall(match[0]) if matchv: playlist = xbmc.PlayList(1) playlist.clear() if videoRes == 1: # Play selected HD and fallback to SD if HD failed vlist = reversed(range(len(matchv))) else: # Play selected SD and HD as next item in playlist vlist = range(len(matchv)) for j in vlist: if matchv[j] == "": continue #algorithm to generate the video link code vidx = matchv[j].find('MT') vidx = -1 # force to start at 24 if vidx < 0: vid = matchv[j][24:+180] # extract max VID code length else: vid = matchv[j][vidx:+180] for k in range(0, len(VIDEO_CODE)): vidcode = re.split(VIDEO_CODE[k][1], vid) if len(vidcode) > 1: vid = vidcode[0] + VIDEO_CODE[k][0] break # fail to decipher, use alternate method to play if len(vidcode) == 1: #print 'vidcode: ', vidcode #print "Use alternative player" playVideo(name, url, thumb) return #else: p_url = 'http://g3.letv.cn/vod/v1/' + vid + '?format=1&b=388&expect=3&host=www_letv_com&tag=letv&sign=free' link = getHttpData(p_url) link = link.replace("\/", "/") match = re.compile('{.+?"location": "(.+?)" }').findall(link) if match: for i in range(len(match)): p_name = name + ' [' + VIDEO_RES[j][0] + ']' listitem = xbmcgui.ListItem( p_name, thumbnailImage=__addonicon__) listitem.setInfo(type="Video", infoLabels={"Title": p_name}) playlist.add(match[i], listitem) break # skip the rest if any (1 of 3) video links access successful break # play user selected video resolution only else: ok = dialog.ok(__addonname__, '无法播放:未匹配到视频文件,请选择其它视频') xbmc.Player().play(playlist) else: ok = dialog.ok(__addonname__, '无法播放:需收费,请选择其它视频') else: match = re.compile( '<dd class="ddBtn1">.+?title="(.+?)" class="btn01">').findall(link) if match and match[0] == "点播购买": ok = dialog.ok(__addonname__, '无法播放:需收费,请选择其它视频') else: ok = dialog.ok(__addonname__, '无法播放:未匹配到视频文件,请选择其它视频')
def create_listitem(item, as_tuple=True, offscreen=True): '''helper to create a kodi listitem from kodi compatible dict with mediainfo''' try: if KODI_VERSION > 17: liz = xbmcgui.ListItem(label=item.get("label", ""), label2=item.get("label2", ""), path=item['file'], offscreen=offscreen) else: liz = xbmcgui.ListItem(label=item.get("label", ""), label2=item.get("label2", ""), path=item['file']) # only set isPlayable prop if really needed if item.get("isFolder", False): liz.setProperty('IsPlayable', 'false') elif "plugin://script.skin.helper" not in item['file']: liz.setProperty('IsPlayable', 'true') nodetype = "Video" if item["type"] in ["song", "album", "artist"]: nodetype = "Music" # extra properties for key, value in item["extraproperties"].iteritems(): liz.setProperty(key, value) # video infolabels if nodetype == "Video": infolabels = { "title": item.get("title"), "size": item.get("size"), "genre": item.get("genre"), "year": item.get("year"), "top250": item.get("top250"), "tracknumber": item.get("tracknumber"), "rating": item.get("rating"), "playcount": item.get("playcount"), "overlay": item.get("overlay"), "cast": item.get("cast"), "castandrole": item.get("castandrole"), "director": item.get("director"), "mpaa": item.get("mpaa"), "plot": item.get("plot"), "plotoutline": item.get("plotoutline"), "originaltitle": item.get("originaltitle"), "sorttitle": item.get("sorttitle"), "duration": item.get("duration"), "studio": item.get("studio"), "tagline": item.get("tagline"), "writer": item.get("writer"), "tvshowtitle": item.get("tvshowtitle"), "premiered": item.get("premiered"), "status": item.get("status"), "code": item.get("imdbnumber"), "imdbnumber": item.get("imdbnumber"), "aired": item.get("aired"), "credits": item.get("credits"), "album": item.get("album"), "artist": item.get("artist"), "votes": item.get("votes"), "trailer": item.get("trailer"), "progress": item.get('progresspercentage') } if item["type"] == "episode": infolabels["season"] = item["season"] infolabels["episode"] = item["episode"] # streamdetails if item.get("streamdetails"): liz.addStreamInfo("video", item["streamdetails"].get("video", {})) liz.addStreamInfo("audio", item["streamdetails"].get("audio", {})) liz.addStreamInfo( "subtitle", item["streamdetails"].get("subtitle", {})) if "dateadded" in item: infolabels["dateadded"] = item["dateadded"] if "date" in item: infolabels["date"] = item["date"] # music infolabels else: infolabels = { "title": item.get("title"), "size": item.get("size"), "genre": item.get("genre"), "year": item.get("year"), "tracknumber": item.get("track"), "album": item.get("album"), "artist": " / ".join(item.get('artist')), "rating": str(item.get("rating", 0)), "lyrics": item.get("lyrics"), "playcount": item.get("playcount") } if "date" in item: infolabels["date"] = item["date"] if "duration" in item: infolabels["duration"] = item["duration"] if "lastplayed" in item: infolabels["lastplayed"] = item["lastplayed"] # setting the dbtype and dbid is supported from kodi krypton and up if KODI_VERSION > 16 and item["type"] not in [ "recording", "channel", "favourite" ]: infolabels["mediatype"] = item["type"] # setting the dbid on music items is not supported ? if nodetype == "Video" and "DBID" in item["extraproperties"]: infolabels["dbid"] = item["extraproperties"]["DBID"] if "lastplayed" in item: infolabels["lastplayed"] = item["lastplayed"] # assign the infolabels liz.setInfo(type=nodetype, infoLabels=infolabels) # artwork liz.setArt(item.get("art", {})) if "icon" in item: liz.setIconImage(item['icon']) if "thumbnail" in item: liz.setThumbnailImage(item['thumbnail']) # contextmenu if item["type"] in ["episode", "season" ] and "season" in item and "tvshowid" in item: # add series and season level to widgets if "contextmenu" not in item: item["contextmenu"] = [] item["contextmenu"] += [ (xbmc.getLocalizedString(20364), "ActivateWindow(Video,videodb://tvshows/titles/%s/,return)" % (item["tvshowid"])), (xbmc.getLocalizedString(20373), "ActivateWindow(Video,videodb://tvshows/titles/%s/%s/,return)" % (item["tvshowid"], item["season"])) ] if "contextmenu" in item: liz.addContextMenuItems(item["contextmenu"]) if as_tuple: return (item["file"], liz, item.get("isFolder", False)) else: return liz except Exception as exc: log_exception(__name__, exc) log_msg(item) return None
def PLAY(name,url,iconimage): playback_url = 'plugin://plugin.video.youtube/?action=play_video&videoid=%s' % url liz = xbmcgui.ListItem(name, iconImage='DefaultVideo.png', thumbnailImage=iconimage) liz.setPath(playback_url) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
def get_listItem(self): return xbmcgui.ListItem(self.Title, iconImage=self.Image)
def list_videos_by_channel(self, channel, start, duration): # Get the list of videos in the category. listEPG = self.user.getEPG(channel, start, duration) for channel in listEPG: for videoKey in listEPG[channel].keys(): # Create a list item with a text label and a thumbnail image. video = listEPG[channel][videoKey] timeStart = modTime.strptime(video['dateCompleteDebut'], "%Y%m%d%H%M") timeEnd = modTime.strptime(video['dateCompleteFin'], "%Y%m%d%H%M") title = "[" + modTime.strftime( "%d/%m/%Y %H:%M", modTime.strptime(video['dateCompleteDebut'], "%Y%m%d%H%M")) + "] " + video['titre'] list_item = xbmcgui.ListItem(label=title) timeStart = modTime.mktime(timeStart) timeEnd = modTime.mktime(timeEnd) # Set additional info for the list item. list_item.setInfo( 'video', { 'title': title, 'genre': video['categorieDetail'], 'dateadded': modTime.strftime( "%Y-%m-%d %H:%M:%s", modTime.strptime(video['dateCompleteDebut'], "%Y%m%d%H%M")), 'mediatype': 'movie', 'dbid': video['id'], 'mpaa': video['classeCSA'], 'duration': (timeEnd - timeStart), 'plot': video['description'], 'plotoutline': video['description'] }) list_item.setProperty('IsPlayable', 'true') duration = timeEnd - timeStart duration = self.add_margin_video(duration) urlVideo = self.user.getURLCatchup(str(video['channel_id']), str(int(timeStart)), str(duration)) url = self.get_url(action='play', video=urlVideo) list_item.setArt({ 'thumb': video['vignette'], 'icon': video['vignette'], 'fanart': video['vignette'] }) xbmcplugin.addDirectoryItem(self._handle, url, list_item, False) xbmcplugin.addSortMethod(self._handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE) # Finish creating a virtual folder. xbmcplugin.endOfDirectory(self._handle)
def geteventLane(): response = urllib.request.urlopen(base_url + args['eventLane']).read() jsonResult = json.loads(response) eventday = None for event in jsonResult['data']['data']: if event['target_type'] == 'event': scheduled_start = datetime.utcfromtimestamp( int(event['metadata']['scheduled_start']['utc_timestamp'])) if (eventday is None or (event['metadata']['state'] == "post" and scheduled_start.date() < eventday) or (event['metadata']['state'] != "post" and scheduled_start.date() > eventday) and not (event['metadata']['state'] != 'live' and ('onlylive' in args and args['onlylive']))): li = xbmcgui.ListItem("[COLOR gold]" + prettydate(scheduled_start, False) + "[/COLOR]") li.setProperty("IsPlayable", "false") xbmcplugin.addDirectoryItem(handle=_addon_handler, url="", listitem=li) eventday = scheduled_start.date() title = __language__(30003) if event['metadata']['title']: title = event['metadata']['title'] else: if event['type'] in [ 'teamEvent', 'skyTeamEvent' ] and 'details' in event['metadata'] and 'home' in event[ 'metadata']['details']: title = event['metadata']['details']['home'][ 'name_full'] + ' - ' + event['metadata']['details'][ 'away']['name_full'] elif event['metadata']['description_bold']: title = event['metadata']['description_bold'] eventinfo = "" if event['metadata']['description_regular']: eventinfo += event['metadata']['description_regular'] fulltitle = '[B]' + title + '[/B]' if eventinfo: fulltitle += ' (' + eventinfo + ')' li = xbmcgui.ListItem(fulltitle) li.setArt({ 'icon': base_image_url + event['metadata']['images']['editorial'] }) li.setInfo('video', {'plot': prettydate(scheduled_start)}) li.setProperty( 'fanart_image', base_image_url + event['metadata']['images']['editorial']) if event['metadata']['state'] == 'live': li.setProperty('IsPlayable', 'true') li.setInfo('video', {}) url = build_url({ 'mode': 'event', 'event': event['target'], 'live': True }) xbmcplugin.addDirectoryItem(handle=_addon_handler, url=url, listitem=li) elif not ('onlylive' in args and args['onlylive']): url = build_url({'mode': 'event', 'event': event['target']}) xbmcplugin.addDirectoryItem(handle=_addon_handler, url=url, listitem=li, isFolder=True) xbmcplugin.endOfDirectory(_addon_handler)
def play_video(self, path): # Create a playable item with a path to play. play_item = xbmcgui.ListItem(path=self.user.getTempM3UCatchup(path)) # Pass the item to the Kodi player. xbmcplugin.setResolvedUrl(self._handle, True, listitem=play_item)
def addLink(name,url,iconimage): liz=xbmcgui.ListItem(name, iconImage=art+'/link.png', thumbnailImage=iconimage) liz.setInfo( type="Video", infoLabels={ "Title": name } ) liz.setProperty('fanart_image',art+"fanart.jpg") return xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=liz)
def manual_set_artwork(artwork, mediatype, header=None): """Allow user to manually select the artwork with a select dialog""" changemade = False if mediatype == "artist": art_types = [ "thumb", "poster", "fanart", "banner", "clearart", "clearlogo", "landscape" ] elif mediatype == "album": art_types = [ "thumb", "discart", "thumbback", "spine", "album3Dthumb", "album3Dflat", "album3Dcase", "album3Dface" ] else: art_types = [ "thumb", "poster", "fanart", "banner", "clearart", "clearlogo", "discart", "landscape", "characterart" ] if not header: header = xbmc.getLocalizedString(13511) # show dialogselect with all artwork options abort = False while not abort: listitems = [] for arttype in art_types: img = artwork.get(arttype, "") listitem = xbmcgui.ListItem(label=arttype, label2=img) listitem.setArt({'icon': img}) listitem.setProperty("icon", img) listitems.append(listitem) dialog = DialogSelect("DialogSelect.xml", "", listing=listitems, window_title=header, multiselect=False) dialog.doModal() selected_item = dialog.result del dialog if selected_item == -1: abort = True else: # show results for selected art type artoptions = [] selected_item = listitems[selected_item] if sys.version_info.major == 3: image = selected_item.getProperty("icon") label = selected_item.getLabel() else: image = selected_item.getProperty("icon").decode("utf-8") label = selected_item.getLabel().decode("utf-8") subheader = "%s: %s" % (header, label) if image: # current image listitem = xbmcgui.ListItem( label=xbmc.getLocalizedString(13512), label2=image) listitem.setArt({'icon': image}) listitem.setProperty("icon", image) artoptions.append(listitem) # none option listitem = xbmcgui.ListItem(label=xbmc.getLocalizedString(231)) listitem.setArt({'icon': "DefaultAddonNone.png"}) listitem.setProperty("icon", "DefaultAddonNone.png") artoptions.append(listitem) # browse option listitem = xbmcgui.ListItem(label=xbmc.getLocalizedString(1024)) listitem.setArt({'icon': "DefaultFolder.png"}) listitem.setProperty("icon", "DefaultFolder.png") artoptions.append(listitem) # add remaining images as option allarts = artwork.get(label + "s", []) for item in allarts: listitem = xbmcgui.ListItem(label=item) listitem.setArt({'icon': item}) listitem.setProperty("icon", item) artoptions.append(listitem) dialog = DialogSelect("DialogSelect.xml", "", listing=artoptions, window_title=subheader) dialog.doModal() selected_item = dialog.result del dialog if image and selected_item == 1: # set image to None artwork[label] = "" changemade = True elif (image and selected_item > 2) or (not image and selected_item > 0): # one of the optional images is selected as new default artwork[label] = artoptions[selected_item].getProperty("icon") changemade = True elif (image and selected_item == 2) or (not image and selected_item == 0): # manual browse... dialog = xbmcgui.Dialog() if sys.version_info.major == 3: image = dialog.browse(2, xbmc.getLocalizedString(1030), 'files', mask='.gif|.png|.jpg') else: image = dialog.browse( 2, xbmc.getLocalizedString(1030), 'files', mask='.gif|.png|.jpg').decode("utf-8") del dialog if image: artwork[label] = image changemade = True # return endresult return changemade, artwork
def queueVideo(url, name, thumb): playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) listitem = xbmcgui.ListItem(name, thumbnailImage=thumb) playlist.add(url, listitem)
def Straight_Resolve(name,url): xbmc.Player().play(url, xbmcgui.ListItem(name))
def onInit(self): global EULA global WARR #hide all timezone, TandC and Apply buttons for hide_this in [1003, 1004, 1005, 1006, 1007, 1008, 1009]: self.getControl(hide_this).setVisible(False) if self.showtimezone: # populate the timezone controls for region, countries in self.timezones.iteritems(): for country in countries: ctl_id = self.tz_control_map.get(region, False) if not ctl_id: continue self.tmp = xbmcgui.ListItem(label=country, label2='', thumbnailImage='') self.getControl(ctl_id).addItem(self.tmp) # hide the controls that determine panel visibility for visibility_control in [ 93000, 94000, 95000, 96000, 97000, 98000, 99000 ]: self.getControl(visibility_control).setVisible(False) # hide the language sub menus for tz in [3001, 3002, 3003, 3004, 3005, 3006, 3007, 3008, 3009]: self.getControl(tz * 10).setVisible(False) # populate the language control for language in self.languages: self.tmp = xbmcgui.ListItem(label=language, label2='', thumbnailImage='') self.getControl(20010).addItem(self.tmp) # populate the terms and conditions self.getControl(555).setText(EULA) # populate the warranty self.getControl(777).setText(WARR) # set the image for the skin preview control self.set_skin_image('OSMC') # this will only be True, if the language has been selected and the GUI has reloaded if self.lang_rerun: # set the flag to False so the GUI doesnt reload on exit self.lang_rerun = False self.bypass_language()
def Big_resolve2(name,url): import liveresolver resolved_url = liveresolver.resolve(url) xbmc.Player().play(resolved_url, xbmcgui.ListItem(name)) xbmcplugin.endOfDirectory(int(sys.argv[1]))
def progList(name,id,page,cat,area,year,p5,p6,p11,order): url = 'http://so.tv.sohu.com/list_p1'+id+'_p2'+cat+'_p3'+area+'_p4'+year+'_p5'+p5+'_p6'+p6+'_p7'+order if name in ('电影','电视剧'): url +='_p82_p9_2d1' else: url +='_p8_p9' url += '_p10'+page+'_p11'+p11+'.html' currpage = int(page) link = getHttpData(url) match = re.compile('<div class="ssPages area">(.+?)</div>', re.DOTALL).findall(link) if not match: dialog = xbmcgui.Dialog() ok = dialog.ok(__addonname__, '没有符合此条件的视频!') else: matchpages = re.compile('<a href="[^"]*">(\d+)</a>', re.DOTALL).findall(match[0]) totalpages = int(matchpages[-1]) if totalpages < currpage: totalpages = currpage match = re.compile('<div class="sort-type">(.+?)</div>', re.DOTALL).findall(link) if len(match): listpage = match[0] else: listpage = '' match = re.compile('<li>(.+?)</li>', re.DOTALL).findall(link) totalItems = len(match) + 1 if currpage > 1: totalItems = totalItems + 1 if currpage < totalpages: totalItems = totalItems + 1 lxstr='' if id not in ('121'): if id in ('130'): catlist= getlabelList(listpage) else: catlist= getcatList(listpage) lxstr += '[COLOR FFFF0000]' if cat: lxstr += searchDict(catlist,cat) else: lxstr += '全部类型' lxstr += '[/COLOR]' if id in ('100','101','106'): lxstr += '/[COLOR FF00FF00]' arealist= getareaList(listpage) if area: lxstr += searchDict(arealist,area) else: lxstr += '全部地区' lxstr += '[/COLOR]' if id=='115': lxstr += '/[COLOR FFFFFF00]' pflist,nllist=getList16(listpage) if p5: lxstr += searchDict(pflist,p5) else: lxstr += '全部篇幅' lxstr += '[/COLOR]/[COLOR FF00FF00]' if p6: lxstr += searchDict(nllist,p6) else: lxstr += '全部年龄' lxstr += '[/COLOR]' if id=='121': lxstr += '[COLOR FFFF0000]' lxlist,yylist,arealist,fglist=getList24(listpage) if p5: lxstr += searchDict(lxlist,p5) else: lxstr += '全部类型' lxstr += '[/COLOR]/[COLOR FF00FF00]' if p11: lxstr += searchDict(yylist,p11) else: lxstr += '全部语言' lxstr += '[/COLOR]/[COLOR FFFF5555]' if area: lxstr += searchDict(arealist,area) else: lxstr += '全部地区' lxstr += '[/COLOR]/[COLOR FFFF00FF]' if cat: lxstr += searchDict(fglist,cat) else: lxstr += '全部风格' lxstr += '[/COLOR]' if id in ('100','101','115','121'): lxstr += '/[COLOR FF5555FF]' yearlist = getyearList(listpage) if year=='': lxstr += '全部年份' elif year in ('80','90'): lxstr += year+'年代' elif year == '100': lxstr += '更早年代' else: lxstr += year+'年' lxstr += '[/COLOR]' li = xbmcgui.ListItem(name+'(第'+str(currpage)+'/'+str(totalpages)+'页)【' + lxstr + '/[COLOR FF00FFFF]' + searchDict(ORDER_LIST,order) + '[/COLOR]】(按此选择)') u = sys.argv[0]+"?mode=4&name="+urllib.quote_plus(name)+"&id="+id+"&cat="+cat+"&area="+area+"&year="+year+"&p5="+p5+"&p6="+p6+"&p11="+p11+"&order="+"&listpage="+urllib.quote_plus(listpage) xbmcplugin.addDirectoryItem(int(sys.argv[1]), u, li, True, totalItems) for i in range(0,len(match)): match1 = re.compile('<a href="([^"]+)" title="([^"]+)" target="_blank"', re.DOTALL).search(match[i]) i_url = 1 i_name = 2 if not match1: match1 = re.compile('<a title="([^"]+)" target="_blank" href="([^"]+)"', re.DOTALL).search(match[i]) i_url = 2 i_name = 1 p_name = match1.group(i_name) p_url = match1.group(i_url) match1 = re.compile('<img .*?src="([^"]+)"', re.DOTALL).search(match[i]) p_thumb = match1.group(1) p_rating = 0 p_votes = '' p_director = '' p_genre = '' match1 = re.compile('<p class="lh-info">(.+?)</p>').search(match[i]) if match1: p_plot = match1.group(1) else: p_plot = '' p_year = 0 if id in ('101','115','106','107','119'): p_dir = True mode = 2 else: p_dir = False mode = 3 match1 = re.compile('<span class="maskTx">(.+?)</span>').search(match[i]) if match1: p_name1 = p_name + ' [' + match1.group(1) + ']' else: p_name1 = p_name if match[i].find('<span class="rl-phua"></span>')>0: p_name1 += ' [片花]' elif match[i].find('<span class="rl-rep"></span>')>0: p_name1 += ' [预告]' elif match[i].find('<span class="rl-fuf"></span>')>0: p_name1 += ' [付费]' if match[i].find('<a title="超清" class="super">')>0: p_name1 += ' [超清]' p_res = 2 elif match[i].find('<a title="原画" class="origin">')>0: p_name1 += ' [原画]' p_res = 1 else: p_res = 0 li = xbmcgui.ListItem(str(i + 1) + '. ' + p_name1, iconImage = '', thumbnailImage = p_thumb) u = sys.argv[0]+"?mode="+str(mode)+"&name="+urllib.quote_plus(p_name)+"&url="+urllib.quote_plus(p_url)+"&thumb="+urllib.quote_plus(p_thumb)+"&id="+urllib.quote_plus(str(i)) li.setInfo(type = "Video", infoLabels = {"Title":p_name, "Director":p_director, "Genre":p_genre, "Plot":p_plot, "Year":p_year, "Rating":p_rating, "Votes":p_votes}) xbmcplugin.addDirectoryItem(int(sys.argv[1]), u, li, p_dir, totalItems) # Fetch and build user selectable page number if matchpages: for num in matchpages: li = xbmcgui.ListItem("... 第" + num + "页") u=sys.argv[0]+"?mode=1&name="+urllib.quote_plus(name)+"&id="+id+"&page="+str(num)+"&cat="+cat+"&area="+area+"&year="+year+"&p5="+p5+"&p6="+p6+"&p11="+p11+"&order="+order xbmcplugin.addDirectoryItem(int(sys.argv[1]), u, li, True, totalItems) xbmcplugin.setContent(int(sys.argv[1]), 'movies') xbmcplugin.endOfDirectory(int(sys.argv[1]))
def queueVideo(url, name): playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) listitem = xbmcgui.ListItem(name) playlist.add(url, listitem)
def PlayVideo(name,url,thumb): level = int(__addon__.getSetting('resolution')) site = int(__addon__.getSetting('videosite')) link = getHttpData(url) match1 = re.compile('var vid="(.+?)";').search(link) if not match1: match1 = re.compile('<a href="(http://[^/]+/[0-9]+/[^\.]+.shtml)" target="?_blank"?><img').search(link) if match1: PlayVideo(name,match1.group(1),thumb) return p_vid = match1.group(1) if p_vid == '0': match1 = re.compile('data-vid="([^"]+)"').search(link) if not match1: dialog = xbmcgui.Dialog() ok = dialog.ok(__addonname__,'您当前选择的节目暂不能播放,请选择其它节目') return p_vid = match1.group(1) if p_vid.find(',') > 0 : p_vid = p_vid.split(',')[0] p_url = 'http://hot.vrs.sohu.com/vrs_flash.action?vid='+ p_vid link = getHttpData(p_url) match = re.compile('"norVid":(.+?),"highVid":(.+?),"superVid":(.+?),"oriVid":(.+?),').search(link) if not match: dialog = xbmcgui.Dialog() ok = dialog.ok(__addonname__,'您当前选择的节目暂不能播放,请选择其它节目') return ratelist=[] if match.group(4)!='0':ratelist.append(['原画','4']) if match.group(3)!='0':ratelist.append(['超清','3']) if match.group(2)!='0':ratelist.append(['高清','2']) if match.group(1)!='0':ratelist.append(['流畅','1']) if level == 4: dialog = xbmcgui.Dialog() list = [x[0] for x in ratelist] if len(ratelist)==1: rate=ratelist[0][1] else: sel = dialog.select('视频清晰度(低网速请选择低清晰度-流畅)', list) if sel == -1: return else: rate=ratelist[sel][1] else: rate = int(ratelist[0][1]) if rate > level + 1: rate = level + 1 if match.group(int(rate))<>str(p_vid): link = getHttpData('http://hot.vrs.sohu.com/vrs_flash.action?vid='+match.group(int(rate))) match = re.compile('"tvName":"(.+?)"').findall(link) if not match: res = ratelist[3-int(rate)][0] dialog = xbmcgui.Dialog() ok = dialog.ok(__addonname__,'您当前选择的视频: ['+ res +'] 暂不能播放,请选择其它视频') return name = match[0] match = re.compile('"clipsURL"\:\["(.+?)"\]').findall(link) paths = match[0].split('","') match = re.compile('"su"\:\["(.+?)"\]').findall(link) if not match: res = ratelist[3-int(rate)][0] dialog = xbmcgui.Dialog() ok = dialog.ok(__addonname__,'您当前选择的视频: ['+ res +'] 暂不能播放,请选择其它视频') return newpaths = match[0].split('","') urls = [] for i in range(0,len(paths)): p_url = 'http://data.vod.itc.cn/?prot=2&file='+paths[i].replace('http://data.vod.itc.cn','')+'&new='+newpaths[i] link = getHttpData(p_url) # http://newflv.sohu.ccgslb.net/|623|116.14.234.161|Googu7gm-8WjRTd5ZfBVPIfrtRtLE5Cn|1|0 key=link.split('|')[3] if site == 0: url = link.split('|')[0].rstrip("/")+newpaths[i]+'?key='+key else: url = 'http://new.sohuv.dnion.com'+newpaths[i]+'?key='+key urls.append(url) stackurl = 'stack://' + ' , '.join(urls) listitem = xbmcgui.ListItem(name,thumbnailImage=thumb) listitem.setInfo(type="Video",infoLabels={"Title":name}) xbmc.Player().play(stackurl, listitem)
def progListUgc(name, url, cat, filtrs, page, listpage): fltrCategory = fetchID(UGC_LIST, name) if page == None: page = '1' p_url = "http://list.letv.com/apin/chandata.json?c=%s&d=2&md=&p=%s%s" if (listpage == None): link = getHttpData(url) listpage = re.compile('<ul class="label_list.+?>(.+?)</ul>').findall( link)[0] listpage += re.compile( '<div class="sort_navy.+?">(.+?)</div>').findall(link)[0].replace( 'li', 'lo') cat = updateListSEL(name, url, cat, filtrs, 0, listpage) p_url = p_url % (fltrCategory, page, filtrs) # Fetch & build video titles list for user selection, highlight user selected filter li = xbmcgui.ListItem(name + '(第' + str(page) + '页)【' + cat + '】(按此选择)') u = sys.argv[0] + "?mode=9&name=" + urllib.quote_plus( name) + "&url=" + urllib.quote_plus(url) + "&cat=" + urllib.quote_plus( cat) + "&filtrs=" + urllib.quote_plus( filtrs) + "&page=1" + "&listpage=" + urllib.quote_plus( listpage) xbmcplugin.addDirectoryItem(int(sys.argv[1]), u, li, True) link = getHttpData(p_url) if link == None: return playlist = xbmc.PlayList(0) # use Music playlist for temporary storage playlist.clear() # fetch and build the video series episode list content = simplejson.loads(link) vlist = content['data_list'] totalItems = len(vlist) for i in range(0, totalItems): vid = str(vlist[i]['vid']) v_url = 'http://www.letv.com/ptv/vplay/%s.html' % vid p_title = vlist[i]['name'].encode('utf-8') try: p_thumb = vlist[i]['images']['150*200'] except KeyError: p_thumb = vlist[i]['images']['160*120'] except: pass p_list = p_name = str(i + 1) + '. ' + p_title + ' ' p_artist = vlist[i]['actor'] if ((p_artist != None) and len(p_artist)): p_list += '[COLOR FFFF00FF][' for actor in p_artist: p_list += actor.encode('utf-8') + ' ' p_list = p_list[:-1] + '][/COLOR]' p_dx = int(vlist[i]['duration']) if (p_dx != None): p_duration = "[%02d:%02d]" % (int(p_dx / 60), (p_dx % 60)) p_list += '[COLOR FFFFFF00]' + p_duration + '[/COLOR]' p_album = vlist[i]['albumName'] if (p_album != None): p_album = p_album.encode('utf-8') p_list += '[COLOR FF00FFFF][' + p_album + '][/COLOR]' li = xbmcgui.ListItem(p_list, iconImage='', thumbnailImage=p_thumb) # li.setInfo(type = "Video", infoLabels = {"Title":p_list, "Artist":p_artist}) u = sys.argv[0] + "?mode=20" + "&name=" + urllib.quote_plus( p_list) + "&url=" + urllib.quote_plus( v_url) + "&thumb=" + urllib.quote_plus(p_thumb) xbmcplugin.addDirectoryItem(int(sys.argv[1]), u, li, False, totalItems) playlist.add(v_url, li) # Fetch and build page selection menu p_itemCount = content['data_count'] p_pageSize = 30 p_pageTotal = (p_itemCount + 29) / p_pageSize p_pageMid = int(p_pageTotal / 2) p_pageNum = int(page) if (p_pageNum <= p_pageMid): p_pageEnd = min(8, p_pageTotal) pages = range(0, p_pageEnd) p_pageFromEnd = max((p_pageTotal - 2), (p_pageEnd + 1)) else: pages = range(2) p_pageFromEnd = max((p_pageTotal - 8), 2) for x in range(p_pageFromEnd, p_pageTotal): pages.append(x) for num in pages: page = num + 1 if (page) != p_pageNum: li = xbmcgui.ListItem("... 第" + str(page) + "页") u = sys.argv[0] + "?mode=8" + "&name=" + urllib.quote_plus( name ) + "&url=" + urllib.quote_plus(url) + "&cat=" + urllib.quote_plus( cat) + "&filtrs=" + urllib.quote_plus(filtrs) + "&page=" + str( page) + "&listpage=" + urllib.quote_plus(listpage) xbmcplugin.addDirectoryItem(int(sys.argv[1]), u, li, True) xbmcplugin.setContent(int(sys.argv[1]), 'movies') xbmcplugin.endOfDirectory(int(sys.argv[1]))