Tidy files
Former-commit-id: 3ad18d4bae036b9c55576f4c8b726a32a4e30c76
This commit is contained in:
@ -7,10 +7,9 @@ from traceback import print_exc
|
||||
|
||||
def init():
|
||||
if len(argv) != 2:
|
||||
print("Usage: a.py file.mp3")
|
||||
print(f"Usage: {__file__} file.mp3")
|
||||
exit(1)
|
||||
return argv[1]
|
||||
# return "新课程外研高一第32期.mp3"
|
||||
|
||||
def make_dir(pth:str):
|
||||
if not path.isdir(pth):
|
||||
|
@ -1,88 +0,0 @@
|
||||
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()
|
78
README.md
Normal file
78
README.md
Normal file
@ -0,0 +1,78 @@
|
||||
# 个人使用小工具集
|
||||
|
||||
## [修改连接数](changeConnectionLimit)
|
||||
|
||||
win10修改wifi热点最大连接终端数
|
||||
|
||||
Usage:`main.bat`
|
||||
|
||||
## [学*网预览下载](zxxk_dl)
|
||||
|
||||
下载学*网资源,通过预览的形式,下载的文件以html形式保存。可以使用adobe Acrobat的打印转为pdf,文字版文件以svg下载,图片版原图。
|
||||
|
||||
1. 研究过程:[process.md](zxxk_dl/process.md)
|
||||
|
||||
2. usage: `python main.py`
|
||||
3. requirements: python, requests
|
||||
|
||||
## adb快速传手机文件
|
||||
|
||||
源文件丢了,TODO
|
||||
|
||||
## [并行auto-editor](mult)
|
||||
|
||||
并行运行auto-editor, 递归转码所有视频。(PS:网课时用的)
|
||||
|
||||
### files
|
||||
|
||||
#### main.py
|
||||
|
||||
主程序
|
||||
|
||||
### main_up.py
|
||||
|
||||
使用hevc(CUDA)硬解码
|
||||
|
||||
### usage
|
||||
|
||||
`python main.py`
|
||||
|
||||
## 菁*网题目下载
|
||||
|
||||
**ATTENTION:目前制作时的账号疑似被封禁,请谨慎使用**
|
||||
|
||||
如需打印,请使用浏览器打印或转pdf
|
||||
|
||||
### Usage
|
||||
|
||||
菁优网任意界面,F12抓Cookie
|
||||
运行main.py,输入复制的内容,根据提示输入网址即可。
|
||||
|
||||
### requements
|
||||
|
||||
python, requests,bs4
|
||||
|
||||
## [听力文件拆分](English_Listening_cut)
|
||||
|
||||
基于学英语报的听力做听力文件拆解,拆分到每段对话
|
||||
|
||||
### Usage
|
||||
|
||||
`python main.py`
|
||||
|
||||
## seat_map
|
||||
|
||||
文档TODO
|
||||
|
||||
## 简单运动报警(move_warn)
|
||||
|
||||
对ip摄像头画面进行简单运动捕捉,核心代码来自网络。效果:运动达到一定范围,发出声音警告后自动关闭程序。
|
||||
|
||||
### usage
|
||||
|
||||
`python main.py`
|
||||
|
||||
### requirements
|
||||
|
||||
python, opencv
|
||||
|
10
autostart.py
Normal file
10
autostart.py
Normal file
@ -0,0 +1,10 @@
|
||||
from getpass import getpass
|
||||
from subprocess import Popen
|
||||
|
||||
cmd=input("SSH: ").split()
|
||||
pwd=getpass()
|
||||
port=cmd[2]
|
||||
ip=cmd[3].replace("root@",f"root:{pwd}@")
|
||||
print(ip,port)
|
||||
Popen(fr'"C:\Program Files (x86)\NetSarang\Xshell 7\Xshell.exe" ssh://{ip}:{port}')
|
||||
ssh=Popen(f"ssh -CNg -L 6006:127.0.0.1:6006 -p {port} {cmd[3]}")
|
1
bfg-1.14.0.jar.REMOVED.git-id
Normal file
1
bfg-1.14.0.jar.REMOVED.git-id
Normal file
@ -0,0 +1 @@
|
||||
688fe713674b914c519bef018aa47f7a8ba18d58
|
39
changeConnectionLimit/main.bat
Normal file
39
changeConnectionLimit/main.bat
Normal file
@ -0,0 +1,39 @@
|
||||
@echo off
|
||||
:: Check if the script is run as administrator
|
||||
NET SESSION >nul 2>&1
|
||||
if %errorLevel% neq 0 (
|
||||
echo Requesting administrator permissions...
|
||||
goto runAsAdmin
|
||||
) else (
|
||||
goto main
|
||||
)
|
||||
|
||||
:runAsAdmin
|
||||
:: Request administrator permissions
|
||||
powershell Start-Process "%0" -Verb RunAs
|
||||
exit /B
|
||||
|
||||
:main
|
||||
:: Get user input for WifiMaxPeers value
|
||||
set /p WifiMaxPeersInput="Enter WifiMaxPeers value (decimal): "
|
||||
|
||||
:: Validate if the input is a number
|
||||
set "WifiMaxPeers=%WifiMaxPeersInput%" 2>nul
|
||||
if not defined WifiMaxPeers (
|
||||
echo Invalid input. Please enter a valid decimal number.
|
||||
pause
|
||||
exit /B
|
||||
)
|
||||
|
||||
:: Set the registry value
|
||||
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\icssvc\Settings" /v WifiMaxPeers /t REG_DWORD /d %WifiMaxPeers% /f
|
||||
|
||||
echo WifiMaxPeers registry value set to %WifiMaxPeers%.
|
||||
|
||||
echo Restarting icssvc service.
|
||||
|
||||
net stop icssvc
|
||||
net start icssvc
|
||||
|
||||
echo Succeed.
|
||||
pause
|
4
fast_pull/main.py
Normal file
4
fast_pull/main.py
Normal file
@ -0,0 +1,4 @@
|
||||
from subprocess import run
|
||||
|
||||
path="Sounds"
|
||||
# Get file list
|
Binary file not shown.
Before Width: | Height: | Size: 117 KiB |
@ -1,97 +1,95 @@
|
||||
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()
|
||||
import cv2
|
||||
import numpy as np
|
||||
from winsound import PlaySound,SND_ALIAS,SND_ASYNC
|
||||
from time import time
|
||||
# Beep(500,500)
|
||||
|
||||
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()
|
4
pwd.txt
Normal file
4
pwd.txt
Normal file
@ -0,0 +1,4 @@
|
||||
***REMOVED***
|
||||
***REMOVED******REMOVED***
|
||||
***REMOVED***
|
||||
***REMOVED******REMOVED***
|
74
seat_map/main.py
Normal file
74
seat_map/main.py
Normal file
@ -0,0 +1,74 @@
|
||||
import numpy as np
|
||||
from pandas import DataFrame
|
||||
|
||||
# seat = np.arange(48,dtype=np.byte).reshape((4,2,6))
|
||||
seat = np.fromfile('seat.dat',dtype=np.byte).reshape((4,2,6))
|
||||
print(seat.shape)
|
||||
|
||||
maps = np.arange(4)
|
||||
maps[-1]=maps[0]
|
||||
maps[:-1]+=1
|
||||
|
||||
seat[:,:,-1]=seat[:,:,0]
|
||||
seat[:,:,0:-1]+=1
|
||||
seat = seat[maps,:,:]
|
||||
|
||||
seat.tofile("seat.dat")
|
||||
|
||||
names = np.array([
|
||||
"张姝肜",
|
||||
"乔旺源",
|
||||
"焦祺",
|
||||
"丛金旺",
|
||||
"周巧冉",
|
||||
"张日昊",
|
||||
"刘卓",
|
||||
"宋智宪",
|
||||
"张文桦",
|
||||
"王子来",
|
||||
"姜樱楠",
|
||||
"于诗澳",
|
||||
"张潇艺",
|
||||
"李语恒",
|
||||
"*",
|
||||
"张晓轩",
|
||||
"宋佳怡",
|
||||
"宋雨蔓",
|
||||
"于世函",
|
||||
"王梁宇",
|
||||
"*",
|
||||
"毕一聪",
|
||||
"娄晴",
|
||||
"黄卓琳",
|
||||
"刘宇航",
|
||||
"刘雨鑫",
|
||||
"庞惠铭",
|
||||
"徐子灏",
|
||||
"阎展博",
|
||||
"崔子豪",
|
||||
"王明仁",
|
||||
"王耀增",
|
||||
"李善伊",
|
||||
"吴庆波",
|
||||
"樊乐天",
|
||||
"潘一鸣",
|
||||
"洛艺伟",
|
||||
"周含笑",
|
||||
"苏振宇",
|
||||
"沈洁",
|
||||
"李柏畅",
|
||||
"毕思淼",
|
||||
"张濠亿",
|
||||
"李怡萱",
|
||||
"高镆",
|
||||
"张妍",
|
||||
"杨颜聪",
|
||||
"李南卓阳"
|
||||
])
|
||||
opt = seat.reshape((8,6))
|
||||
opt = opt[:,::-1]
|
||||
print(DataFrame(opt))
|
||||
opt = names[opt]
|
||||
with open("seat.csv", "w", encoding="gb2312") as f:
|
||||
for i in range(6):
|
||||
print(",".join(opt[:,i]),file=f)
|
@ -30,7 +30,7 @@ def writefile(filename,text):
|
||||
def main():
|
||||
softID=input("ID: ")
|
||||
url = "https://www.zxxk.com/soft/Preview/FirstLoadPreviewJson?softID={}&type=3&product=1&v=2&FullPreview=true"
|
||||
response = requests.get(url.format(softID))
|
||||
response = requests.get(url.format(softID),verify=False)
|
||||
if response.status_code!=200:
|
||||
print("ERROR")
|
||||
print(response.status_code)
|
||||
@ -66,7 +66,7 @@ def main():
|
||||
if "jpg" in url:
|
||||
l.append(f"<img src={url} />")
|
||||
continue
|
||||
page=requests.get(url,cookies=response.cookies)
|
||||
page=requests.get(url,cookies=response.cookies,verify=False)
|
||||
if not page.status_code==200:
|
||||
print(page)
|
||||
print(page.status_code)
|
||||
|
Reference in New Issue
Block a user