forked from Hiram-Wong/ZyPlayer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Hiram
committed
Mar 24, 2024
1 parent
f12b9af
commit 3dffb9b
Showing
4 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,25 @@ | ||
/*! | ||
* @module drpy3 | ||
* @brief T3数据处理核心库 | ||
* @version 3.1.0 | ||
* | ||
* @original-author hjdhnx | ||
* @original-source {@link https://github.com/hjdhnx/hipy-server/blob/master/app/t4/files/drpy3_libs/drpy3.js | Source on GitHub} | ||
* | ||
* @modified-by HiramWong <[email protected]> | ||
* @modification-date 2023-03-24T18:21:29+08:00 | ||
* @modification-description 使用TypeScript适配, 适用于JavaScript项目, 并采取措施防止 Tree-Shaking 删除关键代码 | ||
* | ||
* **防止 Tree-Shake 说明**: | ||
* - 为了确保 `drpy3.ts` 中的函数和变量不被 Tree Shaking, 已采取以下措施: | ||
* - 作用域参数举例:`[a, b, c].forEach(item => item.length)` —— 显式遍历数组元素防止数组相关操作被优化掉。 | ||
* - 作用域函数举例:`let temp = _; temp.stringify({});` —— 对于 `_` 符合的对象,确保其方法被调用,防止被误删。 | ||
* - 全局函数与参数举例:`keepUnUse.useful._` —— 对于 `_` 符合的对象,确保其方法被调用,防止被误删。 | ||
* | ||
* --- | ||
*/ | ||
|
||
|
||
import CryptoJS from 'crypto-js'; | ||
import cheerio from "./cheerio.min"; | ||
import joinUrl from 'url'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
/*! | ||
* @module drpyInject | ||
* @brief T3网络请求、缓存模块处理库 | ||
* @version 3.1.0 | ||
* | ||
* @original-author hjdhnx | ||
* @original-source {@link https://github.com/hjdhnx/hipy-server/blob/master/app/utils/quickjs_ctx.py | Source on GitHub} | ||
* | ||
* @modified-by HiramWong <[email protected]> | ||
* @modification-date 2023-03-24T18:21:29+08:00 | ||
* @modification-description Python转TypeScript, 适用于JavaScript项目 | ||
*/ | ||
|
||
import syncFetch from 'sync-fetch'; | ||
import jsoup from './htmlParser'; | ||
|
||
|
@@ -157,7 +170,7 @@ const pdfl = (html: string, parse: string, list_text: string, list_url: string, | |
return jsp.pdfl(html, parse, list_text, list_url, url_key); | ||
} | ||
|
||
const CACHE_URL = String(import.meta.env.DEV ? '/api' : `${import.meta.env.VITE_APP_API_URL}${import.meta.env.VITE_API_URL_PREFIX}`) + '/v1/cache'; | ||
const CACHE_URL = String(import.meta.env.DEV ? '/api' : `${import.meta.env.VITE_API_URL}${import.meta.env.VITE_API_URL_PREFIX}`) + '/v1/cache'; | ||
|
||
const local_get = (_id: string, key: string, value: string = '') => { | ||
const url = `${CACHE_URL}/${_id}${key}`; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
/*! | ||
* @module htmlParser | ||
* @brief T3解析html处理库 | ||
* @version 3.1.0 | ||
* | ||
* @original-author hjdhnx | ||
* @original-source {@link https://github.com/hjdhnx/hipy-server/blob/master/app/t4/base/htmlParser.py | Source on GitHub} | ||
* | ||
* @modified-by HiramWong <[email protected]> | ||
* @modification-date 2023-03-24T18:21:29+08:00 | ||
* @modification-description Python转TypeScript, 适用于JavaScript项目 | ||
*/ | ||
|
||
import * as cheerio from 'cheerio'; | ||
import jsonpath from 'jsonpath'; | ||
import urlJoin from 'url'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,19 @@ | ||
import { init, home, homeVod, category, detail, play, search, proxy, sniffer, isVideo } from './drpy3'; | ||
/*! | ||
* @module worker | ||
* @brief web-worker 专属线程处理 | ||
* @version 0.0.1 | ||
* @author HiramWong <[email protected]> | ||
* @date 2023-03-24T18:21:29+08:00 | ||
*/ | ||
|
||
import { init, home, homeVod, category, detail, play, search, keepUnUse } from './drpy3'; | ||
|
||
const initUtils = () => { | ||
console.log(`[worker][prevent tree-shake] init t3 not use module`); | ||
keepUnUse.useful(); | ||
} | ||
|
||
if (!import.meta.env.DEV) initUtils(); // 防止tree-shake | ||
|
||
const drpyWork = (parms) => { | ||
const { type, data } = parms; | ||
|