-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [feat(routes)] Add ipsw.dev support * fix: use art-template * fix: host * fix: add __dirname * fix: namespace ---------
- Loading branch information
Showing
3 changed files
with
91 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { Data, Route } from '@/types'; | ||
import got from '@/utils/got'; | ||
import { load } from 'cheerio'; | ||
import { art } from '@/utils/render'; | ||
import path from 'node:path'; | ||
import { getCurrentPath } from '@/utils/helpers'; | ||
|
||
export const route: Route = { | ||
path: '/index/:productID', | ||
categories: ['program-update'], | ||
example: '/ipsw.dev/index/iPhone16,1', | ||
parameters: { | ||
productID: 'Product ID', | ||
}, | ||
name: 'Apple latest beta firmware', | ||
maintainers: ['RieN7'], | ||
handler, | ||
}; | ||
|
||
async function handler(ctx) { | ||
const { productID } = ctx.req.param(); | ||
const __dirname = getCurrentPath(import.meta.url); | ||
const link = `https://ipsw.dev/product/version/${productID}`; | ||
|
||
const resp = await got({ | ||
method: 'get', | ||
url: link, | ||
headers: { | ||
Referer: 'https://ipsw.dev/', | ||
}, | ||
}); | ||
|
||
const $ = load(resp.data); | ||
|
||
const productName = $('#IdentifierModal > div > div > div.modal-body > p:nth-child(1) > em').text(); | ||
|
||
const list: Data[] = $('.firmware') | ||
.map((index, element) => { | ||
const ele = $(element); | ||
const version = ele.find('td:nth-child(1) > div > div > strong').text(); | ||
const build = ele.find('td:nth-child(1) > div > div > div > code').text(); | ||
const date = ele.find('td:nth-child(3)').text(); | ||
const size = ele.find('td:nth-child(4)').text(); | ||
return { | ||
title: `${productName} - ${version}`, | ||
link: `https://ipsw.dev/download/${productID}/${build}`, | ||
pubDate: new Date(date).toLocaleDateString(), | ||
guid: build, | ||
description: art(path.join(__dirname, 'templates/description.art'), { | ||
version, | ||
build, | ||
date, | ||
size, | ||
}), | ||
}; | ||
}) | ||
.get(); | ||
|
||
return { | ||
title: `${productName} Released`, | ||
link, | ||
item: list, | ||
}; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: 'IPSW.dev', | ||
url: 'ipsw.dev', | ||
description: 'Download the latest beta firmware for iPhone, iPad, Mac, Apple Vision Pro, and Apple TV. Check the signing status of the beta firmware.', | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<table> | ||
<tbody> | ||
<tr> | ||
<th>Version</th> | ||
<td>{{ version }}</td> | ||
</tr> | ||
<tr> | ||
<th>Build</th> | ||
<td>{{ build }}</td> | ||
</tr> | ||
<tr> | ||
<th>Released</th> | ||
<td>{{ released }}</td> | ||
</tr> | ||
<tr> | ||
<th>Size</th> | ||
<td>{{ size }}</td> | ||
</tr> | ||
</tbody> | ||
</table> |