Skip to content

Commit

Permalink
Merge pull request #1322 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 Mar 19, 2024
2 parents fbef408 + b56792e commit 0b4207b
Show file tree
Hide file tree
Showing 14 changed files with 288 additions and 1,439 deletions.
19 changes: 0 additions & 19 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,8 @@ updates:
# ESM only packages
- dependency-name: got
versions: ['>=12.0.0']
- dependency-name: remark-parse
versions: ['>=10.0.0']
- dependency-name: remark-preset-prettier
versions: ['>=1.0.0']
- dependency-name: unified
versions: ['>=10.0.0']
# remark-custom-heading-id is not updated to
# the latest mdast/mdxast which is released from
# the second half of 2023
- dependency-name: remark
versions: ['>=15.0.0']
- dependency-name: remark-frontmatter
versions: ['>=5.0.0']
- dependency-name: remark-gfm
versions: ['>=4.0.0']
- dependency-name: remark-mdx
versions: ['>=3.0.0']
- dependency-name: unist-util-visit
versions: ['>=5.0.0']
- dependency-name: unist-util-visit-parents
versions: ['>=6.0.0']

- package-ecosystem: 'github-actions'
directory: '/'
Expand Down
12 changes: 0 additions & 12 deletions .markdownlint.jsonc

This file was deleted.

1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

7 changes: 0 additions & 7 deletions .prettierignore

This file was deleted.

9 changes: 0 additions & 9 deletions jsconfig.json

This file was deleted.

2 changes: 1 addition & 1 deletion lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ router.get('/cpu/yjsy', lazyloadRouteHandler('./routes/universities/cpu/yjsy'));
router.get('/zimuku/:type?', lazyloadRouteHandler('./routes/zimuku/index'));

// Steam
router.get('/steam/search/:params', lazyloadRouteHandler('./routes/steam/search'));
// router.get('/steam/search/:params', lazyloadRouteHandler('./routes/steam/search'));

// Steamgifts
router.get('/steamgifts/discussions/:category?', lazyloadRouteHandler('./routes/steam/steamgifts/discussions'));
Expand Down
57 changes: 0 additions & 57 deletions lib/routes-deprecated/steam/search.js

This file was deleted.

5 changes: 3 additions & 2 deletions lib/routes/hicairo/rss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import { load } from 'cheerio';

export const route: Route = {
path: '/',
categories: ['blog'],
example: '/hicairo',
radar: [
{
source: ['hicairo.com/'],
target: '',
},
],
name: 'Unknown',
name: '最近发表',
maintainers: ['cnkmmk'],
handler,
url: 'hicairo.com/',
Expand Down
6 changes: 6 additions & 0 deletions lib/routes/steam/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: 'Steam',
url: 'store.steampowered.com',
};
64 changes: 64 additions & 0 deletions lib/routes/steam/search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import type { Route } from '@/types';
import got from '@/utils/got';
import { load } from 'cheerio';

export const route: Route = {
path: '/search/:params',
categories: ['game'],
example: '/steam/search/sort_by=Released_DESC&tags=492&category1=10&os=linux',
parameters: { params: 'Query parameters for a Steam Store search.' },
radar: [
{
source: ['store.steampowered.com', 'store.steampowered.com/search/:params'],
},
],
name: 'Store Search',
maintainers: ['moppman'],
handler,
};

async function handler(ctx) {
const query = new URLSearchParams(ctx.req.param('params'));
const { data: html } = await got('https://store.steampowered.com/search/', {
searchParams: query,
});
const $ = load(html);
return {
title: 'Steam search result',
description: `Query: ${query.toString()}`,
link: /g_strUnfilteredURL\s=\s'(.*)'/.exec(html)[1],
item: $('#search_result_container a')
.toArray()
.map((a) => {
const $el = $(a);
const isBundle = !!$el.attr('data-ds-bundle-data');
const isDiscounted = $el.find('.discount_original_price').length > 0;
const hasReview = $el.find('.search_review_summary').length > 0;
let desc = '';
if (isBundle) {
const bundle = JSON.parse($el.attr('data-ds-bundle-data'));
desc += 'Bundle\n';
if (bundle.m_bRestrictGifting) {
desc += 'Restrict gifting\n';
}
desc += `Items count: ${bundle.m_rgItems.length}\n`;
}
if (isDiscounted) {
desc += `Discount: ${$el.find('.discount_pct').text().trim()}\n`;
desc += `Original price: ${$el.find('.discount_original_price').text().trim()}\n`;
desc += `Discounted price: ${$el.find('.discount_final_price').text().trim()}\n`;
} else {
desc += `Price: ${$el.find('.discount_final_price').text().trim()}\n`;
}
if (hasReview) {
desc += $el.find('.search_review_summary').attr('data-tooltip-html');
}
return {
title: $el.find('span.title').text(),
link: $el.attr('href'),
description: desc.replaceAll('\n', '<br>'),
};
})
.filter((it) => it.title),
};
}
36 changes: 22 additions & 14 deletions lib/routes/wmpvp/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Route } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';

Expand Down Expand Up @@ -37,21 +38,28 @@ async function handler(ctx) {
});
const data = response.data.result.filter((item) => item.news !== undefined);

const items = data.map((item) => {
const entity = item.news;
const newsId = entity.newsId;
const newsLink = `https://news.wmpvp.com/news.html?id=${newsId}&gameTypeStr=${type}`;
const items = await Promise.all(
data.map((item) => {
const entity = item.news;
const newsId = entity.newsId;
const newsLink = `https://news.wmpvp.com/news.html?id=${newsId}&gameTypeStr=${type}`;

// 最终需要返回的对象
return {
title: entity.title,
pubDate: parseDate(entity.publishTime),
link: newsLink,
guid: newsLink,
description: entity.summary,
author: entity.author,
};
});
return cache.tryGet(newsLink, async () => {
const detailResponse = await got({
method: 'get',
url: `https://appactivity.wmpvp.com/steamcn/app/news/getAppNewsById?gameType=${type}&newsId=${newsId}`,
});
return {
title: entity.title,
pubDate: parseDate(entity.publishTime),
link: newsLink,
guid: newsLink,
author: entity.author,
description: detailResponse.data.result.news.content,
};
});
})
);

return {
title: `完美世界电竞 - ${TYPE_MAP[type]} 资讯`,
Expand Down
Loading

0 comments on commit 0b4207b

Please sign in to comment.