Skip to content

Commit

Permalink
wip: 新增部分资源API站点
Browse files Browse the repository at this point in the history
  • Loading branch information
renxia committed Jun 29, 2023
1 parent 52a8ca3 commit a41a752
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ program
.command('search [keyword]')
.alias('s')
.option('-u,--url <api...>', '影视搜索的接口地址(m3u8采集站标准接口)')
.option('-F, --force', `是否强制`)
.option('-R,--remote-config-url <url>', '自定义远程配置加载地址。默认从主仓库配置读取')
.description('m3u8视频在线搜索与下载')
.action(async (keyword, options: { url?: string[] }) => {
.action(async (keyword, options: { url?: string[]; remoteConfigUrl?: string }) => {
VideoSerachAndDL(keyword, options, getOptions());
});

Expand Down
15 changes: 11 additions & 4 deletions src/lib/video-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export interface VSOptions {
/** 播放地址缓存 */
api?: string[];
force?: boolean;
/** 远程配置的请求地址 */
remoteConfigUrl?: string;
}

/**
Expand All @@ -33,7 +35,7 @@ export interface VSOptions {
export class VideoSearch {
public apiMap = new Map<string, M3u8StorConfig['remoteConfig']['data']['apiSites'][0]>();
public get api() {
return [...this.apiMap.values()];
return [...this.apiMap.values()].reverse();
}
constructor(protected options: VSOptions = {}) {
if (!options.api?.length) options.api = [];
Expand Down Expand Up @@ -106,7 +108,8 @@ export class VideoSearch {
}

if (needUpdate) {
const url = 'https://ghproxy.com/raw.githubusercontent.com/lzwme/m3u8-dl/main/test/remote-config.json';
const url =
this.options.remoteConfigUrl || 'https://ghproxy.com/raw.githubusercontent.com/lzwme/m3u8-dl/main/test/remote-config.json';
const { data } = await req.get<M3u8StorConfig['remoteConfig']['data']>(
url,
null,
Expand Down Expand Up @@ -141,7 +144,11 @@ export class VideoSearch {
}
}

export async function VideoSerachAndDL(keyword: string, options: { url?: string[] }, baseOpts: CliOptions): Promise<void> {
export async function VideoSerachAndDL(
keyword: string,
options: { url?: string[]; remoteConfigUrl?: string },
baseOpts: CliOptions
): Promise<void> {
const cache = stor.get();
if (cache.latestSearchDL?.keyword) {
const p = await prompt<{ k: boolean }>({
Expand All @@ -158,7 +165,7 @@ export async function VideoSerachAndDL(keyword: string, options: { url?: string[
}

const vs = new VideoSearch();
await vs.updateOptions({ api: options.url || [], force: baseOpts.force });
await vs.updateOptions({ api: options.url || [], force: baseOpts.force, remoteConfigUrl: options.remoteConfigUrl });
const apis = vs.api;
let apiUrl = options.url?.length ? { url: options.url[0] } : apis[0];

Expand Down
102 changes: 102 additions & 0 deletions test/remote-config-prepare.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"apiSites": [
{
"desc": "天堂",
"url": "http://vipmv.cc/api.php/provide/vod/",
"home": "http://vipmv.cc"
},
{
"desc": "快车",
"home": "http://kuaichezy.com",
"url": "https://caiji.kczyapi.com/api.php/provide/vod/"
},
{
"desc": "天空",
"home": "https://tiankongzy.com",
"url": "https://api.tiankongapi.com/api.php/provide/vod/"
},
{
"desc": "飞速",
"home": "https://fszy2.com",
"url": "https://www.feisuzyapi.com/api.php/provide/vod/"
},
{
"desc": "卧龙",
"home": "http://wolongzy.cc",
"url": "https://collect.wolongzy.cc/api.php/provide/vod/"
},
{
"desc": "无尽",
"home": "https://wujinzy.net",
"url": "https://api.wujinapi.me/api.php/provide/vod/"
},
{
"desc": "金鹰",
"home": "https://jyzyapi.com",
"url": "https://jyzyapi.com/provide/vod/",
"enable": 1
},
{
"desc": "金鹰备用1",
"home": "http://jyzy1.com",
"url": "https://jyzy1.com/provide/vod/",
"enable": 0
},
{
"desc": "金鹰备用2",
"home": "http://jinyingzy.com",
"url": "https://jyzyapi.com/provide/vod/",
"enable": 0
},
{
"desc": "新浪",
"home": "https://www.xinlangzy.com",
"url": "https://api.xinlangapi.com/xinlangapi.php/provide/vod/"
},
{
"desc": "光速",
"home": "https://guangsuzy.com",
"url": "https://api.guangsuapi.com/api.php/provide/vod/"
},
{
"desc": "闪电",
"home": "https://www.shan05.com",
"url": "https://sdzyapi.com/api.php/provide/vod/"
},
{
"desc": "apibdzy(百度云资源)",
"home": "https://bdyunzy.com",
"url": "https://api.apibdzy.com/api.php/provide/vod/"
},
{
"desc": "U酷",
"home": "https://ukuzy0.com",
"url": "https://api.ukuapi.com/api.php/provide/vod/"
},
{
"desc": "CK资源",
"home": "https://www.ckzy1.com/",
"url": "https://ckzy.me/api.php/provide/vod/"
},
{
"desc": "量子",
"home": "http://lzizy.net",
"url": "https://cj.lziapi.com/api.php/provide/vod/"
},
{
"desc": "速播",
"home": "https://www.subozy1.com",
"url": "https://subocaiji.com/api.php/provide/vod/"
},
{
"desc": "红牛",
"home": "https://hongniuzy.net/help/",
"url": "https://www.hongniuzy2.com/api.php/provide/vod/"
},
{
"desc": "6U",
"url": "http://www.6uapi.cc/api.php/provide/vod/",
"home": "http://www.6uzy.cc"
}
]
}
33 changes: 24 additions & 9 deletions test/remote-config.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
{
"apiSites": [
{
"url": "https://jyzyapi.com/provide/vod/",
"desc": "金鹰",
"enable": 1
"desc": "天堂",
"url": "http://vipmv.cc/api.php/provide/vod/",
"home": "http://vipmv.cc"
},
{
"url": "https://jyzy1.com/provide/vod/",
"desc": "金鹰备用1",
"enable": 0
"desc": "快车",
"home": "http://kuaichezy.com",
"url": "https://caiji.kczyapi.com/api.php/provide/vod/"
},
{
"url": "https://api.xinlangapi.com/xinlangapi.php/provide/vod/",
"desc": "新浪API",
"enable": 1
"desc": "天空",
"home": "https://tiankongzy.com",
"url": "https://api.tiankongapi.com/api.php/provide/vod/"
},
{
"desc": "飞速",
"home": "https://fszy2.com",
"url": "https://www.feisuzyapi.com/api.php/provide/vod/"
},
{
"desc": "卧龙",
"home": "http://wolongzy.cc",
"url": "https://collect.wolongzy.cc/api.php/provide/vod/"
},
{
"desc": "无尽",
"home": "https://wujinzy.net",
"url": "https://api.wujinapi.me/api.php/provide/vod/"
}
]
}

0 comments on commit a41a752

Please sign in to comment.