def AddDir(name, mode, url='', image=None, isFolder=True, page=1, keyword=None, infoLabels=None, menu=None): name = utils.clean(name) if not image: image = ICON u = sys.argv[0] u += '?mode=' + str(mode) u += '&title=' + urllib.quote_plus(name) u += '&image=' + urllib.quote_plus(image) u += '&page=' + str(page) if url != '': u += '&url=' + urllib.quote_plus(url) if keyword: u += '&keyword=' + urllib.quote_plus(keyword) if infoLabels: infoLabels['title'] = name else: infoLabels = {'title': name} if mode == EPISODE: SetInfoData(name, infoLabels) if infoLabels['playcount'] == 1: menu.append(('Mark as unwatched', 'XBMC.RunPlugin(%s?mode=%d&url=%s&title=%s)' % (sys.argv[0], MARKUNWATCHED, urllib.quote_plus(url), urllib.quote_plus(name)))) else: menu.append(('Mark as watched', 'XBMC.RunPlugin(%s?mode=%d&url=%s&title=%s)' % (sys.argv[0], MARKWATCHED, urllib.quote_plus(url), urllib.quote_plus(name)))) liz = xbmcgui.ListItem(infoLabels['title'], iconImage=image, thumbnailImage=image) if menu: liz.addContextMenuItems(menu) liz.setInfo(type='Video', infoLabels=infoLabels) xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=isFolder)
def AddDir(name, mode, url='', image=None, isFolder=True, page=1, keyword=None, infoLabels=None, menu=None): name = utils.clean(name) if not image: image = ICON u = sys.argv[0] u += '?mode=' + str(mode) u += '&title=' + urllib.quote_plus(name) u += '&image=' + urllib.quote_plus(image) u += '&page=' + str(page) if url != '': u += '&url=' + urllib.quote_plus(url) if keyword: u += '&keyword=' + urllib.quote_plus(keyword) if infoLabels: infoLabels['title'] = name else: infoLabels = { 'title' : name } if mode == EPISODE: SetInfoData(name, infoLabels) if infoLabels['playcount'] == 1: menu.append(('Mark as unwatched', 'XBMC.RunPlugin(%s?mode=%d&url=%s&title=%s)' % (sys.argv[0], MARKUNWATCHED, urllib.quote_plus(url), urllib.quote_plus(name)))) else: menu.append(('Mark as watched', 'XBMC.RunPlugin(%s?mode=%d&url=%s&title=%s)' % (sys.argv[0], MARKWATCHED, urllib.quote_plus(url), urllib.quote_plus(name)))) liz = xbmcgui.ListItem(infoLabels['title'], iconImage=image, thumbnailImage=image) if menu: liz.addContextMenuItems(menu) liz.setInfo(type='Video', infoLabels=infoLabels) xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=isFolder)
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('"image_src" href="(.+?)"').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(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)
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)