python 自动启动迅雷任务(1)

1.让电脑自己打开

https://answers.microsoft.com/zh-hans/windows/forum/windows_7-hardware/windows-7/2e9e1884-f517-436c-b112-558768e4035a

https://jingyan.baidu.com/article/f96699bb012a66894e3c1bfe.html

2.让电脑自己打开python的下载脚本

https://www.cnblogs.com/LMTlmt/p/11389730.html

保存成.bat

python -i F:\xunleiDowload\dowload.py

 放入

C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup)下

 

3.让迅雷自动打开

设置里面有,选一下就可以了

4.让python自动让迅雷开启下载

import os

#下载的目录
save_path = "F:/迅雷下载的目录地址" 
downUrl='ftp://ygdy8:ygdy8@yg18.dydytt.net:7012/阳光电影www.ygdy8.com.饥饿站台.BD.1080p.中英双字幕.mkv'
def get_filename(url):
    return os.path.split(url)[1]

fileNames = get_filename(downUrl)

print(fileNames)

def check_start(filename):
    cache_file = filename+".xltd"
    return os.path.exists(os.path.join(save_path,cache_file))

def check_end(fiename):
    return os.path.exists(os.path.join(save_path,fiename))

isFinish = not check_end(fileNames)
isExist = not check_start(fileNames)
if(isExist):
    #如果这个任务不存在
    print('开始')
    #迅雷exe的目录地址
    os.system("\"D:\\Program\\Thunder.exe\" -StartType:DesktopIcon %s"%downUrl)
else:
    if(isFinish):
        print('继续')
        #没有继续开启任务的命令,没找到,开机自动继续 迅雷里面可以设置的

 

但是有个问题,脚本先运行了,但是迅雷没有启动。

给脚本加一个延时

import time

等待10秒,自己改时间
time.sleep(10)

 

posted on 2020-03-24 21:50  chenyi4  阅读(870)  评论(0编辑  收藏  举报

导航