mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
✨ feat: V1.3.4 新增🍉视频解析,祝各位新年快乐!
1. 新增🍉视频解析
2. 增强“清理data垃圾”命令的可扩展性
This commit is contained in:
parent
2f794fd80b
commit
f219ca7108
@ -7,7 +7,7 @@ import axios from "axios";
|
||||
import _ from "lodash";
|
||||
import tunnel from "tunnel";
|
||||
import HttpProxyAgent from "https-proxy-agent";
|
||||
import { checkAndRemoveFile, deleteFolderRecursive, mkdirIfNotExists } from "../utils/file.js";
|
||||
import { checkAndRemoveFile, deleteFolderRecursive, mkdirIfNotExists, readCurrentDir } from "../utils/file.js";
|
||||
import {
|
||||
downloadBFile,
|
||||
getBiliAudio,
|
||||
@ -35,7 +35,15 @@ import { av2BV } from "../utils/bilibili-bv-av-convert.js";
|
||||
import querystring from "querystring";
|
||||
import TokenBucket from "../utils/token-bucket.js";
|
||||
import { getWbi } from "../utils/biliWbi.js";
|
||||
import { BILI_SUMMARY, DY_INFO, TIKTOK_INFO, TWITTER_TWEET_INFO, XHS_REQ_LINK, XHS_VIDEO } from "../constants/tools.js";
|
||||
import {
|
||||
BILI_SUMMARY,
|
||||
DY_INFO,
|
||||
TIKTOK_INFO,
|
||||
TWITTER_TWEET_INFO,
|
||||
XHS_REQ_LINK,
|
||||
XHS_VIDEO,
|
||||
XIGUA_REQ_LINK
|
||||
} from "../constants/tools.js";
|
||||
import child_process from 'node:child_process'
|
||||
import { getAudio, getVideo } from "../utils/y2b.js";
|
||||
import { processTikTokUrl } from "../utils/tiktok.js";
|
||||
@ -122,6 +130,10 @@ export class tools extends plugin {
|
||||
{
|
||||
reg: "(youtube.com)",
|
||||
fnc: "y2b"
|
||||
},
|
||||
{
|
||||
reg: "(ixigua.com)",
|
||||
fnc: "xigua"
|
||||
}
|
||||
],
|
||||
});
|
||||
@ -721,8 +733,9 @@ export class tools extends plugin {
|
||||
async clearTrash(e) {
|
||||
const dataDirectory = "./data/";
|
||||
|
||||
// 删除Yunzai遗留问题的合成视频垃圾文件
|
||||
try {
|
||||
const files = await fs.promises.readdir(dataDirectory);
|
||||
const files = await readCurrentDir(dataDirectory);
|
||||
let dataClearFileLen = 0;
|
||||
for (const file of files) {
|
||||
// 如果文件名符合规则,执行删除操作
|
||||
@ -731,7 +744,8 @@ export class tools extends plugin {
|
||||
dataClearFileLen++;
|
||||
}
|
||||
}
|
||||
const rTempFileLen = await deleteFolderRecursive(this.toolsConfig.defaultPath)
|
||||
// 删除R插件临时文件
|
||||
const rTempFileLen = await deleteFolderRecursive(this.defaultPath)
|
||||
e.reply(
|
||||
`数据统计:\n` +
|
||||
`- 当前清理了${ dataDirectory }下总计:${ dataClearFileLen } 个垃圾文件\n` +
|
||||
@ -1010,6 +1024,41 @@ export class tools extends plugin {
|
||||
}
|
||||
}
|
||||
|
||||
async xigua(e) {
|
||||
// 1. https://v.ixigua.com/ienrQ5bR/
|
||||
// 2. https://www.ixigua.com/7270448082586698281
|
||||
// 3. https://m.ixigua.com/video/7270448082586698281
|
||||
const msg = /(?:https?:\/\/)?(www|v|m)\.ixigua\.com\/[A-Za-z\d._?%&+\-=\/#]*/g.exec(e.msg)[0];
|
||||
|
||||
const id = /ixigua\.com\/(\d+)/.exec(msg)[1] || /\/video\/(\d+)/.exec(msg)[1];
|
||||
const videoReq = `https://www.ixigua.com/${ id }`;
|
||||
const xiguaHeader = {
|
||||
'authority': 'ib.365yg.com',
|
||||
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
||||
'accept-language': 'zh-CN,zh;q=0.9',
|
||||
'cache-control': 'no-cache',
|
||||
'pragma': 'no-cache',
|
||||
'sec-ch-ua': '"Chromium";v="116", "Not)A;Brand";v="24", "Google Chrome";v="116"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'sec-ch-ua-platform': '"macOS"',
|
||||
'sec-fetch-dest': 'document',
|
||||
'sec-fetch-mode': 'navigate',
|
||||
'sec-fetch-site': 'none',
|
||||
'sec-fetch-user': '?1',
|
||||
'upgrade-insecure-requests': '1',
|
||||
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36'
|
||||
}
|
||||
axios.get(XIGUA_REQ_LINK.replace("{}", videoReq), {
|
||||
headers: xiguaHeader
|
||||
}).then(resp => {
|
||||
const url = resp.data.data.url;
|
||||
this.downloadVideo(url).then(path => {
|
||||
e.reply(segment.video(path + "/temp.mp4"));
|
||||
});
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* 哔哩哔哩下载
|
||||
* @param title
|
||||
|
@ -1,11 +1,11 @@
|
||||
- {
|
||||
version: 1.3.3,
|
||||
version: 1.3.4,
|
||||
data:
|
||||
[
|
||||
新增<span class="cmd">🍉解析</span>功能,
|
||||
新增<span class="cmd">油管解析</span>功能,
|
||||
新增<span class="cmd">小红书无水印下载</span>功能,
|
||||
新增<span class="cmd">哔哩哔哩官方AI总结</span>功能,
|
||||
新增<span class="cmd">快手解析</span>功能,
|
||||
支持<span class="cmd">锅巴</span>插件,方便查看和修改配置,
|
||||
添加<span class="cmd">#R帮助</span>获取插件帮助,
|
||||
添加<span class="cmd">#R版本</span>获取插件版本,
|
||||
|
@ -68,4 +68,10 @@ export const TWITTER_TWEET_INFO = "https://api.twitter.com/2/tweets?ids={}"
|
||||
* XHS 的请求链接
|
||||
* @type {string}
|
||||
*/
|
||||
export const XHS_REQ_LINK = "https://www.xiaohongshu.com/explore/"
|
||||
export const XHS_REQ_LINK = "https://www.xiaohongshu.com/explore/"
|
||||
|
||||
/**
|
||||
* 🍉 的请求链接
|
||||
* @type {string}
|
||||
*/
|
||||
export const XIGUA_REQ_LINK = "http://47.99.158.118/video-crack/v2/parse?content={}"
|
@ -4,7 +4,7 @@ import axios from "axios";
|
||||
import fs from "node:fs";
|
||||
import fetch from "node-fetch";
|
||||
import { mkdirIfNotExists } from "./file.js";
|
||||
import {TEN_THOUSAND} from "../constants/constant.js";
|
||||
import { TEN_THOUSAND } from "../constants/constant.js";
|
||||
|
||||
/**
|
||||
* 请求模板
|
||||
|
@ -6,7 +6,7 @@ import path from "path";
|
||||
* @param file
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function checkAndRemoveFile(file) {
|
||||
export async function checkAndRemoveFile(file) {
|
||||
try {
|
||||
await fs.promises.access(file);
|
||||
await fs.promises.unlink(file);
|
||||
@ -23,7 +23,7 @@ async function checkAndRemoveFile(file) {
|
||||
* @param dir
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function mkdirIfNotExists(dir) {
|
||||
export async function mkdirIfNotExists(dir) {
|
||||
try {
|
||||
await fs.promises.access(dir);
|
||||
} catch (err) {
|
||||
@ -40,9 +40,9 @@ async function mkdirIfNotExists(dir) {
|
||||
* @returns {Promise<number>}
|
||||
* @param folderPath
|
||||
*/
|
||||
async function deleteFolderRecursive(folderPath) {
|
||||
export async function deleteFolderRecursive(folderPath) {
|
||||
try {
|
||||
const files = await fs.promises.readdir(folderPath);
|
||||
const files = await readCurrentDir(folderPath);
|
||||
const actions = files.map(async (file) => {
|
||||
const curPath = path.join(folderPath, file);
|
||||
|
||||
@ -64,4 +64,17 @@ async function deleteFolderRecursive(folderPath) {
|
||||
}
|
||||
}
|
||||
|
||||
export { checkAndRemoveFile, mkdirIfNotExists, deleteFolderRecursive }
|
||||
/**
|
||||
* 读取当前文件夹的所有文件和文件夹
|
||||
* @param path 路径
|
||||
* @param printTree 是否打印树状图
|
||||
* @returns {Promise<*>} 返回一个包含文件名的数组
|
||||
*/
|
||||
export async function readCurrentDir(path) {
|
||||
try {
|
||||
const files = await fs.promises.readdir(path);
|
||||
return files;
|
||||
} catch (err) {
|
||||
logger.error(err);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user