0

我使用 python 很糟糕,但我正在努力学习。所以我有一个脚本可以为我提取 .zip 和 .rar 文件,并且可以完美运行,现在我唯一想要实现的是,如果脚本提取 .zip 或 .rar 我希望它使用 Pushbullet 发送通知到我的手机。这是通过pushbullet.py实现的

无论如何,这是目前的脚本:

import os
from subprocess import check_call
from os.path import join
from pushbullet import Pushbullet
from pyunpack import Archive

pb = Pushbullet("APIkey")
path = "/mnt/synology/Torrents/completed"
for root, dirs, files in os.walk(path):
    if not any(f.endswith(".mkv") for f in files):
        for file in files:
            pth = join(root, file)
            found_r = False
            try:
                 if file.endswith(".zip"):
                    push = pb.push_note("NUC", "Extracting")
                    Archive(pth).extractall(root)
                    found_zip = True
                 elif not found_r and file.endswith((".rar")):
                     push = pb.push_note("NUC", "Extracting")
                     Archive(pth).extractall(root)
                     found_r = True
                     break

            except:
                pass

所以现在它会在它找到的每场比赛中推送到我的手机,这是很多比赛,而不是我想要的。我希望它推动成功的提取。

有谁知道解决方案?

4

0 回答 0