Merge branch 'master' of https://github.com/flt6/tools
Former-commit-id: c9a9f6cc7aa382d71b8fe2fd89554c4112a5c427 Former-commit-id: e8a46880629de9fecdccaad33c030c7793bbbde2
This commit is contained in:
1
English_Listening_cut/a.exe.REMOVED.git-id
Normal file
1
English_Listening_cut/a.exe.REMOVED.git-id
Normal file
@ -0,0 +1 @@
|
||||
6f720344bc9ccc140bde874d65b7173131ca7e99
|
87
English_Listening_cut/main.py
Normal file
87
English_Listening_cut/main.py
Normal file
@ -0,0 +1,87 @@
|
||||
from sys import argv,exit
|
||||
from pydub import AudioSegment,silence
|
||||
from os import path,mkdir,system
|
||||
from shutil import rmtree
|
||||
from traceback import print_exc
|
||||
|
||||
|
||||
def init():
|
||||
if len(argv) != 2:
|
||||
print("Usage: a.py file.mp3")
|
||||
exit(1)
|
||||
return argv[1]
|
||||
# return "新课程外研高一第32期.mp3"
|
||||
|
||||
def make_dir(pth:str):
|
||||
if not path.isdir(pth):
|
||||
try:
|
||||
mkdir(pth)
|
||||
except PermissionError:
|
||||
print("Could not create directory '{pth}' because of permission error.".format(pth=pth))
|
||||
exit(-1)
|
||||
else:
|
||||
ipt=input(f"'{pth}' exists. Remove it [YES/no]: ")
|
||||
if ipt == "" or ipt == "yes":
|
||||
try:
|
||||
rmtree(pth)
|
||||
except PermissionError:
|
||||
print("Could not remove '{pth}' because of permission error.".format(pth=pth))
|
||||
exit(-1)
|
||||
mkdir(pth)
|
||||
else:
|
||||
print(f"Warning: Directory '{pth}' exists, which may influence the programm!")
|
||||
|
||||
def cut(file:AudioSegment,length:list[int],keep=300) -> AudioSegment:
|
||||
maxlen = len(file)
|
||||
bgn,end=length
|
||||
if bgn-keep>=0:
|
||||
bgn-=keep
|
||||
if end+keep<=maxlen:
|
||||
end+=keep
|
||||
return file[bgn:end]
|
||||
|
||||
def main():
|
||||
file = init()
|
||||
NAMES=["BASIC", "1-5", "Others"]
|
||||
make_dir("OUTPUT")
|
||||
for i in NAMES:
|
||||
make_dir(f"OUTPUT/{i}")
|
||||
print("Reading file ...")
|
||||
file:AudioSegment = AudioSegment.from_file(file)
|
||||
print("Detecting audio segments ...")
|
||||
arr=silence.detect_nonsilent(
|
||||
file,
|
||||
silence_thresh=-100,
|
||||
seek_step=500,
|
||||
min_silence_len=4000
|
||||
)
|
||||
print("Cutting audio segments ...")
|
||||
group=[]
|
||||
groups=[]
|
||||
|
||||
groups.append([(cut(file,arr[0]),'info'),(cut(file,arr[1]),'example')])
|
||||
for i in range(2,2+5):
|
||||
group.append((cut(file,arr[i]),str(i-1)))
|
||||
groups.append(group)
|
||||
group=[]
|
||||
for i in range(7,len(arr)-1,2):
|
||||
group.append((cut(file,arr[i]),f"Tips_of_{(i-7)//2+6}"))
|
||||
group.append((cut(file,arr[i+1]),f"Text_{(i-7)//2+6}"))
|
||||
groups.append(group)
|
||||
for i,group in enumerate(groups):
|
||||
print(f"Saving audio segments '{NAMES[i]}' ...")
|
||||
for f,name in group:
|
||||
f.export(f"OUTPUT/{NAMES[i]}/{name}.mp3")
|
||||
print("Done!")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
main()
|
||||
except SystemExit:
|
||||
system("pause")
|
||||
except KeyboardInterrupt as e:
|
||||
raise e
|
||||
except Exception:
|
||||
print("An unexpected exception occurred.")
|
||||
print_exc()
|
88
English_Listening_cut/main_json.py
Normal file
88
English_Listening_cut/main_json.py
Normal file
@ -0,0 +1,88 @@
|
||||
from sys import argv,exit
|
||||
from pydub import AudioSegment,silence
|
||||
from os import path,mkdir,system
|
||||
from shutil import rmtree
|
||||
from traceback import print_exc
|
||||
from json import dumps,loads
|
||||
|
||||
|
||||
def init():
|
||||
if len(argv) != 2:
|
||||
print("Usage: a.py file.mp3")
|
||||
exit(1)
|
||||
return argv[1]
|
||||
# return "新课程外研高一第32期.mp3"
|
||||
|
||||
def make_dir(pth:str):
|
||||
if not path.isdir(pth):
|
||||
try:
|
||||
mkdir(pth)
|
||||
except PermissionError:
|
||||
print("Could not create directory '{pth}' because of permission error.".format(pth=pth))
|
||||
exit(-1)
|
||||
else:
|
||||
ipt=input(f"'{pth}' exists. Remove it [YES/no]: ")
|
||||
if ipt == "" or ipt == "yes":
|
||||
try:
|
||||
rmtree(pth)
|
||||
except PermissionError:
|
||||
print("Could not remove '{pth}' because of permission error.".format(pth=pth))
|
||||
exit(-1)
|
||||
mkdir(pth)
|
||||
else:
|
||||
print(f"Warning: Directory '{pth}' exists, which may influence the programm!")
|
||||
|
||||
def cut(file:AudioSegment,length:list[int],keep=300) -> AudioSegment:
|
||||
maxlen = len(file)
|
||||
bgn,end=length
|
||||
if bgn-keep>=0:
|
||||
bgn-=keep
|
||||
if end+keep<=maxlen:
|
||||
end+=keep
|
||||
return file[bgn:end]
|
||||
|
||||
def main():
|
||||
file = init()
|
||||
NAMES=["BASIC", "1-5", "Others"]
|
||||
make_dir("OUTPUT")
|
||||
for i in NAMES:
|
||||
make_dir(f"OUTPUT/{i}")
|
||||
print("Reading file ...")
|
||||
file:AudioSegment = AudioSegment.from_file(file)
|
||||
print("Detecting audio segments ...")
|
||||
arr=silence.detect_nonsilent(
|
||||
file,
|
||||
silence_thresh=-100,
|
||||
seek_step=500,
|
||||
min_silence_len=4000
|
||||
)
|
||||
print("Cutting audio segments ...")
|
||||
group=[]
|
||||
groups=[]
|
||||
|
||||
groups.append([(cut(file,arr[0]),'info'),(cut(file,arr[1]),'example')])
|
||||
for i in range(2,2+5):
|
||||
group.append((cut(file,arr[i]),str(i-1)))
|
||||
groups.append(group)
|
||||
group=[]
|
||||
for i in range(7,len(arr)-1,2):
|
||||
group.append((cut(file,arr[i]),f"Tips_of_{(i-7)//2+6}"))
|
||||
group.append((cut(file,arr[i+1]),f"Text_{(i-7)//2+6}"))
|
||||
groups.append(group)
|
||||
for i,group in enumerate(groups):
|
||||
print(f"Saving audio segments '{NAMES[i]}' ...")
|
||||
for f,name in group:
|
||||
f.export(f"OUTPUT/{NAMES[i]}/{name}.mp3")
|
||||
print("Done!")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
main()
|
||||
except SystemExit:
|
||||
system("pause")
|
||||
except KeyboardInterrupt as e:
|
||||
raise e
|
||||
except Exception:
|
||||
print("An unexpected exception occurred.")
|
||||
print_exc()
|
97
move_warn/t2.py
Normal file
97
move_warn/t2.py
Normal file
@ -0,0 +1,97 @@
|
||||
import cv2
|
||||
import numpy as np
|
||||
from winsound import PlaySound,SND_ALIAS,SND_ASYNC
|
||||
from time import time
|
||||
# Beep(500,500)
|
||||
|
||||
# camera = cv2.VideoCapture(0) # 参数0表示第一个摄像头
|
||||
# camera = cv2.VideoCapture("opt.flv")
|
||||
camera = cv2.VideoCapture("http://192.168.124.17:8081/live.flv")
|
||||
# 判断视频是否打开
|
||||
if (camera.isOpened()):
|
||||
print('Open')
|
||||
else:
|
||||
print('摄像头未打开')
|
||||
|
||||
# 测试用,查看视频size
|
||||
size = (int(camera.get(cv2.CAP_PROP_FRAME_WIDTH)), int(camera.get(cv2.CAP_PROP_FRAME_HEIGHT)))
|
||||
print('size:'+repr(size))
|
||||
|
||||
es = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (9, 4))
|
||||
kernel = np.ones((5, 5), np.uint8)
|
||||
background = None
|
||||
cnt = 0
|
||||
tot = 0
|
||||
last = time()
|
||||
mask = np.array([(0, 0),(282, 0),(282, 26),(0, 26)])
|
||||
|
||||
# cv2.waitKey(5)
|
||||
|
||||
while True:
|
||||
# 读取视频流
|
||||
try:
|
||||
grabbed, frame_lwpCV = camera.read()
|
||||
cv2.waitKey(5)
|
||||
cv2.fillConvexPoly(frame_lwpCV, mask,(0,255,0))
|
||||
cv2.imshow("src",frame_lwpCV)
|
||||
except cv2.error:
|
||||
print("ignore this frame")
|
||||
continue
|
||||
# 对帧进行预处理,先转灰度图,再进行高斯滤波。
|
||||
# 用高斯滤波进行模糊处理,进行处理的原因:每个输入的视频都会因自然震动、光照变化或者摄像头本身等原因而产生噪声。对噪声进行平滑是为了避免在运动和跟踪时将其检测出来。
|
||||
gray_lwpCV = cv2.cvtColor(frame_lwpCV, cv2.COLOR_BGR2GRAY)
|
||||
gray_lwpCV = cv2.GaussianBlur(gray_lwpCV, (21, 21), 0)
|
||||
# 将第一帧设置为整个输入的背景
|
||||
if background is None:
|
||||
background = gray_lwpCV
|
||||
continue
|
||||
# 对于每个从背景之后读取的帧都会计算其与北京之间的差异,并得到一个差分图(different map)。
|
||||
# 还需要应用阈值来得到一幅黑白图像,并通过下面代码来膨胀(dilate)图像,从而对孔(hole)和缺陷(imperfection)进行归一化处理
|
||||
diff = cv2.absdiff(background, gray_lwpCV)
|
||||
# cv2.imshow('abs', diff)
|
||||
diff = cv2.threshold(diff, 25, 255, cv2.THRESH_BINARY)[1] # 二值化阈值处理
|
||||
diff = cv2.dilate(diff, es, iterations=2) # 形态学膨胀
|
||||
# 显示矩形框
|
||||
contours, hierarchy = cv2.findContours(diff.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) # 该函数计算一幅图像中目标的轮廓
|
||||
contours = [c for c in contours if cv2.contourArea(c) >= 1500]
|
||||
# 对于矩形区域,只显示大于给定阈值的轮廓,所以一些微小的变化不会显示。对于光照不变和噪声低的摄像头可不设定轮廓最小尺寸的阈值
|
||||
total=0
|
||||
for c in contours:
|
||||
# if cv2.contourArea(c) < 1500:
|
||||
# continue
|
||||
total += cv2.contourArea(c)
|
||||
(x, y, w, h) = cv2.boundingRect(c) # 该函数计算矩形的边界框
|
||||
cv2.rectangle(frame_lwpCV, (x, y), (x+w, y+h), (0, 255, 0), 2)
|
||||
|
||||
cv2.imshow('contours', frame_lwpCV)
|
||||
cv2.imshow('dis', diff)
|
||||
|
||||
if len(contours)>0 and total>10000:
|
||||
cnt+=1
|
||||
if cnt > 5:
|
||||
if time()-last<5:
|
||||
print(time(),last)
|
||||
tot+=1
|
||||
else:
|
||||
print("else: ",time(),last)
|
||||
tot = 1
|
||||
last = time()
|
||||
cnt = 0
|
||||
print("################################")
|
||||
PlaySound("SystemAsterisk",SND_ALIAS|SND_ASYNC)
|
||||
background = gray_lwpCV
|
||||
else:
|
||||
cnt=cnt-1 if cnt>0 else 0
|
||||
|
||||
if tot>4:
|
||||
PlaySound("SystemHand",SND_ALIAS)
|
||||
exit()
|
||||
|
||||
key = cv2.waitKey(1) & 0xFF
|
||||
# 按'L'健退出循环
|
||||
if key == ord('L'):
|
||||
break
|
||||
|
||||
|
||||
camera.release()
|
||||
cv2.destroyAllWindows()
|
53
pinyin/gen.py
Normal file
53
pinyin/gen.py
Normal file
@ -0,0 +1,53 @@
|
||||
t='''毕思淼
|
||||
毕一聪
|
||||
丛金旺
|
||||
崔子豪
|
||||
樊乐天
|
||||
高镆
|
||||
黄卓琳
|
||||
姜樱楠
|
||||
焦祺
|
||||
李柏畅
|
||||
李南卓阳
|
||||
李善伊
|
||||
李怡萱
|
||||
李语恒
|
||||
刘宇航
|
||||
刘雨鑫
|
||||
刘卓
|
||||
娄晴
|
||||
洛艺伟
|
||||
马卉冉
|
||||
潘一鸣
|
||||
庞惠铭
|
||||
乔旺源
|
||||
沈洁
|
||||
宋佳怡
|
||||
宋雨蔓
|
||||
宋智宪
|
||||
苏振宇
|
||||
王梁宇
|
||||
王明仁
|
||||
王耀增
|
||||
王子来
|
||||
吴庆波
|
||||
徐子灏
|
||||
阎展博
|
||||
杨颜聪
|
||||
于诗澳
|
||||
于世函
|
||||
张濠亿
|
||||
张日昊
|
||||
张姝肜
|
||||
张文桦
|
||||
张潇艺
|
||||
张晓轩
|
||||
张妍
|
||||
周含笑
|
||||
周巧冉'''
|
||||
from pypinyin import pinyin
|
||||
from pypinyin import Style
|
||||
l=t.splitlines()
|
||||
for text in l:
|
||||
tem=pinyin(text,style=Style.FIRST_LETTER)
|
||||
print(''.join([i[0] for i in tem]))
|
29
rand/main.py
Normal file
29
rand/main.py
Normal file
@ -0,0 +1,29 @@
|
||||
from random import randint
|
||||
|
||||
bgn,end=[int(i) for i in input("Option: Input random area(like 21-43): ").split("-")]
|
||||
obj=int(input("Option: Amount: "))
|
||||
repeat=input("Option: Allow repeat:\nAccept: T(true) (defalt), F(false)\n").lower()
|
||||
if repeat == "":
|
||||
repeat=True
|
||||
else:
|
||||
if repeat in ["t","true"]:
|
||||
repeat=True
|
||||
elif repeat in ["f","false"]:
|
||||
repeat=False
|
||||
else:
|
||||
input("Unsupported option.")
|
||||
l=[]
|
||||
if repeat:
|
||||
l=[randint(bgn,end) for i in range(obj)]
|
||||
else:
|
||||
i=0
|
||||
while len(l)<obj and i<500:
|
||||
t=randint(bgn,end)
|
||||
i+=1
|
||||
if t not in l:
|
||||
l.append(t)
|
||||
|
||||
print(l)
|
||||
for i in l[1:]:
|
||||
print(randint(bgn,end),end=", ")
|
||||
print(l[0])
|
1
recode/Output/test.txt
Normal file
1
recode/Output/test.txt
Normal file
@ -0,0 +1 @@
|
||||
ASD¼Ñ¼ÑDSA
|
103
recode/recode.py
Normal file
103
recode/recode.py
Normal file
@ -0,0 +1,103 @@
|
||||
from sys import argv
|
||||
from os.path import isfile, isdir
|
||||
from os import mkdir
|
||||
from json import dump, load
|
||||
HELP = '''
|
||||
Usage: recode.py <options>/<filename(s)>
|
||||
Options:
|
||||
If options is specified, program will only save configs.
|
||||
|
||||
-i: input file code. (eg. utf-8) (Default: test all known codes)
|
||||
-o: output file code. (Default: utf-8)
|
||||
-c: codes that try to convert from. (Default: test all known codes)
|
||||
split by ','. (eg. utf-8,gbk,gb2312)
|
||||
-r: save the output file in the specified directory. (Default: out)
|
||||
-s: show all known codes. (Don't use this with others)
|
||||
'''
|
||||
OPTIONS = ["-i", "-o", "-c", "-s", "-r"]
|
||||
|
||||
CODES = ['ascii', 'big5', 'big5hkscs', 'cp037', 'cp273', 'cp424', 'cp437', 'cp500', 'cp720', 'cp737', 'cp775', 'cp850', 'cp852', 'cp855', 'cp856', 'cp857', 'cp858', 'cp860', 'cp861', 'cp862', 'cp863', 'cp864', 'cp865', 'cp866', 'cp869', 'cp874', 'cp875', 'cp932', 'cp949', 'cp950', 'cp1006', 'cp1026', 'cp1125', 'cp1140', 'cp1250', 'cp1251', 'cp1252', 'cp1253', 'cp1254', 'cp1255', 'cp1256', 'cp1257', 'cp1258', 'euc_jp', 'euc_jis_2004', 'euc_jisx0213', 'euc_kr', 'gb2312', 'gbk', 'gb18030', 'hz', 'iso2022_jp', 'iso2022_jp_1', 'iso2022_jp_2', 'iso2022_jp_2004',
|
||||
'iso2022_jp_3', 'iso2022_jp_ext', 'iso2022_kr', 'latin_1', 'iso8859_2', 'iso8859_3', 'iso8859_4', 'iso8859_5', 'iso8859_6', 'iso8859_7', 'iso8859_8', 'iso8859_9', 'iso8859_10', 'iso8859_11', 'iso8859_13', 'iso8859_14', 'iso8859_15', 'iso8859_16', 'johab', 'koi8_r', 'koi8_t', 'koi8_u', 'kz1048', 'mac_cyrillic', 'mac_greek', 'mac_iceland', 'mac_latin2', 'mac_roman', 'mac_turkish', 'ptcp154', 'shift_jis', 'shift_jis_2004', 'shift_jisx0213', 'utf_32', 'utf_32_be', 'utf_32_le', 'utf_16', 'utf_16_be', 'utf_16_le', 'utf_7', 'utf_8', 'utf_8_sig']
|
||||
DEFALT = {'ipt': None, 'opt': 'utf-8', 'test': None, 'write': 'out'}
|
||||
|
||||
|
||||
def setOption(arg):
|
||||
if arg[0] == '-s':
|
||||
for i in CODES:
|
||||
print("%15s" % i, end=' ')
|
||||
return
|
||||
opt = arg[::2]
|
||||
val = arg[1:][::2]
|
||||
option = DEFALT.copy()
|
||||
trans = {'-i': 'ipt', '-o': 'opt', '-c': 'test', "-r": "write"}
|
||||
for o, v in zip(opt, val):
|
||||
if o == '-c':
|
||||
option[trans[o]] = v.split(',')
|
||||
else:
|
||||
option[trans[o]] = v
|
||||
with open("config.json", "w") as f:
|
||||
dump(option, f)
|
||||
|
||||
|
||||
def main(files):
|
||||
if isfile("config.json"):
|
||||
try:
|
||||
with open("config.json", "r") as f:
|
||||
config = load(f)
|
||||
except Exception:
|
||||
print("Can't read config file.")
|
||||
config = DEFALT
|
||||
else:
|
||||
print("No config file provided.")
|
||||
config = DEFALT
|
||||
|
||||
codes = CODES if config["test"] is None else config["test"]
|
||||
outcode = config["opt"]
|
||||
outdir = config["write"]
|
||||
|
||||
if not isdir(outdir):
|
||||
mkdir(outdir)
|
||||
|
||||
for file in files:
|
||||
if isfile(outdir+'/'+file):
|
||||
print(f"File '{outdir+'/'+file} exists. Ignore.")
|
||||
continue
|
||||
if config["ipt"] is None:
|
||||
for code in codes:
|
||||
if recode(file, outdir, code, outcode, config["write"]):
|
||||
break
|
||||
else:
|
||||
if not recode(file, outdir, config["ipt"], outcode):
|
||||
print("Could not convert '%s' from '%s' to '%s'" %
|
||||
(file, config["ipt"], outcode))
|
||||
else:
|
||||
print(f"Success to convert {file}")
|
||||
|
||||
|
||||
def recode(file, opt, src, to) -> bool:
|
||||
try:
|
||||
with open(file, 'r', encoding=src) as f:
|
||||
tem = f.read()
|
||||
except KeyboardInterrupt:
|
||||
exit(2)
|
||||
except Exception:
|
||||
print("Can't open file.")
|
||||
return False
|
||||
try:
|
||||
with open(opt+'/'+file, 'w', encoding=to) as f:
|
||||
f.write(tem)
|
||||
except KeyboardInterrupt:
|
||||
exit(2)
|
||||
except Exception:
|
||||
print("Can't write file.")
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(argv) == 1:
|
||||
print(HELP)
|
||||
exit(1)
|
||||
elif argv[1] in OPTIONS:
|
||||
setOption(argv[1:])
|
||||
else:
|
||||
main(argv[1:])
|
58
recode/recode_new.py
Normal file
58
recode/recode_new.py
Normal file
@ -0,0 +1,58 @@
|
||||
from sys import argv
|
||||
from os.path import isfile, isdir,abspath
|
||||
from os import mkdir
|
||||
from chardet import detect
|
||||
from colorama import init,Fore
|
||||
HELP = '''
|
||||
Usage: recode.py <options>/<filename(s)>
|
||||
'''
|
||||
TARGET = 'utf-8'
|
||||
OUTDIR = "Output"
|
||||
|
||||
|
||||
def main(files):
|
||||
if not isdir(OUTDIR):
|
||||
mkdir(OUTDIR)
|
||||
|
||||
for file in files:
|
||||
path = abspath(file)
|
||||
path = path.replace("\\", "/")
|
||||
path = path.split('/')
|
||||
path = '/'.join(path[:-1])+"/"+OUTDIR+"/"+path[-1]
|
||||
if isfile(path):
|
||||
print(Fore.YELLOW+f"WARN: File '{path} exists. Ignore.")
|
||||
continue
|
||||
recode(file,path)
|
||||
|
||||
|
||||
def recode(file,path):
|
||||
try:
|
||||
with open(file, 'rb') as f:
|
||||
tem = f.read()
|
||||
except Exception as e:
|
||||
print(Fore.RED+f"ERROR: Can't open file '{file}'")
|
||||
return
|
||||
ret = detect(tem)
|
||||
if ret["encoding"] is None:
|
||||
print(Fore.RED+"ERROR: Cannot detect encoding of `%s`" % file)
|
||||
return
|
||||
|
||||
with open(file, 'r',encoding=ret["encoding"]) as f:
|
||||
tem = f.read()
|
||||
|
||||
if ret['confidence'] < 0.8:
|
||||
print(Fore.YELLOW+"WARN: File `%s` confidence is lower than 0.8. Recognized as `%s`."%(file,ret["encoding"]))
|
||||
|
||||
with open(path, 'w', encoding=TARGET) as f:
|
||||
f.write(tem)
|
||||
print(Fore.LIGHTBLUE_EX+"INFO: Success for `%s` with confidence %0.1f%%"%(file,ret["confidence"]*100))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
init(autoreset=True)
|
||||
if len(argv) == 1:
|
||||
print(HELP)
|
||||
else:
|
||||
main(argv[1:])
|
||||
print("------------------------")
|
||||
input("Press enter to exit")
|
1
recode/test.txt
Normal file
1
recode/test.txt
Normal file
@ -0,0 +1 @@
|
||||
ASD<EFBFBD>Ѽ<EFBFBD>DSA
|
32
video/cut.py
Normal file
32
video/cut.py
Normal file
@ -0,0 +1,32 @@
|
||||
from sys import argv
|
||||
from subprocess import run
|
||||
from os import system
|
||||
|
||||
if len(argv) != 2:
|
||||
print("Usage: <file>")
|
||||
exit(1)
|
||||
file = argv[1]
|
||||
tem=file.split(".")
|
||||
name = ".".join(tem[:-1])
|
||||
o = tem[-1]
|
||||
bgn = input("bgn: ")
|
||||
if bgn=="":
|
||||
bgn="0"
|
||||
to = input("to: ")
|
||||
cmd = [
|
||||
r'E:\green\ffmpeg\bin\ffmpeg.exe',
|
||||
'-i',
|
||||
file,
|
||||
'-ss',
|
||||
bgn,
|
||||
'-to',
|
||||
to,
|
||||
'-c',
|
||||
'copy',
|
||||
name+"_cut."+o
|
||||
]
|
||||
print(cmd)
|
||||
# run("pause")
|
||||
ret = run(cmd)
|
||||
print("ffmpeg finished with code",ret.returncode)
|
||||
system("pause")
|
75
wjx/main.py
Normal file
75
wjx/main.py
Normal file
@ -0,0 +1,75 @@
|
||||
from requests import Response,Session
|
||||
from re import search
|
||||
from json import dumps
|
||||
|
||||
headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.42'
|
||||
}
|
||||
s=Session()
|
||||
|
||||
def chk(resp:Response):
|
||||
if resp.status_code != 200:
|
||||
print("Error: %d" % resp.status_code)
|
||||
exit(1)
|
||||
return resp.text
|
||||
|
||||
def get(url,**kwargs):
|
||||
ret = s.get(url,allow_redirects=False,headers=headers,**kwargs)
|
||||
jar = ret.cookies
|
||||
if ret.status_code == 302:
|
||||
url2 = ret.headers['Location']
|
||||
return get(url2, cookies=jar)
|
||||
elif ret.status_code != 200:
|
||||
print("Error: %d" % ret.status_code)
|
||||
exit(1)
|
||||
return ret
|
||||
|
||||
def login(username, password):
|
||||
# 问卷星竟然明文发送密码
|
||||
ret = chk(s.get("https://www.wjx.cn/login.aspx"))
|
||||
v1 = search('(?<=(<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value=")).+(?=(" />))',ret)
|
||||
if v1 is not None:
|
||||
v1 = v1.group()
|
||||
v2 = search('(?<=(<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value=")).+(?=(" />))',ret)
|
||||
if v2 is not None:
|
||||
v2 = v2.group()
|
||||
v3 = search('(?<=(<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value=")).+(?=(" />))',ret)
|
||||
if v3 is not None:
|
||||
v3 = v3.group()
|
||||
print(v1,v2,v3)
|
||||
with open("tmp.html", "w",encoding="utf-8") as f:
|
||||
print(ret,file=f)
|
||||
d={
|
||||
"__VIEWSTATE": v1,
|
||||
"__VIEWSTATEGENERATOR": v2,
|
||||
"__EVENTVALIDATION": v3,
|
||||
"UserName": username,
|
||||
"Password": password,
|
||||
"LoginButton": "登录"
|
||||
}
|
||||
# d={
|
||||
# "__VIEWSTATE": "/wEPDwULLTIxMTQ1NzY4NzFkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBQpSZW1lbWJlck1ldLwU4qgz33Rji8zou8eAENNib4k=",
|
||||
# "__VIEWSTATEGENERATOR":"C2EE9ABB",
|
||||
# "__EVENTVALIDATION": "/wEdAAfxrqR6nVOy3mBYlwdwNQ3ZR1LBKX1P1xh290RQyTesRRHS0B3lkDg8wcTlzQR027xRgZ0GCHKgt6QG86UlMSuIXArz/WCefbk6V2VE3Ih52ScdcjStD50aK/ZrfWs/uQXcqaj6i4HaaYTcyD0yJuxuNMxKZaXzJnI0VXVv9OL2HZrk5tk=",
|
||||
# "UserName": username,
|
||||
# "Password": password,
|
||||
# "LoginButton": "登录"
|
||||
# }
|
||||
ret = s.post("https://www.wjx.cn/Login.aspx",json=dumps(d))
|
||||
ret.raise_for_status()
|
||||
|
||||
def getlist(id):
|
||||
ret = s.get(
|
||||
"https://www.wjx.cn/wjx/activitystat/viewstatsummary.aspx",
|
||||
params={"activity":id},
|
||||
headers=headers
|
||||
)
|
||||
ret = chk(ret)
|
||||
find = search(r'(?<=(var ids = "))[\d,]+(?=(";))',ret)
|
||||
assert find is not None,ret
|
||||
return find.group().split(",")
|
||||
|
||||
if __name__ == "__main__":
|
||||
login("flt","***REMOVED***")
|
||||
print(s.cookies)
|
||||
print(getlist("184412487"))
|
275
wjx/tmp.html
Normal file
275
wjx/tmp.html
Normal file
@ -0,0 +1,275 @@
|
||||
|
||||
|
||||
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
||||
<head id="Head1"><title>
|
||||
|
||||
登录页面_问卷星
|
||||
|
||||
</title><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE10" /><meta name="renderer" content="webkit" /><link href="/wjxUI/src/wjxUI.css?v=13" rel="stylesheet" /><link rel="stylesheet" href="/css/index.css?v=4" type="text/css" />
|
||||
|
||||
<script src="//aeu.alicdn.com/waf/antidomxss_v640.js"></script><script src="//aeu.alicdn.com/waf/interfaceacting211222.js"></script><script type="text/javascript" src="//cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
!window.jQuery && document.write('<script src="/js/jquery-1.10.2.min.js"><\/script>');
|
||||
|
||||
</script>
|
||||
|
||||
<link rel="canonical" href="https://www.wjx.cn/login.aspx" /><link rel="alternate" media="only screen and(max-width: 640px)" href="https://www.wjx.cn/mobile/login.aspx" /><meta name="applicable-device" content="pc" />
|
||||
|
||||
<style>
|
||||
|
||||
|
||||
|
||||
.wjxui-select{
|
||||
|
||||
height: 40px;
|
||||
|
||||
line-height: 1.3;
|
||||
|
||||
line-height: 40px\9;
|
||||
|
||||
border-width: 1px;
|
||||
|
||||
border-style: solid;
|
||||
|
||||
background-color: #fff;
|
||||
|
||||
border-radius:4px;
|
||||
|
||||
border-color: #D9D9D9;
|
||||
|
||||
padding-left:20px;
|
||||
|
||||
width:400px;
|
||||
|
||||
font-size:14px;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
<script src="/layer/layer.js?v=2116" type="text/javascript"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body id="body1" class="fp-viewing">
|
||||
|
||||
<form name="form" method="post" action="./login.aspx" id="form">
|
||||
|
||||
<div>
|
||||
|
||||
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTIxMTQ1NzY4NzFkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBQpSZW1lbWJlck1ldLwU4qgz33Rji8zou8eAENNib4k=" />
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div>
|
||||
|
||||
|
||||
|
||||
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="C2EE9ABB" />
|
||||
|
||||
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEdAAfxrqR6nVOy3mBYlwdwNQ3ZR1LBKX1P1xh290RQyTesRRHS0B3lkDg8wcTlzQR027xRgZ0GCHKgt6QG86UlMSuIXArz/WCefbk6V2VE3Ih52ScdcjStD50aK/ZrfWs/uQXcqaj6i4HaaYTcyD0yJuxuNMxKZaXzJnI0VXVv9OL2HZrk5tk=" />
|
||||
|
||||
</div>
|
||||
|
||||
<div class="fullpage-wrapper">
|
||||
|
||||
<div class="full-head clearfix">
|
||||
|
||||
<a href="/" id="sojumplogo" class="logo pull-left">
|
||||
|
||||
<img src="/images/index/wjx-logo@2x.png" alt="问卷星_不止问卷调查/在线考试" width="130">
|
||||
|
||||
</a>
|
||||
|
||||
<div class="member pull-right">
|
||||
|
||||
<a href="/login.aspx" class="btn btn-default btn-lg pull-left login hidden" rel="nofollow">登入</a>
|
||||
|
||||
<a href="/register/register.aspx?type=1" class="btn btn-default btn-lg pull-left register " rel="nofollow">注册</a>
|
||||
|
||||
<a href="/" class="btn btn-default btn-lg pull-left back-wjx">返回首页</a>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="fullpage-main"></div>
|
||||
|
||||
<div class="validate-box validate-nstyle" id="divSojump">
|
||||
|
||||
<fieldset class="validate-wrapper">
|
||||
|
||||
<div class="login-validate-tab">
|
||||
|
||||
<a href="/login.aspx" id="hlogintxt" class="validate-caption curtab">账号登录</a>
|
||||
|
||||
<a href="/smslogin.aspx" id="aloginMode" class="validate-caption">验证码登录</a>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<ul>
|
||||
|
||||
<li>
|
||||
|
||||
|
||||
|
||||
<input name="UserName" id="UserName" name="user-name" placeholder="用户名/Email/手机" class="validate-input user-name" type="text" onfocus="if(value=='用户名/Email/手机'){value='';}" onblur="if(value==''){value='用户名/Email/手机'}" /><input type="hidden" name="hfUserName" id="hfUserName" />
|
||||
|
||||
<div class="divclear"></div>
|
||||
|
||||
</li>
|
||||
|
||||
<li style="display:none;">
|
||||
|
||||
<select id="selUname" class="wjxui-select"></select>
|
||||
|
||||
<input type="hidden" name="hfSelUser" id="hfSelUser" />
|
||||
|
||||
</li>
|
||||
|
||||
<li>
|
||||
|
||||
<input name="Password" type="password" id="Password" placeholder="请输入登录密码" class="validate-input" />
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
<div id="trRemember" class="remember-box">
|
||||
|
||||
<span class="automatic-box pull-left wjxui-form-checkbox wjx__templet__beautifyInput">
|
||||
|
||||
|
||||
|
||||
<input name="RememberMe" type="checkbox" id="RememberMe" />
|
||||
|
||||
<label for="RememberMe">下次自动登录</label>
|
||||
|
||||
</span>
|
||||
|
||||
|
||||
|
||||
<a id="PasswordRecoveryLink" class="get-back pull-right" href="register/forgetpassword.aspx">忘记用户名/密码?</a>
|
||||
|
||||
</div>
|
||||
|
||||
<span style="color: red; line-height: 28px;">
|
||||
|
||||
</span>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="submit-wrapper" style="text-align: center;">
|
||||
|
||||
<input type="submit" name="LoginButton" value="登 录" onclick="return checkLogin();" id="LoginButton" class="submitbutton" onmouseover="this.className='submitbutton submitbutton_hover';" onmouseout="this.className='submitbutton';" style="color:White;" />
|
||||
|
||||
<a href="/register/register.aspx?type=1" id="hrefRegister" title="只需20秒,就可完成注册" class="register-now wjx_alink">立即注册</a>
|
||||
|
||||
<div class="third-party-login">
|
||||
|
||||
<div class="third-party-txt">
|
||||
|
||||
<em class="word">更多登录方式</em>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="penguin-box">
|
||||
|
||||
<span>
|
||||
|
||||
<a href="/connectnew.aspx" id="hrefQQ" class="icon penguin-icon"></a>
|
||||
|
||||
<p>QQ登录</p>
|
||||
|
||||
|
||||
|
||||
</span>
|
||||
|
||||
<span id="spanWeiXin">
|
||||
|
||||
<a href="/weixinlogin.aspx" id="hrefWx" class="icon wxpenguin-icon"></a>
|
||||
|
||||
<p>微信登录</p>
|
||||
|
||||
</span>
|
||||
|
||||
<span id="spanQywx" style="margin-right:0;">
|
||||
|
||||
<a href="https://qywx.wjx.cn/mobile/qywx/manage.aspx" id="hrefQywx" class="icon qywxpenguin-icon">
|
||||
|
||||
|
||||
|
||||
<img style="height:0px;" src="https://open.work.weixin.qq.com/service/img?id=wwb835fa4352ca80df&t=login&c=blue&s=small" srcset="https://open.work.weixin.qq.com/service/img?id=wwb835fa4352ca80df&t=login&c=blue&s=small@2x 2x" referrerpolicy="unsafe-url" alt="企业微信登录">
|
||||
|
||||
|
||||
|
||||
</a>
|
||||
|
||||
<p>企业微信</p>
|
||||
|
||||
</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div style="clear:both;"></div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var UserName = document.getElementById("UserName");
|
||||
|
||||
var hfUserName = document.getElementById("hfUserName");
|
||||
|
||||
var Password = document.getElementById("Password");
|
||||
|
||||
var LoginButton = document.getElementById("LoginButton");
|
||||
|
||||
var txtCode = document.getElementById("txtCode");
|
||||
|
||||
var hrefGetCode = document.getElementById("hrefGetCode");
|
||||
|
||||
var hfSelUser = document.getElementById("hfSelUser");
|
||||
|
||||
var isYzm = true;
|
||||
|
||||
function getCode() {
|
||||
|
||||
if (!isYzm)
|
||||
|
||||
return;
|
||||
|
||||
txtCode.focus();
|
||||
|
||||
$(hrefGetCode).html('重新发送 <span id="dtime">60</span>');
|
||||
|
||||
$.ajax({
|
||||
|
||||
url: "/handler/sendlsms.ashx?t=" + new Date().valueOf(), async: true, success: function (data) {
|
12
wjx/tmp.py
Normal file
12
wjx/tmp.py
Normal file
@ -0,0 +1,12 @@
|
||||
import requests
|
||||
|
||||
url = "https://www.wjx.cn/login.aspx"
|
||||
|
||||
payload={}
|
||||
headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.42'
|
||||
}
|
||||
|
||||
response = requests.request("GET", url, headers=headers, data=payload)
|
||||
|
||||
print(response.text)
|
3
zxxk_dl/.gitignore
vendored
Normal file
3
zxxk_dl/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
*.html
|
||||
*.pdf
|
||||
*.docx
|
Reference in New Issue
Block a user