初次提交
This commit is contained in:
commit
70f8ad025a
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
node_modules
|
||||
*.spec
|
||||
config.json
|
||||
build
|
||||
dist
|
||||
@*
|
||||
Home_ping_log.txt
|
||||
Server_guangzhou_ping_log.txt
|
112
C/按键计时.c
Normal file
112
C/按键计时.c
Normal file
@ -0,0 +1,112 @@
|
||||
#include<reg52.h>
|
||||
typedef unsigned int u16;
|
||||
typedef unsigned char u8;
|
||||
|
||||
//定义数码管的端口
|
||||
sbit D1 = P2^0;
|
||||
sbit D2 = P2^1;
|
||||
sbit D3 = P2^2;
|
||||
sbit D4 = P2^3;
|
||||
//定义按键的端口
|
||||
sbit K3 = P3^2;
|
||||
sbit K2 = P3^3;
|
||||
//0~9的段码
|
||||
u8 code table[]={0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90};
|
||||
u8 second;
|
||||
u8 key=0;
|
||||
|
||||
// 1ms*1000=1s
|
||||
void delay1ms(u16 t)
|
||||
{
|
||||
u16 i,j;
|
||||
for(i=0;i<t;i++)
|
||||
{
|
||||
for(j=0;j<120;j++);
|
||||
}
|
||||
}
|
||||
|
||||
void ExitInit() //定时器初始化
|
||||
{
|
||||
TMOD =0X01; //定时器0,工作方式1,16位定时器
|
||||
ET0=1;
|
||||
EA=1;
|
||||
second=0;
|
||||
TH0=0xFC;
|
||||
TL0=0x18;
|
||||
P3=0xff;
|
||||
P0=0x00;
|
||||
}
|
||||
|
||||
void Display(u8 s) //数码管显示
|
||||
{
|
||||
D1=0;D2=1;
|
||||
P0=table[s/10];
|
||||
delay1ms(5);
|
||||
D1=1;D2=0;
|
||||
P0=table[s%10];
|
||||
delay1ms(5);
|
||||
}
|
||||
|
||||
|
||||
void Keyscan()
|
||||
{
|
||||
if (TR0 == 0) //定时器0关闭
|
||||
{
|
||||
if(K3==0)
|
||||
{
|
||||
delay1ms(10);
|
||||
if(K3==0)
|
||||
{
|
||||
TR0=1;
|
||||
}
|
||||
}
|
||||
if (K2==0)
|
||||
{
|
||||
second = 0;
|
||||
}
|
||||
|
||||
}
|
||||
delay1ms(100);
|
||||
if (TR0 == 1)
|
||||
{
|
||||
if(K3==0)
|
||||
{
|
||||
delay1ms(10);
|
||||
if(K3==0)
|
||||
{
|
||||
TR0=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
ExitInit(); //定时器初始化
|
||||
while(1)
|
||||
{
|
||||
Display(second); //显示秒数
|
||||
Keyscan(); //按键扫描
|
||||
}
|
||||
}
|
||||
|
||||
void Timer0() interrupt 1 //定时器0中断函数
|
||||
{
|
||||
static u16 timer;
|
||||
TH0=0XFC;
|
||||
TL0=0X18;
|
||||
timer++;
|
||||
//1ms*1000=1s
|
||||
if(timer==1000)
|
||||
{
|
||||
timer=0;
|
||||
second++;
|
||||
// 当second=100时,second=0,即从0开始计数
|
||||
if(second==100)
|
||||
second=0;
|
||||
}
|
||||
}
|
||||
|
||||
// Path: C\按键计时.c
|
||||
|
400
C/时钟.c
Normal file
400
C/时钟.c
Normal file
@ -0,0 +1,400 @@
|
||||
/*
|
||||
|
||||
く__,.ヘヽ. / ,ー、 〉
|
||||
\ ', !-─‐-i / /´
|
||||
/`ー' L//`ヽ、
|
||||
/ /, /| , , ',
|
||||
イ / /-‐/ i L_ ハ ヽ! i
|
||||
レ ヘ 7イ`ト レ'ァ-ト、!ハ| |
|
||||
!,/7 '0' ´0iソ| |
|
||||
|.从" _ ,,,, / |./ |
|
||||
レ'| i>.、,,__ _,.イ / .i |
|
||||
レ'| | / k_7_/レ'ヽ, ハ. |
|
||||
| |/i 〈|/ i ,.ヘ | i |
|
||||
.|/ / i: ヘ! \ |
|
||||
kヽ>、ハ _,.ヘ、 /、!
|
||||
!'〈//`T´', \ `'7'ーr'
|
||||
レ'ヽL__|___i,___,ンレ|ノ
|
||||
ト-,/ |___./
|
||||
'ー' !_,.:
|
||||
|
||||
四位数码管STC89C52RC单片机实现简易时钟外加闹钟功能
|
||||
Four digital tube STC89C52RC microcontroller to achieve a simple clock plus alarm clock function
|
||||
创建于2023/6/15 14:13
|
||||
Created on 2023/6/15 14:13
|
||||
*/
|
||||
#include<reg52.h>
|
||||
typedef unsigned int u16;
|
||||
typedef unsigned char u8;
|
||||
|
||||
//定义数码管的端口
|
||||
sbit D1 = P2^0;
|
||||
sbit D2 = P2^1;
|
||||
sbit D3 = P2^2;
|
||||
sbit D4 = P2^3;
|
||||
//如果D1 = 0则选中
|
||||
//如果D1 = 1则不选中
|
||||
|
||||
|
||||
//定义按键的端口
|
||||
sbit K3 = P3^5; //切换显示时间和设置时间和设置闹钟的时间
|
||||
sbit K4 = P3^4; //切换小时和分钟的时间设置
|
||||
sbit K5 = P3^3; //当设置时钟的时间、设置闹钟的时间,用来增加时间、可减少小时和分钟通过K4切换
|
||||
sbit K6 = P3^2; //当设置时钟的时间、设置闹钟的时间,用来减少时间、可减少小时和分钟通过K4切换
|
||||
|
||||
//判断按钮是否按下
|
||||
int K3UPdown;
|
||||
int K4UPdown;
|
||||
int K5UPdown;
|
||||
int K6UPdown;
|
||||
|
||||
// 设置默认时间
|
||||
//12:00:00
|
||||
u8 hour = 12;
|
||||
u8 minute = 0;
|
||||
|
||||
// 设置默认闹钟时间
|
||||
//12:01:00
|
||||
u8 bellhour = 12;
|
||||
u8 bellminute = 1;
|
||||
u8 bellsecond = 0;
|
||||
|
||||
//默认显示时钟
|
||||
u8 timekey = 0;
|
||||
|
||||
//小时和分分钟的切换状态
|
||||
u8 Statukey = 0; //Statukey = 0 小时设置、Statukey = 1 分钟设置
|
||||
//定义蜂鸣器的端口
|
||||
sbit beep = P3^6;
|
||||
//0~9的段码
|
||||
u8 code table[]={0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90}; //0~9的段码 共阳极数码管
|
||||
u8 code tablecode[]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10,0x08,0x03,0x46,0x21,0x06,0x0e};//0~9的段码 共阳极数码管带小数点
|
||||
u8 second;
|
||||
u8 key=0;
|
||||
|
||||
// 1ms*1000=1s
|
||||
void delay1ms(u16 t)
|
||||
{
|
||||
u16 i,j;
|
||||
for(i=0;i<t;i++)
|
||||
{
|
||||
for(j=0;j<120;j++);
|
||||
}
|
||||
}
|
||||
|
||||
void ExitInit() //定时器初始化
|
||||
{
|
||||
TMOD =0X01;
|
||||
ET0=1;
|
||||
EA=1;
|
||||
second=0; //秒数计时
|
||||
TH0=0xFC;
|
||||
TL0=0x18;
|
||||
P3=0xff;
|
||||
P0=0x00;
|
||||
}
|
||||
|
||||
void Display() //数码管显示
|
||||
{
|
||||
//切换显示时间设置或者闹钟设置
|
||||
//如果key = 0则显示时间设置,key = 1则显示闹钟设置
|
||||
if(timekey == 0 || timekey == 1){ //切换显示时间或者时间设置
|
||||
//显示时间设置
|
||||
D1 = 0; D2 = 1; D3 = 1; D4 = 1; //选中第一个数码管
|
||||
P0 = table[hour / 10]; //显示s的十位
|
||||
delay1ms(3);
|
||||
D1 = 1; D2 = 0; D3 = 1; D4 = 1;
|
||||
P0 = tablecode[hour % 10];
|
||||
delay1ms(3);
|
||||
D1 = 1; D2 = 1; D3 = 0; D4 = 1;
|
||||
P0 = table[minute / 10]; //显示s的十位
|
||||
delay1ms(3);
|
||||
D1 = 1; D2 = 1; D3 = 1; D4 = 0;
|
||||
P0 = table[minute % 10];
|
||||
delay1ms(3);
|
||||
}
|
||||
|
||||
// 闹钟设置
|
||||
if (timekey==2) //闹钟设置
|
||||
{
|
||||
D1 = 0; D2 = 1; D3 = 1; D4 = 1; //选中第一个数码管
|
||||
P0 = table[bellhour / 10]; //显示s的十位
|
||||
delay1ms(3);
|
||||
D1 = 1; D2 = 0; D3 = 1; D4 = 1;
|
||||
P0 = tablecode[bellhour % 10];
|
||||
delay1ms(3);
|
||||
D1 = 1; D2 = 1; D3 = 0; D4 = 1;
|
||||
P0 = table[bellminute / 10]; //显示s的十位
|
||||
delay1ms(3);
|
||||
D1 = 1; D2 = 1; D3 = 1; D4 = 0;
|
||||
P0 = table[bellminute % 10];
|
||||
delay1ms(3);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
void Timer0() interrupt 1 //定时器0中断函数 检查是否到达闹钟时间
|
||||
{
|
||||
static u16 timer;
|
||||
TH0=0XFC;
|
||||
TL0=0X18;
|
||||
timer++;
|
||||
//1ms*1000=1s
|
||||
if(timer==1000)
|
||||
{
|
||||
timer=0;
|
||||
second++;
|
||||
if(second==60)
|
||||
{
|
||||
second=0;
|
||||
minute++;
|
||||
if(minute==60)
|
||||
{
|
||||
minute=0;
|
||||
hour++;
|
||||
if(hour==24)
|
||||
{
|
||||
hour=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void main()
|
||||
{
|
||||
int timex;
|
||||
ExitInit();
|
||||
TR0 = 1;
|
||||
while(1)
|
||||
{
|
||||
if(timekey == 0)//时钟模式才响铃
|
||||
{
|
||||
if (hour == bellhour && minute == bellminute && second == bellsecond)
|
||||
{
|
||||
for(timex=0;timex<3;timex++)
|
||||
{
|
||||
beep = 0;
|
||||
delay1ms(1);
|
||||
beep = 1;
|
||||
delay1ms(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 如果计时器开启则进行以下判断
|
||||
if(timekey==0)
|
||||
{
|
||||
TR0 = 1;
|
||||
}
|
||||
if(timekey==1 || timekey==2)
|
||||
{
|
||||
// 停止计时
|
||||
TR0 = 0;
|
||||
//归零
|
||||
second = 0;
|
||||
}
|
||||
|
||||
Display(); //数码管显示
|
||||
|
||||
//切换显示时间或者时间设置或者闹钟设置
|
||||
//timekey = 0 显示时间 timekey = 1 时间设置 timekey = 2 闹钟设置
|
||||
//当进入时间设置或者闹钟设置时,timekey = 1或者timekey = 2 则归零秒数计时并暂停
|
||||
if (K3 == 0) //切换显示时间和设置时间和设置闹钟的时间
|
||||
{
|
||||
delay1ms(5);
|
||||
if (K3 == 0)
|
||||
{
|
||||
if (K3UPdown == 0)
|
||||
{
|
||||
key++;
|
||||
K3UPdown = 1;
|
||||
if (key == 3)
|
||||
{
|
||||
key = 0;
|
||||
}
|
||||
if (key == 0)
|
||||
{
|
||||
timekey = 0;
|
||||
}
|
||||
if (key == 1)
|
||||
{
|
||||
timekey = 1;
|
||||
}
|
||||
if (key == 2)
|
||||
{
|
||||
timekey = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(K3UPdown == 1)//恢复按键状态
|
||||
{
|
||||
if (K3 == 1)
|
||||
{
|
||||
delay1ms(5);
|
||||
if (K3 == 1)
|
||||
{
|
||||
K3UPdown = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//切换小时和分钟的时间设置
|
||||
if (K4 == 0)
|
||||
{
|
||||
delay1ms(5);
|
||||
if (K4 == 0)
|
||||
{
|
||||
if (K4UPdown == 0)
|
||||
{
|
||||
Statukey++;
|
||||
K4UPdown = 1;
|
||||
if (Statukey == 2)
|
||||
{
|
||||
Statukey = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(K4UPdown == 1) //恢复按键状态
|
||||
{
|
||||
if (K4 == 1)
|
||||
{
|
||||
delay1ms(5);
|
||||
if (K4 == 1)
|
||||
{
|
||||
K4UPdown = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
//K5用来增加时间、小时和分钟通过K4切换
|
||||
if(K5 == 0)
|
||||
{
|
||||
delay1ms(5);
|
||||
if (K5 == 0)
|
||||
{
|
||||
if (K5UPdown == 0)
|
||||
{
|
||||
K5UPdown = 1;
|
||||
if (timekey == 1)
|
||||
{
|
||||
if (Statukey == 0)
|
||||
{
|
||||
hour++;
|
||||
if (hour == 24)
|
||||
{
|
||||
hour = 0;
|
||||
}
|
||||
}
|
||||
if (Statukey == 1)
|
||||
{
|
||||
minute++;
|
||||
if (minute == 60)
|
||||
{
|
||||
minute = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(timekey == 2)
|
||||
{
|
||||
if (Statukey == 0)
|
||||
{
|
||||
bellhour++;
|
||||
if (bellhour == 24)
|
||||
{
|
||||
bellhour = 0;
|
||||
}
|
||||
}
|
||||
if (Statukey == 1)
|
||||
{
|
||||
bellminute++;
|
||||
if (bellminute == 60)
|
||||
{
|
||||
bellminute = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//当设置时钟的时间、设置闹钟的时间,用来增加时间、可减少小时和分钟通过K4切换
|
||||
|
||||
}
|
||||
}
|
||||
if(K5UPdown == 1) //恢复按键状态
|
||||
{
|
||||
if (K5 == 1)
|
||||
{
|
||||
delay1ms(5);
|
||||
if (K5 == 1)
|
||||
{
|
||||
K5UPdown = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(K6 == 0)
|
||||
{
|
||||
delay1ms(5);
|
||||
if(K6 == 0)
|
||||
{
|
||||
if (K6UPdown == 0)
|
||||
{
|
||||
K6UPdown = 1;
|
||||
//当设置时钟的时间、设置闹钟的时间,用来减少时间、可减少小时和分钟通过K4切换
|
||||
if (timekey == 1)
|
||||
{
|
||||
if (Statukey == 0)
|
||||
{
|
||||
hour--;
|
||||
Display(); //数码管显示
|
||||
if (hour == 255)
|
||||
{
|
||||
hour = 23;
|
||||
}
|
||||
}
|
||||
if (Statukey == 1)
|
||||
{
|
||||
minute--;
|
||||
if (minute == 255)
|
||||
{
|
||||
minute = 59;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(timekey == 2)
|
||||
{
|
||||
if (Statukey == 0)
|
||||
{
|
||||
bellhour--;
|
||||
if (bellhour == 255)
|
||||
{
|
||||
bellhour = 23;
|
||||
}
|
||||
}
|
||||
if (Statukey == 1)
|
||||
{
|
||||
bellminute--;
|
||||
if (bellminute == 255)
|
||||
{
|
||||
bellminute = 59;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(K6UPdown == 1) //恢复按键状态
|
||||
{
|
||||
if (K6 == 1)
|
||||
{
|
||||
delay1ms(5);
|
||||
if (K6 == 1)
|
||||
{
|
||||
K6UPdown = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Path: SASO-STATIC-API/C/时钟.c
|
||||
// Compare this snippet from C/按键计时.c:
|
||||
// Author: Syayuri
|
||||
// E-mail: syayuri@outlook.jp
|
133
PHP/jsd.php
Normal file
133
PHP/jsd.php
Normal file
@ -0,0 +1,133 @@
|
||||
<?php
|
||||
$file = $_SERVER['REQUEST_URI'];
|
||||
if(strpos($file, '/gh/') === 0) {
|
||||
// 过滤 非/npm/开头的文件访问
|
||||
}elseif(strpos($file, '/npm/') === 0) {
|
||||
// 过滤 非/wp/开头的文件访问
|
||||
}elseif(strpos($file, '/wp/') === 0) {
|
||||
}else{
|
||||
exit('/* 你不正常 */');
|
||||
}
|
||||
// 过滤 禁止php文件访问
|
||||
if(strpos($file, '.php') !== false) exit('/* 你想干嘛? */');
|
||||
//过滤没有文件后缀使用正则表达式
|
||||
if(!preg_match('/\.\w+$/', $file)) exit('/* 你文件呢? */');
|
||||
//过滤 非静态文件访问 js css img 等
|
||||
if(!preg_match('/\.(js|css|png|jpg|jpeg|gif|bmp|ico|webp|mp3|mp4|webm|ogg|svg|eot|ttf|woff|woff2|json|xml|txt|swf|htc|pdf|doc|docx|xls|xlsx|ppt|pptx|zip|rar|gz|bz2)$/i', $file)) exit('/* 文件格式不在白名单内 */');
|
||||
// 过滤 非/gh/开头的文件访问
|
||||
$self_path = pathinfo($_SERVER['PHP_SELF'], PATHINFO_DIRNAME); // 当前目录
|
||||
$query = '';
|
||||
if($_SERVER['QUERY_STRING']) // 有query string
|
||||
{
|
||||
$file = explode('?', $file)[0]; // 去掉query string
|
||||
$query = '?' . $_SERVER['QUERY_STRING']; // 重新构造query string
|
||||
}
|
||||
$file_info = pathinfo($file); // 获取文件信息
|
||||
$path = $file_info['dirname'];
|
||||
if($path=='/') exit('/* ??? */');
|
||||
$mimetype = get_mimetype($file_info['extension']);
|
||||
$cdn_file = $file;
|
||||
if(strlen($self_path)>1){ // 非根目录
|
||||
$cdn_file = substr($file, strlen($self_path)); // 去掉开头的目录
|
||||
}
|
||||
$local_path = substr(pathinfo( $cdn_file, PATHINFO_DIRNAME), 1); // 去掉开头的/
|
||||
if($local_path && !is_dir($local_path)){ // 目录不存在
|
||||
@mkdir($local_path, 755, true); // 创建目录
|
||||
}
|
||||
$url = 'https://cdn.jsdelivr.net' . $cdn_file . $query; // 构造CDN文件URL
|
||||
$content = curl($url); // 获取文件内容
|
||||
if($content){
|
||||
header('content-type:'. $mimetype .';charset=utf-8'); // 输出文件头
|
||||
file_put_contents(substr($cdn_file, 1), $content); // 保存文件
|
||||
exit($content); // 输出文件
|
||||
}else{
|
||||
header('location: ' .$url );
|
||||
}
|
||||
|
||||
|
||||
function curl($url)
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, 3000);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 3000);
|
||||
if (strpos($url, 'https') !== false) {
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36');
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
/**
|
||||
* 根据文件后缀获取其mine类型
|
||||
* @param string $extension
|
||||
* @return string
|
||||
*/
|
||||
function get_mimetype($extension) {
|
||||
$ct['htm'] = 'text/html';
|
||||
$ct['html'] = 'text/html';
|
||||
$ct['txt'] = 'text/plain';
|
||||
$ct['asc'] = 'text/plain';
|
||||
$ct['bmp'] = 'image/bmp';
|
||||
$ct['gif'] = 'image/gif';
|
||||
$ct['jpeg'] = 'image/jpeg';
|
||||
$ct['jpg'] = 'image/jpeg';
|
||||
$ct['jpe'] = 'image/jpeg';
|
||||
$ct['png'] = 'image/png';
|
||||
$ct['ico'] = 'image/vnd.microsoft.icon';
|
||||
$ct['mpeg'] = 'video/mpeg';
|
||||
$ct['mpg'] = 'video/mpeg';
|
||||
$ct['mpe'] = 'video/mpeg';
|
||||
$ct['qt'] = 'video/quicktime';
|
||||
$ct['mov'] = 'video/quicktime';
|
||||
$ct['avi'] = 'video/x-msvideo';
|
||||
$ct['wmv'] = 'video/x-ms-wmv';
|
||||
$ct['mp2'] = 'audio/mpeg';
|
||||
$ct['mp3'] = 'audio/mpeg';
|
||||
$ct['rm'] = 'audio/x-pn-realaudio';
|
||||
$ct['ram'] = 'audio/x-pn-realaudio';
|
||||
$ct['rpm'] = 'audio/x-pn-realaudio-plugin';
|
||||
$ct['ra'] = 'audio/x-realaudio';
|
||||
$ct['wav'] = 'audio/x-wav';
|
||||
$ct['css'] = 'text/css';
|
||||
$ct['zip'] = 'application/zip';
|
||||
$ct['pdf'] = 'application/pdf';
|
||||
$ct['doc'] = 'application/msword';
|
||||
$ct['bin'] = 'application/octet-stream';
|
||||
$ct['exe'] = 'application/octet-stream';
|
||||
$ct['class'] = 'application/octet-stream';
|
||||
$ct['dll'] = 'application/octet-stream';
|
||||
$ct['xls'] = 'application/vnd.ms-excel';
|
||||
$ct['ppt'] = 'application/vnd.ms-powerpoint';
|
||||
$ct['wbxml'] = 'application/vnd.wap.wbxml';
|
||||
$ct['wmlc'] = 'application/vnd.wap.wmlc';
|
||||
$ct['wmlsc'] = 'application/vnd.wap.wmlscriptc';
|
||||
$ct['dvi'] = 'application/x-dvi';
|
||||
$ct['spl'] = 'application/x-futuresplash';
|
||||
$ct['gtar'] = 'application/x-gtar';
|
||||
$ct['gzip'] = 'application/x-gzip';
|
||||
$ct['js'] = 'application/javascript';
|
||||
$ct['swf'] = 'application/x-shockwave-flash';
|
||||
$ct['tar'] = 'application/x-tar';
|
||||
$ct['7z'] = 'application/x7zcompressed';
|
||||
$ct['rar'] = 'application/x-rar-compressed';
|
||||
$ct['xhtml'] = 'application/xhtml+xml';
|
||||
$ct['au'] = 'audio/basic';
|
||||
$ct['snd'] = 'audio/basic';
|
||||
$ct['midi'] = 'audio/midi';
|
||||
$ct['mid'] = 'audio/midi';
|
||||
$ct['m3u'] = 'audio/x-mpegurl';
|
||||
$ct['tiff'] = 'image/tiff';
|
||||
$ct['tif'] = 'image/tiff';
|
||||
$ct['rtf'] = 'text/rtf';
|
||||
$ct['wml'] = 'text/vnd.wap.wml';
|
||||
$ct['wmls'] = 'text/vnd.wap.wmlscript';
|
||||
$ct['xsl'] = 'text/xml';
|
||||
$ct['xml'] = 'text/xml';
|
||||
|
||||
return isset($ct[strtolower($extension)]) ? $ct[strtolower($extension)] : 'text/html';
|
||||
}
|
13
Python/Readme.md
Normal file
13
Python/Readme.md
Normal file
@ -0,0 +1,13 @@
|
||||
# 自己搞的小东西
|
||||
|
||||
- 不建议使用,性能极差
|
||||
|
||||
- 如果你非要用
|
||||
|
||||
- 你可以使用下面的命令进行打包可在所有电脑运行
|
||||
|
||||
|
||||
```python
|
||||
pyinstaller --onefile main.py
|
||||
```
|
||||
|
145
Python/UNPKG/main.py
Normal file
145
Python/UNPKG/main.py
Normal file
@ -0,0 +1,145 @@
|
||||
import requests
|
||||
import re
|
||||
import os
|
||||
import shutil
|
||||
import time
|
||||
from requests.adapters import HTTPAdapter
|
||||
from urllib3.util.retry import Retry
|
||||
|
||||
# 配置
|
||||
url = "https://unpkg.ovofish.com/"
|
||||
headers = {
|
||||
'Accept-Language': 'zh-CN,zh;q=0.8',
|
||||
'Content-Type': 'text/html; Charset=utf-8',
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"
|
||||
}
|
||||
|
||||
# 输入模块名
|
||||
mod = input("请输入模块名:")
|
||||
|
||||
# 设置重试机制
|
||||
def requests_retry_session(
|
||||
retries=3,
|
||||
backoff_factor=0.3,
|
||||
status_forcelist=(500, 502, 504),
|
||||
session=None,
|
||||
proxies=None
|
||||
):
|
||||
session = session or requests.Session()
|
||||
retry = Retry(
|
||||
total=retries,
|
||||
read=retries,
|
||||
connect=retries,
|
||||
backoff_factor=backoff_factor,
|
||||
status_forcelist=status_forcelist,
|
||||
)
|
||||
adapter = HTTPAdapter(max_retries=retry)
|
||||
session.mount('http://', adapter)
|
||||
session.mount('https://', adapter)
|
||||
if proxies:
|
||||
session.proxies.update(proxies)
|
||||
return session
|
||||
|
||||
# 获取HTML
|
||||
def getHTML(url, encoding='utf-8', proxies=None):
|
||||
try:
|
||||
with requests_retry_session(proxies=proxies).get(url, headers=headers) as rd:
|
||||
rd.encoding = encoding
|
||||
rd.raise_for_status()
|
||||
return rd.text
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f"获取HTML时发生错误: {e}")
|
||||
return None
|
||||
|
||||
# 获取版本
|
||||
def getVsions(m, proxies=None):
|
||||
h = getHTML(url + m + '/', proxies=proxies)
|
||||
j = re.findall(r'<select name="version"(.*?)</select>', h, re.S)[0]
|
||||
patt = re.compile(r'<option.+?>(.+?)</option>')
|
||||
option = patt.findall(j)
|
||||
return option
|
||||
|
||||
# 扫描目录
|
||||
def getPaths(v, p='/', files=[], folders=[], proxies=None):
|
||||
h = getHTML(url + v + p, proxies=proxies)
|
||||
t = re.findall(r'<table(.*?)</table>', h, re.S)[0]
|
||||
href = re.findall('href="(.*?)"', t)
|
||||
for name in href:
|
||||
path = p + name
|
||||
if name in ['../', 'LICENSE'] or path in ['/src/', '/packages/', '/types/', '/dist/docs/', '/docs/',
|
||||
'/samples/', "/test/", "/locale/"]: # 跳过
|
||||
continue
|
||||
print(path)
|
||||
if name[-1] == '/':
|
||||
folders.append(path)
|
||||
getPaths(v, path, files, folders, proxies)
|
||||
else:
|
||||
files.append(path)
|
||||
return {"files": files, "folders": folders}
|
||||
|
||||
# 创建目录
|
||||
def makeDirs(dirs, p):
|
||||
if p is None:
|
||||
p = './'
|
||||
for i in dirs:
|
||||
path = p + i
|
||||
if not os.path.exists(path):
|
||||
print("创建目录", path)
|
||||
os.makedirs(path)
|
||||
|
||||
# 下载文件
|
||||
def download(url, path=None, proxies=None):
|
||||
try:
|
||||
with requests_retry_session(proxies=proxies).get(url, proxies=proxies) as r:
|
||||
r.raise_for_status()
|
||||
if not os.path.exists(path):
|
||||
print("下载:", url)
|
||||
t = str(time.time()) + '.' + str(os.getpid()) + '.tmp'
|
||||
with open(t, 'wb') as tmp_file:
|
||||
tmp_file.write(r.content)
|
||||
os.rename(t, path)
|
||||
else:
|
||||
print("文件已存在")
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f"下载文件时发生错误: {e}")
|
||||
|
||||
# 获取所有版本并展示
|
||||
versions = getVsions(mod)
|
||||
print("所有版本:", versions)
|
||||
|
||||
# 选择版本
|
||||
version = input("请输入版本号(留空使用最新版):") or versions[-1]
|
||||
print("选择的版本:", version)
|
||||
|
||||
# 构建版本路径
|
||||
version_path = mod + '@' + version
|
||||
|
||||
# 检查当前目录是否存在该版本
|
||||
if os.path.exists(version_path):
|
||||
print(f"版本 {version_path} 已存在,不再下载。")
|
||||
else:
|
||||
# 使用代理
|
||||
proxies = None
|
||||
use_proxy = input("是否使用代理?(输入 'y' 或 'n'): ").lower()
|
||||
if use_proxy == 'y':
|
||||
# 获取代理设置
|
||||
default_proxy_host = "10.10.50.210" # 设置默认代理主机
|
||||
default_proxy_port = 65115 # 设置默认代理端口
|
||||
|
||||
proxy_host = input(f"请输入代理主机 (默认为 {default_proxy_host}): ") or default_proxy_host
|
||||
proxy_port = int(input(f"请输入代理端口 (默认为 {default_proxy_port}): ") or default_proxy_port)
|
||||
proxy_username = input("请输入代理用户名(如果不需要身份验证,直接回车): ")
|
||||
proxy_password = input("请输入代理密码(如果不需要身份验证,直接回车): ")
|
||||
|
||||
# 设置代理
|
||||
proxies = {
|
||||
'http': f'socks5://{proxy_username}:{proxy_password}@{proxy_host}:{proxy_port}' if proxy_username else f'socks5://{proxy_host}:{proxy_port}',
|
||||
'https': f'socks5://{proxy_username}:{proxy_password}@{proxy_host}:{proxy_port}' if proxy_username else f'socks5://{proxy_host}:{proxy_port}'
|
||||
}
|
||||
|
||||
paths = getPaths(version_path, proxies=proxies)
|
||||
makeDirs(paths["folders"], version_path)
|
||||
for i in paths["files"]:
|
||||
u = url + version_path + i
|
||||
download(u, version_path + '/' + i, proxies)
|
||||
print("下载完成")
|
20
Python/UNPKG/requirements.txt
Normal file
20
Python/UNPKG/requirements.txt
Normal file
@ -0,0 +1,20 @@
|
||||
certifi==2024.7.4
|
||||
charset-normalizer==3.3.2
|
||||
colorama==0.4.6
|
||||
colorlog==6.8.2
|
||||
hjson==3.1.0
|
||||
idna==3.7
|
||||
mcdreforged==2.13.1
|
||||
packaging==24.1
|
||||
parse==1.20.2
|
||||
prompt_toolkit==3.0.47
|
||||
psutil==6.0.0
|
||||
py-cpuinfo==9.0.0
|
||||
PySocks==1.7.1
|
||||
requests==2.32.3
|
||||
resolvelib==1.0.1
|
||||
ruamel.yaml==0.18.6
|
||||
ruamel.yaml.clib==0.2.8
|
||||
typing_extensions==4.12.2
|
||||
urllib3==2.2.2
|
||||
wcwidth==0.2.13
|
9
Python/Ups-Smtp/Readme.md
Normal file
9
Python/Ups-Smtp/Readme.md
Normal file
@ -0,0 +1,9 @@
|
||||
# 来电邮箱提示
|
||||
|
||||
## 前言
|
||||
|
||||
本人买了雷迪司的UPS,这东西挺好,有停电提醒,同时也有来电提醒,但是不知道为什么来电提醒不生效,所以自己整了一个
|
||||
|
||||
## QAQ
|
||||
|
||||
如果你的UPS也存在这种问题不妨也用这个曲线救国试试
|
8
Python/Ups-Smtp/build.py
Normal file
8
Python/Ups-Smtp/build.py
Normal file
@ -0,0 +1,8 @@
|
||||
# build.py
|
||||
import PyInstaller.__main__
|
||||
|
||||
PyInstaller.__main__.run([
|
||||
'ups-test.py', # Python脚本文件名
|
||||
'--onefile', # 生成单个可执行文件
|
||||
|
||||
])
|
54
Python/Ups-Smtp/ups-test.py
Normal file
54
Python/Ups-Smtp/ups-test.py
Normal file
@ -0,0 +1,54 @@
|
||||
import os
|
||||
import smtplib
|
||||
from email.mime.text import MIMEText
|
||||
from datetime import datetime
|
||||
|
||||
def send_email(subject, message, recipient):
|
||||
sender = "syayuri@xbox.email.cn"
|
||||
password = "3NCjnCAcMJEFM7db"
|
||||
|
||||
# 设置邮件内容
|
||||
email = MIMEText(message)
|
||||
email["Subject"] = subject
|
||||
email["From"] = sender
|
||||
email["To"] = recipient
|
||||
|
||||
# 连接SMTP服务器
|
||||
with smtplib.SMTP_SSL("smtp.email.cn", 465) as server:
|
||||
# 登录SMTP服务器
|
||||
server.login(sender, password)
|
||||
|
||||
# 发送邮件
|
||||
server.sendmail(sender, [recipient], email.as_string())
|
||||
|
||||
print("邮件发送成功!")
|
||||
|
||||
def main():
|
||||
command = "baidu.com" # 替换为要ping的域名或IP地址
|
||||
recipient = "mirai@lolicon.team" # 替换为要发送邮件的邮箱地址
|
||||
subject = "UPS输入市电恢复" # 替换为邮件主题
|
||||
|
||||
# 动态生成DateTime内容
|
||||
now = datetime.now()
|
||||
datetime_str = now.strftime("%Y-%m-%d %H:%M:%S")
|
||||
message = f"""
|
||||
来自 USB790470F_ID;
|
||||
事件: UPS输入市电异常;
|
||||
类型: 输入事件;
|
||||
Contact: syayuri@xbox.email.cn;
|
||||
DateTime: {datetime_str}
|
||||
""" # 替换为要发送的邮件内容
|
||||
|
||||
ping_result = 1
|
||||
while ping_result != 0:
|
||||
# 执行ping命令
|
||||
ping_result = os.system(f"ping -c 1 {command}")
|
||||
|
||||
if ping_result == 0:
|
||||
# ping成功,发送电子邮件
|
||||
send_email(subject, message, recipient)
|
||||
else:
|
||||
print("Ping失败,正在重试...")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
11
Python/dns-ip/Readme.md
Normal file
11
Python/dns-ip/Readme.md
Normal file
@ -0,0 +1,11 @@
|
||||
# 用于dnspod公共DNS绑定
|
||||
|
||||
- 自带拦截规则
|
||||
- 支持电脑的53端口直接用
|
||||
- 相应快
|
||||
- 每月300万次请求/FREE
|
||||
- 个人用完全足够,但多人就不行了
|
||||
|
||||
## 该项目有什么用
|
||||
|
||||
本项目通过监听本机IP变动进行主动绑定保持规则可用性
|
54
Python/dns-ip/main.py
Normal file
54
Python/dns-ip/main.py
Normal file
@ -0,0 +1,54 @@
|
||||
import requests
|
||||
import time
|
||||
import json
|
||||
|
||||
def get_current_ip():
|
||||
try:
|
||||
response = requests.get("https://archive.ovofish.com/api/center/ipsee/")
|
||||
data = response.json()
|
||||
print("API响应:", data) # 打印完整的API响应
|
||||
return data["ip"]
|
||||
except KeyError:
|
||||
print("API返回的JSON格式不正确,未找到'ip'键。")
|
||||
return None
|
||||
except Exception as e:
|
||||
print(f"发生错误:{e}")
|
||||
return None
|
||||
|
||||
def perform_action(ip):
|
||||
if ip is not None:
|
||||
# 执行你的操作,访问 https://link.dns.pub/
|
||||
# 你可以使用 requests.get() 或其他适当的方法
|
||||
url = "https://link.dns.pub/"
|
||||
try:
|
||||
response = requests.get(url)
|
||||
# 在这里可以添加处理响应的代码,例如检查状态码、打印内容等
|
||||
print(f"执行操作,访问 {url},当前IP: {ip}")
|
||||
except Exception as e:
|
||||
print(f"执行操作时发生错误:{e}")
|
||||
else:
|
||||
print("无法获取有效的IP地址,跳过执行操作。")
|
||||
|
||||
def main():
|
||||
current_ip = get_current_ip()
|
||||
|
||||
# 初始操作
|
||||
perform_action(current_ip)
|
||||
|
||||
while True:
|
||||
time.sleep(120)
|
||||
|
||||
new_ip = get_current_ip()
|
||||
|
||||
if new_ip is not None and new_ip != current_ip:
|
||||
print("IP 已更改,执行操作")
|
||||
|
||||
# 执行操作
|
||||
perform_action(new_ip)
|
||||
|
||||
current_ip = new_ip
|
||||
else:
|
||||
print("IP 未更改,继续等待")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
49
Python/ping-logs/Readme.md
Normal file
49
Python/ping-logs/Readme.md
Normal file
@ -0,0 +1,49 @@
|
||||
# 用于监听本机网络波动
|
||||
|
||||
- 监测网络波动
|
||||
- URL传输到服务器数据库中存储日志
|
||||
- 可本地文件存储
|
||||
- 仅检测
|
||||
|
||||
## 该项目有什么用
|
||||
|
||||
方便投诉你的运营商,让其网络保持稳定
|
||||
|
||||
## 如何使用
|
||||
|
||||
所需环境`ping3`
|
||||
|
||||
```python
|
||||
pip install ping3
|
||||
```
|
||||
|
||||
你需要准备一个`config.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"target_ips": {
|
||||
"需要ping的IP": {"location": "位置", "threshold_ms": 设置阈值, "log_method": "触发"},
|
||||
"需要ping的IP": {"location": "位置", "threshold_ms": 设置阈值, "log_method": "触发"},
|
||||
"需要ping的IP": {"location": "位置", "threshold_ms": 设置阈值, "log_method": "触发"}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
示例
|
||||
|
||||
```json
|
||||
{
|
||||
"target_ips": {
|
||||
"10.10.50.1": {"location": "Home", "threshold_ms": 10, "log_method": "url"},
|
||||
"10.10.51.1": {"location": "Home2", "threshold_ms": 30, "log_method": "url"},
|
||||
"10.10.92.1": {"location": "Home3", "threshold_ms": 100, "log_method": "url"}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
阈值单位为MS,请根据你的网络环境进行调整
|
||||
|
||||
超出该阈值时则触发条件
|
||||
|
||||
log_method:`file`,`url`,`console`
|
||||
|
77
Python/ping-logs/main.py
Normal file
77
Python/ping-logs/main.py
Normal file
@ -0,0 +1,77 @@
|
||||
import time
|
||||
from ping3 import ping
|
||||
import requests
|
||||
import json
|
||||
import sys
|
||||
import io
|
||||
# 设置标准输入输出为UTF-8编码
|
||||
sys.stdout.reconfigure(encoding='utf-8')
|
||||
sys.stdin.reconfigure(encoding='utf-8')
|
||||
def load_config():
|
||||
with open("config.json", "r", encoding="utf-8") as config_file:
|
||||
config_data = json.load(config_file)
|
||||
return config_data["target_ips"]
|
||||
|
||||
def continuous_ping(ip_addresses):
|
||||
while True:
|
||||
for ip_address, data in ip_addresses.items():
|
||||
location = data["location"]
|
||||
threshold_ms = data["threshold_ms"]
|
||||
log_method = data["log_method"]
|
||||
|
||||
delay = ping(ip_address)
|
||||
|
||||
if delay is not None:
|
||||
# print(f'Ping delay to {location} ({ip_address}): {delay * 1000:.2f} ms')
|
||||
delay = int(delay * 1000)
|
||||
else:
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S")}Ping to {location} ({ip_address}) failed.')
|
||||
delay = 0 # 或者设定其他默认值
|
||||
if delay is not None and delay > threshold_ms:
|
||||
log_message = f'High latency detected for {location} ({ip_address})! Delay: {delay}ms'
|
||||
|
||||
if log_method == "file":
|
||||
try:
|
||||
with open(f'{location}_ping_log.txt', 'a', encoding="utf-8") as log_file:
|
||||
log_file.write(f'{time.strftime("%Y-%m-%d %H:%M:%S")}\t{ip_address}\t{delay}ms\n')
|
||||
except Exception as e:
|
||||
print(f'Error writing to file: {e}')
|
||||
elif log_method == "console":
|
||||
print(log_message)
|
||||
elif log_method == "url":
|
||||
target_url = "https://archive.ovofish.com/api/center/ping-logs/"
|
||||
|
||||
payload = {"location": location, "ip_address": ip_address, "delay": delay}
|
||||
headers = {"Content-Type": "application/json"}
|
||||
|
||||
try:
|
||||
response = requests.post(target_url, data=json.dumps(payload), headers=headers)
|
||||
if response.status_code == 200:
|
||||
print(f'Delay information sent to {target_url} successfully.')
|
||||
else:
|
||||
print(f'Failed to send delay information to {target_url}. Status code: {response.status_code}')
|
||||
|
||||
# 获取返回的 JSON 数据
|
||||
try:
|
||||
error_json = response.json()
|
||||
print(f'Error JSON: {error_json}')
|
||||
except json.JSONDecodeError:
|
||||
print('Failed to decode error JSON.')
|
||||
except Exception as e:
|
||||
print(f'Error sending delay information to {target_url}: {e}')
|
||||
else:
|
||||
pass
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 判断是否有配置文件
|
||||
try:
|
||||
with open("config.json", "r") as config_file:
|
||||
config_data = json.load(config_file)
|
||||
except FileNotFoundError:
|
||||
print("配置文件不存在,请检查文件路径。")
|
||||
exit(1)
|
||||
print("正在运行...")
|
||||
target_ips = load_config()
|
||||
continuous_ping(target_ips)
|
0
Python/teamspeak-doownload/README.md
Normal file
0
Python/teamspeak-doownload/README.md
Normal file
149
Python/teamspeak-doownload/mian.py
Normal file
149
Python/teamspeak-doownload/mian.py
Normal file
@ -0,0 +1,149 @@
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
import re
|
||||
import json
|
||||
import os
|
||||
import hmac
|
||||
from hashlib import sha1
|
||||
|
||||
|
||||
print("Start downloading file links...")
|
||||
|
||||
# 发送GET请求获取页面内容
|
||||
url = "https://teamspeak.com/zh-CN/downloads/"
|
||||
response = requests.get(url)
|
||||
soup = BeautifulSoup(response.content, "html.parser")
|
||||
|
||||
# 找到所有<a>标签并提取链接
|
||||
links = soup.find_all("a", href=True)
|
||||
|
||||
# 匹配包含"https://files.teamspeak-services.com"的链接
|
||||
file_links = [link["href"] for link in links if re.search(r"https://files.teamspeak-services.com", link["href"])]
|
||||
|
||||
# 按版本划分链接
|
||||
ver3_links = [link for link in file_links if re.search(r"\/3\.\d+\.\d+\/", link)]
|
||||
ver5_links = [link for link in file_links if re.search(r"\/(?:5\.\d+\.\d+|5\.\d+\.\d+\-\w+)/", link)]
|
||||
|
||||
# 设置全局变量
|
||||
download_file = True
|
||||
file_updated = False
|
||||
# 创建版本文件夹并保存链接
|
||||
def save_links_to_folder(links, folder_name):
|
||||
folder_path = os.path.join(os.getcwd(), "file", folder_name)
|
||||
if not os.path.exists(folder_path):
|
||||
os.makedirs(folder_path)
|
||||
|
||||
for link in links:
|
||||
file_name = link.split("/")[-1]
|
||||
file_path = os.path.join(folder_path, file_name)
|
||||
|
||||
# 检查文件是否需要更新
|
||||
global download_file
|
||||
if os.path.exists(file_path):
|
||||
response = requests.head(link)
|
||||
remote_file_size = int(response.headers.get('Content-Length', 0))
|
||||
local_file_size = os.path.getsize(file_path)
|
||||
if remote_file_size == local_file_size:
|
||||
download_file = False
|
||||
print(f"文件 {file_name} 已更新。无需下载。")
|
||||
else:
|
||||
download_file = True
|
||||
os.remove(file_path)
|
||||
|
||||
# 如果需要下载文件
|
||||
if download_file:
|
||||
with open(file_path, "wb") as file:
|
||||
response = requests.get(link)
|
||||
file.write(response.content)
|
||||
print(f"文件 {file_name} 已下载到 {folder_name}")
|
||||
|
||||
# 保存链接到对应版本文件夹中
|
||||
save_links_to_folder(ver3_links, "Ver3")
|
||||
save_links_to_folder(ver5_links, "Ver5")
|
||||
|
||||
# 将链接存储为JSON文件
|
||||
data = {"Ver3": ver3_links, "Ver5": ver5_links}
|
||||
|
||||
with open("file_links.json", "w") as json_file:
|
||||
json.dump(data, json_file, indent=4)
|
||||
|
||||
print("链接已保存至file_links.json")
|
||||
|
||||
def downloadFile():
|
||||
global file_updated
|
||||
if download_file:
|
||||
print("download_file的值为:", download_file)
|
||||
file_updated = True
|
||||
else:
|
||||
print("download_file的值为:", download_file)
|
||||
file_updated = False
|
||||
downloadFile()
|
||||
print("file_updated的最终值为:", file_updated)
|
||||
|
||||
# 生成本地文件下载链接
|
||||
base_download_url = "https://file-teamspeak-download.lolicon.team/file/"
|
||||
|
||||
def generate_local_download_links(links, folder_name):
|
||||
local_download_links = [base_download_url + folder_name + "/" + link.split("/")[-1] for link in links]
|
||||
return local_download_links
|
||||
|
||||
ver3_local_download_links = generate_local_download_links(ver3_links, "Ver3")
|
||||
ver5_local_download_links = generate_local_download_links(ver5_links, "Ver5")
|
||||
|
||||
# 将本地文件下载链接存储为JSON文件
|
||||
local_download_links_data = {"Ver3": ver3_local_download_links, "Ver5": ver5_local_download_links}
|
||||
|
||||
with open("local_download_links.json", "w") as local_json_file:
|
||||
json.dump(local_download_links_data, local_json_file, indent=4)
|
||||
|
||||
print("本地下载链接已保存至local_download_links.json")
|
||||
|
||||
# 判断是否有文件更新
|
||||
if file_updated:
|
||||
print("文件已更新,开始预热CDN...")
|
||||
# 预热 CDN
|
||||
def dogecloud_api(api_path, data={}, json_mode=False):
|
||||
print('正在调用多吉云 API...')
|
||||
access_key = '' # 请将此处替换为你的多吉云 Access Key
|
||||
secret_key = '' # 请将此处替换为你的多吉云 Secret Key
|
||||
# 如果没有 access_key 和 secret_key,则跳过下面所有操作
|
||||
if not access_key or not secret_key:
|
||||
print('请填写多吉云 Access Key 和 Secret Key。')
|
||||
return None
|
||||
|
||||
body = ''
|
||||
mime = ''
|
||||
if json_mode:
|
||||
body = json.dumps(data)
|
||||
mime = 'application/json'
|
||||
else:
|
||||
body = urllib.parse.urlencode(data)
|
||||
mime = 'application/x-www-form-urlencoded'
|
||||
|
||||
sign_str = api_path + "\n" + body
|
||||
signed_data = hmac.new(secret_key.encode('utf-8'), sign_str.encode('utf-8'), sha1)
|
||||
sign = signed_data.digest().hex()
|
||||
authorization = 'TOKEN ' + access_key + ':' + sign
|
||||
|
||||
response = requests.post('https://api.dogecloud.com' + api_path, data=body, headers={
|
||||
'Authorization': authorization,
|
||||
'Content-Type': mime
|
||||
})
|
||||
|
||||
return response.json()
|
||||
|
||||
api_path = '/cdn/refresh/add.json'
|
||||
data = {
|
||||
'rtype': 'prefetch',
|
||||
'urls': json.dumps(all_local_links)
|
||||
}
|
||||
response = dogecloud_api(api_path, data, json_mode=True)
|
||||
print(response)
|
||||
data = {
|
||||
'rtype': 'path',
|
||||
'urls': 'https://file-teamspeak-download.lolicon.team/file/'
|
||||
}
|
||||
response = dogecloud_api(api_path, data, json_mode=True)
|
||||
print(response)
|
||||
else:
|
||||
print("文件未更新,无需预热CDN。")
|
23
Python/teamspeak-doownload/requirements.txt
Normal file
23
Python/teamspeak-doownload/requirements.txt
Normal file
@ -0,0 +1,23 @@
|
||||
beautifulsoup4==4.12.3
|
||||
bs4==0.0.2
|
||||
certifi==2024.7.4
|
||||
charset-normalizer==3.3.2
|
||||
colorama==0.4.6
|
||||
colorlog==6.8.2
|
||||
hjson==3.1.0
|
||||
idna==3.7
|
||||
mcdreforged==2.13.1
|
||||
packaging==24.1
|
||||
parse==1.20.2
|
||||
prompt_toolkit==3.0.47
|
||||
psutil==6.0.0
|
||||
py-cpuinfo==9.0.0
|
||||
PySocks==1.7.1
|
||||
requests==2.32.3
|
||||
resolvelib==1.0.1
|
||||
ruamel.yaml==0.18.6
|
||||
ruamel.yaml.clib==0.2.8
|
||||
soupsieve==2.6
|
||||
typing_extensions==4.12.2
|
||||
urllib3==2.2.2
|
||||
wcwidth==0.2.13
|
Loading…
x
Reference in New Issue
Block a user