def PlayVideo(_url, select): resolved = resolve.ResolveURL(_url) if len(resolved) == 0: url = None msg = 'Unidentified Video Host' else: index = GetLinkIndex(resolved, select) if index == None: xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, xbmcgui.ListItem('')) return resolver = resolved[index][0] url = resolved[index][1] msg = resolved[index][2] if url: url = url.split('"')[0] url = url.replace(' ', '%20') if not url: d = xbmcgui.Dialog() d.ok(TITLE + ' - ' + VERSION, '', msg, '') print 'WATCHCARTOONSONLINE - (%s) Failed to locate video for %s' % ( msg, _url) return html = common.getHTML(_url) image = re.compile('"image_src" href="(.+?)"').search(html).group(1) title = re.compile('<title>(.+?)</title>').search(html).group(1).split( ' |', 1)[0] title = common.clean(title) liz = xbmcgui.ListItem(title, iconImage=image, thumbnailImage=image) liz.setInfo(type="Video", infoLabels={"Title": title}) liz.setProperty("IsPlayable", "true") if int(sys.argv[1]) == -1: pl = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) pl.clear() pl.add(url, liz) xbmc.Player().play(pl) else: liz.setPath(url) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
def DownloadVideo(_url, title): resolved = resolve.ResolveURL(_url) title = utils.clean(title) if len(resolved) == 0: d = xbmcgui.Dialog() d.ok(TITLE + ' - ' + VERSION, 'Unable to download', title, 'Cannot find an online source') return auto = ADDON.getSetting('DOWNLOAD_AUTO') index = GetLinkIndex(resolved, not auto) if index < 0: return url = resolved[index][1] file = urllib.unquote_plus(url.rsplit('/')[-1]) file = utils.fileSystemSafe(file) folder = ADDON.getSetting('DOWNLOAD_FOLDER') if len(folder) == 0: folder = 'special://profile/addon_data/plugin.video.watchcartoononline/downloads' import sfile if not sfile.exists(folder): sfile.makedirs(folder) file = os.path.join(folder, file) try: import download download.download(url, file, title) except Exception, e: print '%s - %s Error during downloading of %s' % (TITLE, VERSION, title) print str(e)
def PlayVideo(_url, select): resolved = resolve.ResolveURL(_url) if len(resolved) == 0: url = None msg = 'Unidentified Video Host' else: index = GetLinkIndex(resolved, select) if index == None: xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, xbmcgui.ListItem('')) return resolver = resolved[index][0] url = resolved[index][1] msg = resolved[index][2] if url: url = url.split('"')[0] url = url.replace(' ', '%20') if not url: d = xbmcgui.Dialog() d.ok(TITLE + ' - ' + VERSION, '', msg, '') print 'WATCHCARTOONSONLINE - (%s) Failed to locate video for %s' % ( msg, _url) return html = utils.getHTML(_url) image = re.compile('<meta property="og:image" content="(.+?)" />').search( html).group(1) #following sometimes doesn't contain episode information :( #title = re.compile('<title>(.+?)</title>').search(html).group(1).split(' |', 1)[0] html = html.replace('title="RSD"', '') html = html.replace('title="Watch cartoons online', '') title = re.compile('title="(.+?)">').search(html).group(1) if title.startswith('Watch '): title = title.split('Watch ', 1)[-1] title = utils.clean(title) liz = xbmcgui.ListItem(title, iconImage=image, thumbnailImage=image) metaData = {'title': title} meta.GetMetaData(title, metaData) liz.setInfo(type='Video', infoLabels=metaData) liz.setProperty('IsPlayable', 'true') if int(sys.argv[1]) == -1: pl = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) pl.clear() pl.add(url, liz) #xbmc.Player().play(pl) player = XBMCPlayer() player.SetMetaData(metaData) player.play(pl) while player.isActive: player.update() xbmc.sleep(500) else: liz.setPath(url) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
def PlayVideo(_url, select): resolved = resolve.ResolveURL(_url) if len(resolved) == 0: url = None msg = 'Unidentified Video Host' else: index = GetLinkIndex(resolved, select) if index == None: xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, xbmcgui.ListItem('')) return resolver = resolved[index][0] url = resolved[index][1] msg = resolved[index][2] if url: url = url.split('"')[0] url = url.replace(' ', '%20') if not url: d = xbmcgui.Dialog() d.ok(TITLE + ' - ' + VERSION, '', msg, '') print 'WATCHCARTOONSONLINE - (%s) Failed to locate video for %s' % ( msg, _url) return html = utils.getHTML(_url) image = common.parseDOM( [x for x in re.compile('(<img.+?>)').findall(html) if "/thumb" in x], "img", ret="src") if image: image = image[0] else: image = '' title = common.parseDOM([ x.decode('utf-8') for x in re.compile('(<a.+?</a>)').findall(html) if _url in x ], "a")[0] title = utils.clean(title.encode('utf-8')) liz = xbmcgui.ListItem(title, iconImage=image, thumbnailImage=image) metaData = {'title': title} meta.GetMetaData(title, metaData) liz.setInfo(type='Video', infoLabels=metaData) liz.setProperty('IsPlayable', 'true') if int(sys.argv[1]) == -1: pl = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) pl.clear() pl.add(url, liz) # player = xbmc.Player() player = XBMCPlayer() # player = XBMCPlayer(xbmc.PLAYER_CORE_DVDPLAYER) player.SetMetaData(metaData) player.play(pl) while player.is_active: xbmc.sleep(100) else: liz.setPath(url) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)