def is_rar_enabled(): q = '{"jsonrpc": "2.0", "method": "Addons.GetAddonDetails", "params": {"addonid": "vfs.rar", "properties": ["enabled"]}, "id": 0 }' r = json.loads(xbmc.executeJSONRPC(q)) log(xbmc.executeJSONRPC(q)) if r.has_key("result") and r["result"].has_key("addon"): return r['result']["addon"]["enabled"] return True
def Search(item): # standard input try: LTV = LegendasTV() LTV.Log = log subtitles = "" languages = [] subtitles = LTV.Search(title=item['title'], tvshow=item['tvshow'], year=item['year'], season=item['season'], episode=item['episode'], lang=item['languages']) except: import traceback log("\n%s" % traceback.format_exc()) return 1 if subtitles: for it in subtitles: listitem = xbmcgui.ListItem(label=it["language_name"], label2=it["filename"], iconImage=it["rating"], thumbnailImage=it["language_flag"] ) if it["sync"]: listitem.setProperty( "sync", "true" ) else: listitem.setProperty( "sync", "false" ) if it.get("hearing_imp", False): listitem.setProperty( "hearing_imp", "true" ) else: listitem.setProperty( "hearing_imp", "false" ) url = "plugin://%s/?action=download&download_url=%s&filename=%s" % (__scriptid__, it["url"],os.path.basename(item["file_original_path"])) xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=listitem,isFolder=False)
def Search(item): # standard input try: languages = [] subtitles = LTV.Search(title=item['title'], tvshow=item['tvshow'], year=item['year'], season=item['season'], episode=item['episode'], lang=item['languages'], imdb=item['imdb']) except: import traceback log("\n%s" % traceback.format_exc(), "ERROR") return 1 if subtitles: for it in subtitles: if it['type'] == "destaque": label = "[COLOR FFDE7B18]%s[/COLOR]" % it["filename"] else: label = it["filename"] listitem = xbmcgui.ListItem(label=it["language_name"], label2=label, iconImage=it["rating"], thumbnailImage=it["language_flag"]) if it["sync"]: listitem.setProperty("sync", "true") else: listitem.setProperty("sync", "false") if it.get("hearing_imp", False): listitem.setProperty("hearing_imp", "true") else: listitem.setProperty("hearing_imp", "false") pack = "true" if it['type'] == "pack" else "false" url = "plugin://%s/?action=download&download_url=%s&filename=%s&pack=%s&lang=%s" % ( __scriptid__, it["url"], os.path.basename( item["file_original_path"]), pack, it["language_name"]) xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=listitem, isFolder=False) if item['original_title'] != "true": listitem = xbmcgui.ListItem(label="", label2=__language__(32011).encode("utf-8"), iconImage="", thumbnailImage="") searchstring = "&searchstring=%s" % item[ 'searchstring'] if item.has_key("searchstring") else "" url = "plugin://%s/?action=search&original_title=true&languages=%s%s" % ( __scriptid__, urllib.quote(",".join( item["languages"])), urllib.quote(searchstring)) xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=listitem, isFolder=False)
def Search(item): # standard input enable_rar() try: languages = [] subtitles = LTV.Search(title=item['title'], tvshow=item['tvshow'], year=item['year'], season=item['season'], episode=item['episode'], lang=item['languages'], imdb=item['imdb']) except: import traceback log("\n%s" % traceback.format_exc(), "ERROR") return 1 if subtitles: for it in subtitles: if it['type'] == "destaque": label = "[COLOR FFDE7B18]%s[/COLOR]" % it["filename"] else: label = it["filename"] listitem = xbmcgui.ListItem(label=it["language_name"], label2=label, iconImage=str(int(round(float(it["rating"])/2))), thumbnailImage=it["language_flag"] ) if it["sync"]: listitem.setProperty( "sync", "true" ) else: listitem.setProperty( "sync", "false" ) if it.get("hearing_imp", False): listitem.setProperty( "hearing_imp", "true" ) else: listitem.setProperty( "hearing_imp", "false" ) pack = "true" if it['type'] == "pack" else "false" url = "plugin://%s/?action=download&download_url=%s&filename=%s&pack=%s&lang=%s" % (__scriptid__, it["url"], os.path.basename(item["file_original_path"]), pack, it["language_name"] ) xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=listitem,isFolder=False) if item['original_title'] != "true": listitem = xbmcgui.ListItem(label="", label2=__language__( 32011 ).encode("utf-8"), iconImage="", thumbnailImage="") searchstring = "&searchstring=%s" % item['searchstring'] if item.has_key("searchstring") else "" url = "plugin://%s/?action=search&original_title=true&languages=%s%s" % ( __scriptid__, urllib.quote(",".join(item["languages"])), urllib.quote(searchstring) ) xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=listitem,isFolder=False)
def Search(item): # standard input try: languages = [] subtitles = LTV.Search( title=item["title"], tvshow=item["tvshow"], year=item["year"], season=item["season"], episode=item["episode"], lang=item["languages"], ) except: import traceback log("\n%s" % traceback.format_exc()) return 1 if subtitles: for it in subtitles: if it["type"] == "destaque": label = "[COLOR FFDE7B18]%s[/COLOR]" % it["filename"] else: label = it["filename"] listitem = xbmcgui.ListItem( label=it["language_name"], label2=label, iconImage=it["rating"], thumbnailImage=it["language_flag"] ) if it["sync"]: listitem.setProperty("sync", "true") else: listitem.setProperty("sync", "false") if it.get("hearing_imp", False): listitem.setProperty("hearing_imp", "true") else: listitem.setProperty("hearing_imp", "false") pack = "true" if it["type"] == "pack" else "false" url = "plugin://%s/?action=download&download_url=%s&filename=%s&pack=%s&lang=%s" % ( __scriptid__, it["url"], os.path.basename(item["file_original_path"]), pack, it["language_name"], ) xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=listitem, isFolder=False)
def extract_and_copy(extraction=0): for root, dirs, files in os.walk(extractPath, topdown=False): for file in files: dirfile = os.path.join(root, file) # Sanitize filenames - converting them to ASCII - and remove them from folders log("Opening file: " + dirfile, "DEBUG") with open(dirfile, 'rb') as f: FileContent = f.read() xbmcvfs.delete(dirfile) dirfile_with_path_name = normalizeString( os.path.relpath(dirfile, extractPath)) dirname, basename = os.path.split(dirfile_with_path_name) dirname = re.sub(r"[/\\]{1,10}", "-", dirname) dirfile_with_path_name = "(%s) %s" % ( dirname, basename) if len(dirname) else basename new_dirfile = os.path.join( extractPath, safeFilename(dirfile_with_path_name)) with open(new_dirfile, "w") as f: log("Writing file: " + new_dirfile, "DEBUG") f.write(FileContent) # Get the file extension ext = os.path.splitext(new_dirfile)[1][1:].lower() if ext in sub_ext and xbmcvfs.exists(new_dirfile): if not new_dirfile in subtitles: #Append the matching file subtitles.append(new_dirfile) elif ext in "rar zip" and not extraction: # Extract compressed files, extracted priorly xbmc.executebuiltin("XBMC.Extract(%s, %s)" % (new_dirfile, extractPath)) xbmc.sleep(1000) extract_and_copy(1) elif ext not in "idx": xbmcvfs.delete(new_dirfile) for dir in dirs: dirfolder = os.path.join(root, dir) xbmcvfs.rmdir(dirfolder)
def Search(item): # standard input try: LTV = LegendasTV() LTV.Log = log subtitles = "" languages = [] subtitles = LTV.Search(title=item['title'], tvshow=item['tvshow'], year=item['year'], season=item['season'], episode=item['episode'], lang=item['languages']) except: import traceback log("\n%s" % traceback.format_exc()) return 1 if subtitles: for it in subtitles: listitem = xbmcgui.ListItem(label=it["language_name"], label2=it["filename"], iconImage=it["rating"], thumbnailImage=it["language_flag"]) if it["sync"]: listitem.setProperty("sync", "true") else: listitem.setProperty("sync", "false") if it.get("hearing_imp", False): listitem.setProperty("hearing_imp", "true") else: listitem.setProperty("hearing_imp", "false") url = "plugin://%s/?action=download&download_url=%s&filename=%s" % ( __scriptid__, it["url"], os.path.basename(item["file_original_path"])) xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=listitem, isFolder=False)
def extract_and_copy(extraction=0): for root, dirs, files in os.walk(extractPath, topdown=False): for file in files: dirfile = os.path.join(root, file) # Sanitize filenames - converting them to ASCII - and remove them from folders log("Opening file: "+dirfile, "DEBUG") with open(dirfile,'rb') as f: FileContent = f.read() xbmcvfs.delete(dirfile) dirfile_with_path_name = normalizeString(os.path.relpath(dirfile, extractPath)) dirname, basename = os.path.split(dirfile_with_path_name) dirname = re.sub(r"[/\\]{1,10}","-", dirname) dirfile_with_path_name = "(%s) %s" % (dirname, basename) if len(dirname) else basename new_dirfile = os.path.join(extractPath, safeFilename(dirfile_with_path_name)) with open(new_dirfile, "w") as f: log("Writing file: "+new_dirfile, "DEBUG") f.write(FileContent) # Get the file extension ext = os.path.splitext(new_dirfile)[1][1:].lower() if ext in sub_ext and xbmcvfs.exists(new_dirfile): if not new_dirfile in subtitles: #Append the matching file subtitles.append(new_dirfile) elif ext in "rar zip" and not extraction: # Extract compressed files, extracted priorly xbmc.executebuiltin("XBMC.Extract(%s, %s)" % (new_dirfile, extractPath)) xbmc.sleep(1000) extract_and_copy(1) elif ext not in "idx": xbmcvfs.delete(new_dirfile) for dir in dirs: dirfolder = os.path.join(root, dir) xbmcvfs.rmdir(dirfolder)
paramstring = string if len(paramstring) >= 2: params = paramstring cleanedparams = params.replace('?', '') if (params[len(params) - 1] == '/'): params = params[0:len(params) - 2] pairsofparams = cleanedparams.split('&') param = {} for i in range(len(pairsofparams)): splitparams = {} splitparams = pairsofparams[i].split('=') if (len(splitparams)) == 2: param[splitparams[0]] = splitparams[1] return param params = get_params() log("Version: %s" % __version__) log("Action '%s' called" % params['action']) if params['action'] == 'search' or params['action'] == 'manualsearch': item = {} item['temp'] = False item['rar'] = False item['year'] = xbmc.getInfoLabel("VideoPlayer.Year") # Year item['season'] = str(xbmc.getInfoLabel("VideoPlayer.Season")) # Season item['episode'] = str(xbmc.getInfoLabel("VideoPlayer.Episode")) # Episode item['tvshow'] = normalizeString( xbmc.getInfoLabel("VideoPlayer.TVshowtitle")) # Show item['title'] = normalizeString( xbmc.getInfoLabel( "VideoPlayer.OriginalTitle")) # try to get original title item['file_original_path'] = urllib.unquote(
else: paramstring=string if len(paramstring)>=2: params=paramstring cleanedparams=params.replace('?','') if (params[len(params)-1]=='/'): params=params[0:len(params)-2] pairsofparams=cleanedparams.split('&') param={} for i in range(len(pairsofparams)): splitparams={} splitparams=pairsofparams[i].split('=') if (len(splitparams))==2: param[splitparams[0]]=splitparams[1] return param params = get_params() log( "Version: %s" % __version__) log( "Action '%s' called" % params['action']) if params['action'] == 'search' or params['action'] == 'manualsearch': item = {} item['temp'] = False item['rar'] = False item['year'] = xbmc.getInfoLabel("VideoPlayer.Year") # Year item['season'] = str(xbmc.getInfoLabel("VideoPlayer.Season")) # Season item['episode'] = str(xbmc.getInfoLabel("VideoPlayer.Episode")) # Episode item['tvshow'] = normalizeString(xbmc.getInfoLabel("VideoPlayer.TVshowtitle")) # Show item['title'] = normalizeString(xbmc.getInfoLabel("VideoPlayer.OriginalTitle")) # try to get original title item['file_original_path'] = urllib.unquote(xbmc.Player().getPlayingFile().decode('utf-8')) # Full path of a playing file item['languages'] = [] #['scc','eng'] item["languages"].extend(urllib.unquote(params['languages']).decode('utf-8').split(",")) item["original_title"] = "true" if params.has_key("original_title") else "false"
if (params[len(params)-1]=='/'): params=params[0:len(params)-2] pairsofparams=cleanedparams.split('&') param={} for i in range(len(pairsofparams)): splitparams={} splitparams=pairsofparams[i].split('=') if (len(splitparams))==2: param[splitparams[0]]=splitparams[1] return param params = get_params() if params['action'] == 'search': log( "action 'search' called") item = {} item['temp'] = False item['rar'] = False item['year'] = xbmc.getInfoLabel("VideoPlayer.Year") # Year item['season'] = str(xbmc.getInfoLabel("VideoPlayer.Season")) # Season item['episode'] = str(xbmc.getInfoLabel("VideoPlayer.Episode")) # Episode item['tvshow'] = normalizeString(xbmc.getInfoLabel("VideoPlayer.TVshowtitle")) # Show item['title'] = normalizeString(xbmc.getInfoLabel("VideoPlayer.OriginalTitle"))# try to get original title item['file_original_path'] = urllib.unquote(xbmc.Player().getPlayingFile().decode('utf-8'))# Full path of a playing file item['languages'] = [] #['scc','eng'] item["languages"].extend(urllib.unquote(params['languages']).decode('utf-8').split(",")) if len(item["languages"]) > 1: for x, lang in enumerate(item["languages"]): if lang == u"Portuguese (Brazil)":