This repository has been archived by the owner on May 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
下载器.pyw
131 lines (99 loc) · 3.38 KB
/
下载器.pyw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import requests, os, time, random
from 目录编辑器 import removeItem
from datetime import datetime
from time import strftime
from pytz import timezone
def main():
filePath = "index.txt"
file = open(filePath, "r")
videoList = processFile(file)
download(videoList)
def processFile(file):
vNL, iNL, eL = [], [], []
for line in file.readlines():
vN, iN, e = line.split(" ")
if "\n" in e:
e = e[:-1]
vNL.append(vN)
iNL.append(iN)
eL.append(e)
videoList = []
for i in range(len(vNL)):
videoList.append([iNL[i], eL[i], vNL[i]])
return videoList
def download(videoList):
for l in videoList:
episode, indexNumber = l[1], l[0]
attempt = True
url = "http://diaodiaode.me/rss/feed/" + str(indexNumber)
r = requests.get(url)
if episode == "S00E00":
index = r.text.find("中英字幕")
else:
episode1 = str(episode) + ".中英字幕"
index = r.text.find(episode1)
if index == -1:
episode = str(episode) + ".END.中英字幕"
index = r.text.find(episode)
if index == -1:
attempt = False
if attempt:
text = r.text[index:]
index1 = text.find("<magnet>")
index2 = text.find("</magnet>")
magnetLink = text[index1 + 8:index2]
os.startfile(magnetLink)
changeFile(l[1], l[0], l[2], videoList)
createLog(l[1], l[2])
def createLog(episode, videoName):
filePath = "log.txt"
file = open(filePath, "r")
lines = file.readlines()
file.close()
oldLine = []
for line in lines:
if "\n" in line:
line = line[:-1]
oldLine.append(line)
time = datetime.now(timezone("Asia/Shanghai")).strftime("%Y-%m-%d %H:%M:%S")
newLine = time + " GMT+8 " + videoName + " " + episode
oldLine.append(newLine)
lines = oldLine
file = open(filePath, "w")
for line in lines:
print(line, file = file)
file.close()
def changeFile(episode, indexNumber, videoName, videoList):
r = requests.get("http://diaodiaode.me/rss/feed/" + str(indexNumber))
if episode == "S00E00" or r.text.find("本剧完结") != -1:
removeItem(indexNumber)
createLog("Removed", videoName)
else:
oldEpisode = episode
episode = episode[1:]
season, episode = episode.split("E")
if r.text.find("连载中") != -1:
episode = int(episode) + 1
elif r.text.find("季完结") != -1:
season = int(season) + 1
episode = 1
if len(str(season)) == 1:
sN = "0" + str(season)
else:
sN = str(season)
if len(str(episode)) == 1:
eN = "0" + str(episode)
else:
eN = str(episode)
episode = "S" + sN + "E" + eN
index = videoList.index([indexNumber, oldEpisode, videoName])
videoList[index] = [indexNumber, episode, videoName]
file = open("index.txt", "w")
for i in range(len(videoList)):
print(videoList[i][2] + " " + videoList[i][0] + " " + videoList[i][1],
file = file)
file.close()
if __name__ == "__main__":
while True:
main()
time.sleep(random.randrange(1, 15) * 60)