forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #648 from DIYgod/master
[pull] master from diygod:master
- Loading branch information
Showing
5 changed files
with
195 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,7 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: '盯梢', | ||
url: 'www.dingshao.cn', | ||
lang: 'zh-CN', | ||
}; |
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,53 @@ | ||
import { Route } from '@/types'; | ||
import ofetch from '@/utils/ofetch'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
import type { Context } from 'hono'; | ||
import { Value } from './types'; | ||
|
||
export const route: Route = { | ||
path: '/share/:shortId', | ||
categories: ['other'], | ||
example: '/dingshao/share/FzFypN', | ||
parameters: { | ||
shortId: '频道 ID', | ||
}, | ||
radar: [ | ||
{ | ||
source: ['www.dingshao.cn/share/:shortId'], | ||
}, | ||
], | ||
name: '频道', | ||
maintainers: ['TonyRL'], | ||
handler, | ||
}; | ||
|
||
const baseUrl = 'https://www.dingshao.cn'; | ||
|
||
async function handler(ctx: Context) { | ||
const { shortId } = ctx.req.param(); | ||
|
||
const response = await ofetch<Value>(`${baseUrl}/api/v2/channel/get-channel-and-recent-messages-by-short-id`, { | ||
method: 'POST', | ||
body: { | ||
shortId, | ||
}, | ||
}); | ||
|
||
const items = response.value.bundle.channelMessages.map((message) => ({ | ||
title: message.excerpt.split('\n')[0], | ||
description: message.content, | ||
pubDate: parseDate(message.publishedAt), | ||
category: message.tags, | ||
link: `${baseUrl}/channel/${response.value.channel}/${message.id}`, | ||
})); | ||
|
||
const channelProfile = response.value.bundle.channels.find((channel) => channel.id === response.value.channel)?.profile; | ||
|
||
return { | ||
title: channelProfile?.name, | ||
description: channelProfile?.description, | ||
link: `${baseUrl}/share/${shortId}`, | ||
image: channelProfile?.image, | ||
item: items, | ||
}; | ||
} |
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 @@ | ||
export interface Value { | ||
value: { | ||
channel: string; | ||
recentMessages: string[]; | ||
bundle: Bundle; | ||
}; | ||
} | ||
|
||
interface Bundle { | ||
channels: Channel[]; | ||
users: User[]; | ||
channelMessages: ChannelMessage[]; | ||
channelMessageInteractions: any[]; | ||
} | ||
|
||
interface Channel { | ||
id: string; | ||
owner: string; | ||
profile: Profile; | ||
tags: string[]; | ||
script: Script; | ||
private: boolean; | ||
stats: Stats; | ||
sharable: boolean; | ||
lastPublishedAt: string; | ||
} | ||
|
||
interface Profile { | ||
name: string; | ||
description: string; | ||
image: string; | ||
} | ||
|
||
interface Script { | ||
homepage: string; | ||
} | ||
|
||
interface Stats { | ||
subscribers: number; | ||
} | ||
|
||
interface User { | ||
id: string; | ||
profile: UserProfile; | ||
} | ||
|
||
interface UserProfile { | ||
name: string; | ||
image: string; | ||
} | ||
|
||
interface ChannelMessage { | ||
id: string; | ||
channel: string; | ||
author: string; | ||
tags: string[]; | ||
excerpt: string; | ||
content: string; | ||
likes: number; | ||
private: boolean; | ||
sharable: boolean; | ||
script: boolean; | ||
publishedAt: string; | ||
} |
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 type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: '台灣大哥大', | ||
url: 'www.taiwanmobile.com', | ||
lang: 'zh-TW', | ||
}; |
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 { DataItem, Route } from '@/types'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
import ofetch from '@/utils/ofetch'; | ||
import { load } from 'cheerio'; | ||
import cache from '@/utils/cache'; | ||
|
||
export const route: Route = { | ||
path: '/rate-plans', | ||
categories: ['other'], | ||
example: '/taiwanmobile/rate-plans', | ||
radar: [ | ||
{ | ||
source: ['taiwanmobile.com/cs/public/servAnn/queryList.htm'], | ||
}, | ||
], | ||
name: '資費公告', | ||
maintainers: ['Tsuyumi25'], | ||
handler, | ||
url: 'www.taiwanmobile.com/cs/public/servAnn/queryList.htm?type=1', | ||
}; | ||
|
||
async function handler() { | ||
const baseUrl = 'https://www.taiwanmobile.com'; | ||
const listUrl = `${baseUrl}/cs/public/servAnn/queryList.htm?type=1`; | ||
const response = await ofetch(listUrl); | ||
|
||
const $ = load(response); | ||
|
||
const list = $('.pagination_data') | ||
.toArray() | ||
.map((item) => { | ||
const element = $(item); | ||
const title = element.find('a').text().trim(); | ||
const link = new URL(element.find('a').attr('href') ?? '', baseUrl).href; | ||
const pubDate = parseDate(element.find('td').first().text(), 'YYYY/MM/DD'); | ||
|
||
return { | ||
title, | ||
link, | ||
pubDate, | ||
}; | ||
}) | ||
.slice(0, 20); | ||
|
||
const items = await Promise.all( | ||
list.map((item) => | ||
cache.tryGet(item.link, async () => { | ||
const detailResponse = await ofetch(item.link); | ||
const content = load(detailResponse); | ||
|
||
return { | ||
...item, | ||
description: content('.v2-page-change__current').find('.v2-uikit__typography-text.-h3, .v2-m-faq-card__description.gray.pad_btm1').remove().end().html() || '暫無內容', | ||
}; | ||
}) | ||
) | ||
); | ||
|
||
return { | ||
title: '台灣大哥大 - 資費公告', | ||
link: listUrl, | ||
item: items as DataItem[], | ||
}; | ||
} |