def DoResolve(html): ret = [] text = '' if not 'youtube' in html: return [[None, 'Error Resolving URL']] try: import yt match = re.compile('src="http://.+?.com/v/(.+?)">').findall(html) if len(match) < 1: return DoResolve2(html) for id in match: id = id.split('?', 1)[0] video, links = yt.GetVideoInformation(id) if 'best' in video: ret.append([video['best'], '']) except: pass if len(ret) < 1: ret.append([[None, 'Error Resolving URL']]) return ret
def AddYT(name, id): video, links = yt.GetVideoInformation(id) url = video['best'] desc = video['title'] image = video['thumbnail'] AddDir(name, id, _YOUTUBE, image, desc, False, True, image)
def DoResolve2(html): ret = [] text = '' if not 'youtube' in html: return [[None, 'Error Resolving URL']] try: from simpleYT import yt match = re.compile('src="http://.+?.com/embed/(.+?)"').findall(html) for id in match: video, links = yt.GetVideoInformation(id) if 'best' in video: ret.append([video['best'], '']) except: pass if len(ret) < 1: ret.append([None, 'Error Resolving YouTube URL']) return ret
def PlayYT(id): xbmc.executebuiltin('Dialog.Show(busydialog)') video, links = yt.GetVideoInformation(id) xbmc.executebuiltin('Dialog.Close(busydialog)') if 'best' not in video: return False url = video['best'] title = video['title'] image = video['thumbnail'] liz = xbmcgui.ListItem(title, iconImage=image, thumbnailImage=image) liz.setInfo(type="Video", infoLabels={"Title": title}) windowed = utils.getSetting('PLAYBACK') == '1' APPLICATION.setResolvedUrl(url, success=True, listItem=liz, windowed=windowed)