def incomplete(): log("incomplete:") active_nzbname_list, nzbname_list = nzbname_lists() nzoid_history_list = [x[1] for x in nzbname_list if x[1] is not None] for row in active_nzbname_list: url = "&nzoid=" + str(row[1]) + "&nzbname=" + utils.quote_plus(row[0]) +\ "&nzoidhistory_list=" + utils.quote_plus(';'.join(nzoid_history_list)) +\ "&folder=" + utils.quote_plus(row[0]) info = nfo.ReadNfoLabels(utils.join(INCOMPLETE_FOLDER, row[0])) info.info_labels['title'] = "Active - " + info.info_labels['title'] add_posts(info.info_labels, url, MODE_INCOMPLETE_LIST, info.thumbnail, info.fanart) for row in nzbname_list: if row[1]: url = "&nzoidhistory=" + str(row[1]) + "&nzbname=" + utils.quote_plus(row[0]) +\ "&nzoidhistory_list=" + utils.quote_plus(';'.join(nzoid_history_list)) +\ "&folder=" + utils.quote_plus(row[0]) info = nfo.ReadNfoLabels(utils.join(INCOMPLETE_FOLDER, row[0])) add_posts(info.info_labels, url, MODE_INCOMPLETE_LIST, info.thumbnail, info.fanart) else: # Clean out a failed SABnzbd folder removal utils.dir_exists(utils.join(INCOMPLETE_FOLDER, row[0]), None) xbmcplugin.setContent(HANDLE, 'movies') xbmcplugin.endOfDirectory(HANDLE, succeeded=True, cacheToDisc=True) return
def playlist_item(play_list, rar_file_list, folder, sab_nzo_id, sab_nzo_id_history): log("playlist_item: play_list: %s rar_file_list: %s folder: %s sab_nzo_id: %s sab_nzo_id_history: %s" %\ (play_list, rar_file_list, folder, sab_nzo_id, sab_nzo_id_history)) new_play_list = play_list[:] for arch_rar, movie_file in zip(play_list[0::2], play_list[1::2]): info = nfo.ReadNfoLabels(folder) xurl = "%s?mode=%s" % (sys.argv[0],MODE_LIST_PLAY) url = (xurl + "&nzoid=" + str(sab_nzo_id) + "&nzoidhistory=" + str(sab_nzo_id_history)) +\ "&play_list=" + utils.quote_plus(';'.join(new_play_list)) + "&folder=" + utils.quote_plus(folder) +\ "&file_list=" + utils.quote_plus(';'.join(rar_file_list)) new_play_list.remove(arch_rar) new_play_list.remove(movie_file) item = xbmcgui.ListItem(movie_file, iconImage='DefaultVideo.png', thumbnailImage=info.thumbnail) item.setInfo(type="Video", infoLabels=info.info_labels) item.setProperty("Fanart_Image", info.fanart) item.setPath(url) isfolder = False # item.setProperty("IsPlayable", "true") cm = [] if sab_nzo_id_history: cm_url_repair = sys.argv[0] + '?' + "mode=repair" + "&nzoidhistory=" + str(sab_nzo_id_history) + "&folder=" + utils.quote_plus(folder) cm.append(("Repair" , "XBMC.RunPlugin(%s)" % (cm_url_repair))) cm_url_delete = sys.argv[0] + '?' + "mode=delete" + "&nzoid=" + str(sab_nzo_id) + "&nzoidhistory=" + str(sab_nzo_id_history) + "&folder=" + utils.quote_plus(folder) cm.append(("Delete" , "XBMC.RunPlugin(%s)" % (cm_url_delete))) item.addContextMenuItems(cm, replaceItems=True) xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=isfolder) xbmcplugin.setContent(HANDLE, 'movies') xbmcplugin.endOfDirectory(HANDLE, succeeded=True, cacheToDisc=True) return
def incomplete(): active_nzbname_list = [] m_nzbname_list = [] m_row = [] for folder in os.listdir(INCOMPLETE_FOLDER): sab_nzo_id = SABNZBD.nzo_id(folder) if not sab_nzo_id: m_row.append(folder) m_row.append(None) m_nzbname_list.append(m_row) m_row = [] else: m_row.append(folder) m_row.append(sab_nzo_id) active_nzbname_list.append(m_row) m_row = [] nzbname_list = SABNZBD.nzo_id_history_list(m_nzbname_list) nzoid_history_list = [x[1] for x in nzbname_list if x[1] is not None] for row in active_nzbname_list: url = "&nzoid=" + str(row[1]) + "&nzbname=" + urllib.quote_plus(row[0]) +\ "&nzoidhistory_list=" + urllib.quote_plus(';'.join(nzoid_history_list)) +\ "&folder=" + urllib.quote_plus(row[0]) info = nfo.ReadNfoLabels(os.path.join(INCOMPLETE_FOLDER, row[0])) info.info_labels['title'] = "Active - " + info.info_labels['title'] add_posts(info.info_labels, url, MODE_INCOMPLETE_LIST, info.thumbnail, info.fanart) for row in nzbname_list: if row[1]: url = "&nzoidhistory=" + str(row[1]) + "&nzbname=" + urllib.quote_plus(row[0]) +\ "&nzoidhistory_list=" + urllib.quote_plus(';'.join(nzoid_history_list)) +\ "&folder=" + urllib.quote_plus(row[0]) info = nfo.ReadNfoLabels(os.path.join(INCOMPLETE_FOLDER, row[0])) add_posts(info.info_labels, url, MODE_INCOMPLETE_LIST, info.thumbnail, info.fanart) xbmcplugin.setContent(HANDLE, 'movies') xbmcplugin.endOfDirectory(HANDLE, succeeded=True, cacheToDisc=True) return
def list_local(params): log("list_local: params: %s" % params) top_folder = utils.unquote_plus(params.get("folder")) type = utils.unquote_plus(params.get("type")) for folder in utils.listdir_dirs(top_folder): folder_path = utils.join(top_folder, folder) # Check if the folder contains a single nzb and no folders nzb_list = [] folder_list = [] for file in utils.listdir_files(folder_path): file_path = utils.join(folder_path, file) ext = os.path.splitext(file_path)[1] if ext == '.nzb' or ext == '.gz' or ext == '.zip': nzb_list.append(file_path) for sub_folder in utils.listdir_dirs(folder_path): folder_list.append(sub_folder) # If single nzb allow the folder to be playable and show info if len(nzb_list) == 1 and len(folder_list) == 0: # Fixing the naming of nzb according to SAB rules nzb_name = m_nzb.Nzbname(os.path.basename(nzb_list[0])).final_name if folder.lower() == nzb_name.lower(): info = nfo.ReadNfoLabels(folder_path) info.info_labels['title'] = info.info_labels['title'] url = "&nzbname=" + utils.quote_plus(nzb_name) +\ "&nzb=" + utils.quote_plus(nzb_list[0]) + "&type=" + type add_posts(info.info_labels, url, MODE_LOCAL_FILE_IN_DIR, info.thumbnail, info.fanart, False) else: url = "&type=" + type + "&folder=" + utils.quote_plus( folder_path) add_posts({'title': folder}, url, MODE_LOCAL_LIST, '', '') else: url = "&type=" + type + "&folder=" + utils.quote_plus(folder_path) add_posts({'title': folder}, url, MODE_LOCAL_LIST, '', '') for file in utils.listdir_files(top_folder): ext = os.path.splitext(file)[1] if ext == '.nzb' or ext == '.gz' or ext == '.zip': file_path = utils.join(top_folder, file) url = "&nzbname=" + utils.quote_plus(m_nzb.Nzbname(file).final_name) +\ "&nzb=" + utils.quote_plus(file_path) + "&type=" + type add_posts({'title': file}, url, MODE_LOCAL_FILE, '', '', False) xbmcplugin.setContent(HANDLE, 'movies') xbmcplugin.endOfDirectory(HANDLE, succeeded=True, cacheToDisc=True) return