Esempio n. 1
0
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
Esempio n. 2
0
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_PLAY, 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_PLAY, '', '', False)
    xbmcplugin.setContent(HANDLE, 'movies')
    xbmcplugin.endOfDirectory(HANDLE, succeeded=True, cacheToDisc=True)
    return
Esempio n. 3
0
def incomplete():
    log("incomplete:")
    active_nzbname_list = []
    m_nzbname_list = []
    m_row = []
    for folder in utils.listdir_dirs(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)
            log("incomplete: m_nzbname_list.append: %s" % m_row)
            m_row = []
        else:
            m_row.append(folder)
            m_row.append(sab_nzo_id)
            active_nzbname_list.append(m_row)
            log("incomplete: active_nzbname_list: %s" % 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=" + 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
Esempio n. 4
0
def nzbname_lists():
    log("nzbname_lists:")
    active_nzbname_list = []
    m_nzbname_list = []
    m_row = []
    for folder in utils.listdir_dirs(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)
            log("incomplete: m_nzbname_list.append: %s" % m_row)
            m_row = []
        else:
            m_row.append(folder)
            m_row.append(sab_nzo_id)
            active_nzbname_list.append(m_row)
            log("incomplete: active_nzbname_list: %s" % m_row)
            m_row = []
    nzbname_list = sabnzbd.nzo_id_history_list(m_nzbname_list)
    return active_nzbname_list, nzbname_list
Esempio n. 5
0
def nzbname_lists():
    log("nzbname_lists:")
    active_nzbname_list = []
    m_nzbname_list = []
    m_row = []
    for folder in utils.listdir_dirs(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)
            log("incomplete: m_nzbname_list.append: %s" % m_row)
            m_row = []
        else:
            m_row.append(folder)
            m_row.append(sab_nzo_id)
            active_nzbname_list.append(m_row)
            log("incomplete: active_nzbname_list: %s" % m_row)
            m_row = []
    nzbname_list = sabnzbd.nzo_id_history_list(m_nzbname_list)
    return active_nzbname_list, nzbname_list