Esempio n. 1
0
            exit()
        PreDirList = []
        if (PreDirDirectMode == 0):
            for i in PreList:
                PreDirList.append(str(i))
        elif (PreDirDirectMode == 1):
            for i in PreList:
                PreDirList.append("")
    PreList.append(0)
    PreDirList.append("0")
else:
    Avalon.info("正在以交互模式运行 " + str(datetime.datetime.now()))

if not (Server):
    try:
        Work_path = Avalon.gets("请输入工作目录(备份文件父目录),为空或错误则为当前目录:")
    except KeyboardInterrupt:
        Avalon.error("Control-C,exiting", front="\n")
        if (exe_mode):
            input("按回车键退出...")
        sys.exit()
if (Server):
    if (Auto_Clean):
        Avalon.info("自动清理已开启,将会自动删除" + str(Auto_Clean_time) + "天前的备份文件")

not_work_path = False
exe_path = os.getcwd()

if (os.path.exists(Work_path)):
    try:
        os.chdir(Work_path)
Esempio n. 2
0
            if (not Avalon.ask("确认无误?", True)):
                Avalon.warning("请重新输入")
            else:
                break
        else:
            PreSet = False
            break
    except KeyboardInterrupt:
        ForceStop()
        Avalon.error("Control-C,exiting", front="\n")
        exit(0)

while (1):
    try:
        try:
            pid = int((Avalon.gets("请输入帖子链接或id(输入0退出):").split('/')
                       )[-1].split('?')[0])
        except Exception:
            Avalon.warning("未找到正确的id")
            continue
        if (pid == 0):
            exit(0)
        Avalon.info("id:%d" % pid)
        title = GetTitle(pid)
        title["forum"] = re.sub(r"[\/\\\:\*\?\"\<\>\|]", "_", title["forum"])
        title["post"] = re.sub(r"[\/\\\:\*\?\"\<\>\|]", "_", title["post"])
        if (not PreSet):
            lz = Avalon.ask("只看楼主?", False)
            comment = (0 if lz else Avalon.ask("包括评论?", True))
            DirName = Avalon.gets("文件夹名(空则表示使用\"吧名\\标题\"):")
            OutputHTML = Avalon.ask("输出HTML(否则表示输出Makrdown)?:", True)
Esempio n. 3
0
     if len(DirName) == 0:
         DirName = title["forum"] + "-" + title["post"]
         DirName = re.sub(r'(/|\\|\?|\||\*|\:|\"|\<|\>|\.)', '',
                          DirName)  # 去除不能当文件夹名的字符
     Avalon.info("id: %d , 选定: %s && %s评论 , 目录: \"%s\"" %
                 (pid, ("楼主" if lz else "全部"),
                  ("全" if comment else "无"), DirName))
     Init(pid, overwrite, DirName)
     GetPost(pid, lz, comment)
     Done()
     ConvertAudio(DirName)
 except KeyboardInterrupt:
     ForceStop()
     Avalon.error("Raised Control-C", front="\n")
     write_err_info()
     t_in = Avalon.gets("请选择:1.退出程序  2.退出当前帖子\n", front="\n")
     if "1" in t_in:
         exit(0)
     elif "2" in t_in:
         continue
     else:
         continue
 except UserCancelled:
     Avalon.warning("用户取消")
 except RequestError as err:
     err = err.data
     Avalon.error("百度贴吧API返回错误,代码:%d\n描述:%s" %
                  (err["code"], err["msg"]),
                  front="\n")
 except Exception:
     ForceStop()