Skip to content

Commit

Permalink
fix: update youku version retrieval method
Browse files Browse the repository at this point in the history
  • Loading branch information
xrgzs committed Oct 10, 2024
1 parent 5205529 commit b3465e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
2 changes: 1 addition & 1 deletion tasks/优酷/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ recursiveUnzipList = []
[extra]
# require_windows = false
# missing_version = ""
weekly = true
# weekly = true
27 changes: 8 additions & 19 deletions tasks/优酷/scraper.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
import { Ok, Err, Result } from "ts-results";
import { Ok, Result } from "ts-results";
import { ScraperReturned } from "../../src/class";
import { robustGet } from "../../src/network";

export default async function (): Promise<Result<ScraperReturned, string>> {
const page = (
await robustGet("https://youku.com/product/index")
).unwrap() as string;

// 匹配初始化数据
const jsonTextMatch = page.match(/window\.__INITIAL_DATA__\s*=\s*([^;]+);/g);
if (jsonTextMatch == null) return new Err("Error:Can't match initial data");
const json = JSON.parse(
jsonTextMatch[0].split(/window.__INITIAL_DATA__\s*=\s*/)[1].slice(0, -1),
);
// console.log(JSON.stringify(json,null,2))

// 选中pc版
const node = json[0].subNav[0];
// console.log(JSON.stringify(node,null,2))

const prefix = "https://pcclient.download.youku.com/iku-win-release/";
const versionUrl = `${prefix}latest.yml?noCache=${Math.random()}`;
const versionInfo: any = (await robustGet(versionUrl)).unwrap() as string;
const version = versionInfo.match(/version: (.+)/)[1];
const downloadLink = prefix + versionInfo.match(/url: (.+)/)[1];
return new Ok({
version: node.ver,
downloadLink: node.downloadUrl,
version,
downloadLink,
});
}

0 comments on commit b3465e1

Please sign in to comment.