Skip to content

Commit

Permalink
Merge pull request #2075 from DIYgod/master
Browse files Browse the repository at this point in the history
[pull] master from diygod:master
  • Loading branch information
pull[bot] authored Feb 5, 2025
2 parents 4f87dde + d2d3472 commit 091c524
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 50 deletions.
45 changes: 30 additions & 15 deletions lib/routes/gcores/templates/description.art
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
{{ if images }}
{{ each images image }}
{{ if image?.src }}
<img
{{ if image.alt }}
alt="{{ image.alt }}"
{{ /if }}
src="{{ image.src }}"
>
<figure>
<img
{{ if image.alt }}
alt="{{ image.alt }}"
{{ /if }}
{{ if image.width }}
width="{{ image.width }}"
{{ /if }}
{{ if image.height }}
height="{{ image.height }}"
{{ /if }}
src="{{ image.src }}">
</figure>
{{ /if }}
{{ /each }}
{{ /if }}
Expand All @@ -27,18 +34,26 @@
{{ /each }}
{{ /if }}

{{ if video }}
{{ if videos }}
{{ each videos video }}
{{ if video?.src }}
<video
controls>
<source
{{ if video?.type?.endsWith('taptap') }}
<iframe
src="{{ video.src }}"
type="{{ video.type }}">
<object data="{{ video.src }}">
<embed src="{{ video.src }}">
</object>
</video>
frameborder="0"
allowfullscreen>
</iframe>
{{ else }}
<video
controls>
<source
src="{{ video.src }}"
type="{{ video.type }}">
<object data="{{ video.src }}">
<embed src="{{ video.src }}">
</object>
</video>
{{ /if }}
{{ /if }}
{{ /each }}
{{ /if }}
Expand Down
29 changes: 14 additions & 15 deletions lib/routes/theinitium/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,23 @@ async function handler(ctx) {
const category = ctx.req.param('category') ?? 'latest_sc';
const __dirname = getCurrentPath(import.meta.url);
const baseUrl = 'https://app.theinitium.com/';
const userAgent = 'PugpigBolt v4.1.8 (iPhone, iOS 18.2.1) on phone (model iPhone15,2)';

const feeds = await cache.tryGet(
new URL('timelines.json', baseUrl).href,
async () =>
await got({
method: 'get',
url: new URL('timelines.json', baseUrl).href,
}),
config.cache.routeExpire,
false
);
async function getUA(url: string) {
return await got({
method: 'get',
url,
headers: {
'User-Agent': userAgent,
},
});
}

const feeds = await cache.tryGet(new URL('timelines.json', baseUrl).href, async () => await getUA(new URL('timelines.json', baseUrl).href), config.cache.routeExpire, false);

const metadata = feeds.data.timelines.find((timeline) => timeline.id === category);

const response = await got({
method: 'get',
url: new URL(metadata.feed, baseUrl).href,
});
const response = await getUA(new URL(metadata.feed, baseUrl).href);

const feed = response.data.stories.filter((item) => item.type === 'article');

Expand All @@ -113,7 +112,7 @@ async function handler(ctx) {
}
}
item.category = [...new Set(item.category)];
const response = await got(new URL(item.url, baseUrl).href);
const response = await getUA(new URL(item.url, baseUrl).href);
const $ = load(response.data);
// resolve relative links with app.theinitium.com
// code from @/middleware/paratmeter.ts
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"@opentelemetry/semantic-conventions": "1.28.0",
"@postlight/parser": "2.2.3",
"@rss3/sdk": "0.0.25",
"@scalar/hono-api-reference": "0.5.170",
"@scalar/hono-api-reference": "0.5.171",
"@sentry/node": "7.119.1",
"@tonyrl/rand-user-agent": "2.0.81",
"aes-js": "3.1.2",
Expand Down Expand Up @@ -115,7 +115,7 @@
"puppeteer-extra-plugin-user-preferences": "2.4.1",
"query-string": "9.1.1",
"rate-limiter-flexible": "5.0.5",
"re2js": "0.4.3",
"re2js": "1.0.1",
"rfc4648": "1.5.4",
"rss-parser": "3.13.0",
"sanitize-html": "2.14.0",
Expand Down
36 changes: 18 additions & 18 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 091c524

Please sign in to comment.