Merge branch 'main' into feature-invalidInfo
This commit is contained in:
@ -1,9 +1,15 @@
|
||||
import 'package:pilipala/models/common/invalid_video.dart';
|
||||
import 'dart:convert';
|
||||
import 'dart:math';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pilipala/models/sponsor_block/segment.dart';
|
||||
|
||||
import 'index.dart';
|
||||
|
||||
class CommonHttp {
|
||||
static final RegExp spmPrefixExp =
|
||||
RegExp(r'<meta name="spm_prefix" content="([^"]+?)">');
|
||||
static Future unReadDynamic() async {
|
||||
var res = await Request().get(Api.getUnreadDynamic,
|
||||
data: {'alltype_offset': 0, 'video_offset': '', 'article_offset': 0});
|
||||
@ -70,4 +76,42 @@ class CommonHttp {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
static Future buvidActivate() async {
|
||||
try {
|
||||
// 获取 HTML 数据
|
||||
var html = await Request().get(Api.dynamicSpmPrefix);
|
||||
|
||||
// 提取 spmPrefix
|
||||
String spmPrefix = spmPrefixExp.firstMatch(html.data)?.group(1) ?? '';
|
||||
|
||||
// 生成随机 PNG 结束部分
|
||||
Random rand = Random();
|
||||
String randPngEnd = base64.encode(
|
||||
List<int>.generate(32, (_) => rand.nextInt(256))
|
||||
..addAll(List<int>.filled(4, 0))
|
||||
..addAll([73, 69, 78, 68])
|
||||
..addAll(List<int>.generate(4, (_) => rand.nextInt(256))),
|
||||
);
|
||||
|
||||
// 构建 JSON 数据
|
||||
String jsonData = json.encode({
|
||||
'3064': 1,
|
||||
'39c8': '$spmPrefix.fp.risk',
|
||||
'3c43': {
|
||||
'adca': 'Linux',
|
||||
'bfe9': randPngEnd.substring(randPngEnd.length - 50),
|
||||
},
|
||||
});
|
||||
|
||||
// 发送 POST 请求
|
||||
await Request().post(
|
||||
Api.activateBuvidApi,
|
||||
data: {'payload': jsonData},
|
||||
options: Options(contentType: 'application/json'),
|
||||
);
|
||||
} catch (err) {
|
||||
debugPrint('buvidActivate error: $err');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user