Files
RSSHub/lib/routes/ipsw.dev/index.tsx
T
Tony 5527d18de9 refactor: remove unnecessary trim/first/last (#22837)
* refactor: remove unnecessary trim/first/last

* refactor(types): allow null in DataItem.description

* refactor: remove unnecessary fallback

* refactor(types): allow null in Data.description

* refactor: remove unnecessary fallback

* refactor: remove .clone()

* refactor: refine json content text

* fIx: cognition

* fix: more fixes

* fix(route/jiemian): use api

* fix(route/jandan): housekeeping

add back maintainers from #8904

* fix(route/kcna/news): update source and target mappings

* fix(route/jandan): sanitize HTML content in titles

* refactor: remove unnecessary referer

* fix(route/jinse): regex
2026-07-27 22:23:57 +08:00

76 lines
2.4 KiB
TypeScript

import { load } from 'cheerio';
import { renderToString } from 'hono/jsx/dom/server';
import type { Data, Route } from '@/types';
import got from '@/utils/got';
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 link = `https://ipsw.dev/product/version/${productID}`;
const resp = await got({
method: 'get',
url: link,
});
const $ = load(resp.data);
const productName = $('#IdentifierModal > div > div > div.modal-body > p:nth-child(1) > em').text();
const list: Data[] = $('.firmware')
.toArray()
.map((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: renderToString(
<table>
<tbody>
<tr>
<th>Version</th>
<td>{version}</td>
</tr>
<tr>
<th>Build</th>
<td>{build}</td>
</tr>
<tr>
<th>Released</th>
<td>{date}</td>
</tr>
<tr>
<th>Size</th>
<td>{size}</td>
</tr>
</tbody>
</table>
),
};
});
return {
title: `${productName} Released`,
link,
item: list,
};
}