-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathMBili.py
153 lines (126 loc) · 3.86 KB
/
MBili.py
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import os
import shutil
import sys
import time
import pyperclip
import requests
from selenium.webdriver.common.by import By
import BUtils
import Maintainace
import MyUtils
# 压力测试
# 多作者、多P
# 组织方式约定:
# ./bili/upUID/
# 视频标题_BV********.jpg(png),
# 分P标题.MP4,简介内容.txt。字幕文件
videospectrum = BUtils.videospectrum
videouserspectrum = BUtils.videouserspectrum
videouserexpired = BUtils.videouserexpired
coverspectrum = BUtils.coverspectrum
downloadedindisk = BUtils.downloadedindisk
missing = BUtils.missing
# 记录操作盘user、pieces
def makerecord():
length1 = videospectrum.length()
f = []
for i in MyUtils.listdir('./bili'):
f.append(i[i.rfind('_') + 1:])
for k in MyUtils.listdir(i):
j = MyUtils.filename(k)
num = (BUtils.filenametonum(j))
title = j[:-len('_' + num)]
videospectrum.addpiece(num, BUtils.filenametonum(i), title)
MyUtils.log('user: ', len(f))
MyUtils.log(f'{length1}->{videospectrum.length()}')
# 打开VideoUser,决定User是否要expire
def checkweb():
page = MyUtils.edge()
count = 0
for i in range(videouserspectrum.length()):
num = videouserspectrum.get()
count += 1
page.execute_script(f"window.open('https://space.bilibili.com/{num}')")
print(num)
if count >= 20:
break
expire()
# 立刻从Expired更新UserList
def expire():
while True:
num = input('请输入expire编号:')
num = num.strip('?').strip('https://space.bilibili.com/')
videouserspectrum.delete(num)
videouserexpired.add(num)
MyUtils.log(f'{num} expired.')
# 删除操作盘里的作者文件
def delete():
lis = []
for i in videouserexpired.l:
dirs = MyUtils.listdir('./bili')
for k in dirs:
num = k[k.rfind('_') + 1:]
if num == i:
lis.append(k)
print(f'操作盘中存在的作者: {lis}')
MyUtils.deletedirandfile(lis)
# 立刻命令行添加用户
def adduser():
BUtils.add()
# 反向从操作盘中检查申明
def checkisindisk():
def func(tuple):
(uid, au, ti, d1, d) = tuple
b = False
for i in MyUtils.listdir('./bili'):
if MyUtils.tellstringsame(i, au):
b = True
break
if b == False:
MyUtils.delog(f'不存在{d}{222}')
return False
for j in MyUtils.listdir(i):
if MyUtils.tellstringsame(MyUtils.filename(j), f'{ti}_{uid}'):
MyUtils.delog(f'存在{d}')
return True
MyUtils.delog(f'不存在{d1}{(MyUtils.listdir(i), f"{ti}_{uid}")}')
return False
Maintainace.checkisindisk(videospectrum, func)
def countdownloaded():
count = 0
for i in MyUtils.listdir('./bili'):
for j in MyUtils.listdir(i):
count += 1
MyUtils.log(f'已下载个数:{count}')
def countrecord():
MyUtils.log(f'记录总数:{videospectrum.length()}')
def count():
# 15024
countrecord()
# 1224
countdownloaded()
# 可能产生的错误,视频作者归并错了
# 先查用户所有的bv号,再核对,没有的报错,然后进行人工检查
def mistake():
for i in MyUtils.listdir('./bili'):
if 'bili/cache' in i:
continue
author,useruid=MyUtils.splittail(i,'_')
author=MyUtils.gettail(author,'/')
up=BUtils.up(useruid,author)
vlist=[]
for j in up.vlist:
vlist.append(j.bvid)
for j in MyUtils.listdir(i):
bvid=MyUtils.gettail(j,'_')
if not bvid in vlist:
MyUtils.warn(f'{author} {bvid}')
if __name__ == '__main__':
# count()
# adduser()
# checkweb()
# delete()
# checkisindisk()
mistake()
# makerecord()
pass