Skip to content

Commit

Permalink
fix: 适配4399当前页面即为真实页面的情况
Browse files Browse the repository at this point in the history
  • Loading branch information
Cnotech committed Feb 29, 2024
1 parent efc4a6d commit a2f79a0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
15 changes: 14 additions & 1 deletion packages/main/modules/com4399.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,20 @@ const testMap: Record<string, GameInfo> = {
"binUrl": "https://s4.4399.com/4399swf/upload_swf/ftp/20090929/1/pvz_9_15.swf",
"icon": "http://imga3.5054399.com/upload_pic/2016/2/18/4399_18432063237.jpg"
}
}
},
"https://www.4399.com/flash/94107.htm":
{
"title": "愤怒的小鸟免费神鹰版",
"category": "益智",
"type": "flash",
"fromSite": "4399",
"online": {
"originPage": "http://www.4399.com/flash/94107.htm",
"truePage": "http://sxiao.4399.com/4399swf/upload_swf/ftp8/zhichang/20120723/001.swf",
"binUrl": "http://sxiao.4399.com/4399swf/upload_swf/ftp8/zhichang/20120723/001.swf",
"icon": "http://imga3.5054399.com/upload_pic/2012/7/23/4399_10113765770.jpg"
}
}
}
test("4399", async () => {
//初始化模块
Expand Down
29 changes: 6 additions & 23 deletions packages/main/modules/com4399.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {GameInfo} from '../../class';
import {BrowserWindow} from 'electron';
import iconv from 'iconv-lite';
import cheerio from 'cheerio';
import {GBKEncodeUri,GBKDecodeUri} from "./GBKUri";
import {GBKDecodeUri, GBKEncodeUri} from "./GBKUri";

let cookie: string | null = null
let updateCookie: (cookie: string) => void
Expand Down Expand Up @@ -176,30 +176,13 @@ async function entrance(url: string): Promise<Result<GameInfo, string>> {
resolve(pvzPatchRes)
return
}
// 加入直接拿 swf 路径的补丁
const m=(originPage as string).match(/[/\w_]+\.swf/)
if(m?.length){
const binUrl=fullUrl(m[0])
if(!binUrl){
return new Err(`Error:Failed to full url for '${m[0]}'`)
}
resolve(new Ok({
title,
category,
type: "flash",
fromSite: "4399",
online: {
originPage: url,
truePage: binUrl,
binUrl,
icon: await getIcon(title, id)
}
}))
// 也有可能当前页就是真实页面
if (originPage.match(/_strGamePath\s*=\s*".*"/)?.length) {
m = [`/flash/${id}.htm`]
} else {
resolve(new Err("Error:Can't parse playing page"))
return
}

resolve(new Err("Error:Can't parse playing page"))
return
}
const playingPage = m[0]
// console.log('playingPage:'+playingPage)
Expand Down

0 comments on commit a2f79a0

Please sign in to comment.