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 #2476 from DIYgod/master
[pull] master from diygod:master
- Loading branch information
Showing
13 changed files
with
1,337 additions
and
372 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
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
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,87 @@ | ||
import { Route } from '@/types'; | ||
|
||
import cache from '@/utils/cache'; | ||
import got from '@/utils/got'; | ||
import { load } from 'cheerio'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
|
||
export const route: Route = { | ||
path: '/blog', | ||
categories: ['blog'], | ||
example: '/0x80/blog', | ||
url: '0x80.pl/notesen.html', | ||
name: 'Articles', | ||
maintainers: ['xnum'], | ||
handler, | ||
}; | ||
|
||
function extractDateFromURL(url: string) { | ||
const regex = /\d{4}-\d{2}-\d{2}/; | ||
const match = url.match(regex); | ||
|
||
return match ? match[0] : null; | ||
} | ||
|
||
async function handler() { | ||
// The TLS cert is invalid, we are limited to use HTTP unfortunately. | ||
const baseUrl = 'http://0x80.pl/'; | ||
const targetUrl = `${baseUrl}notesen.html`; | ||
|
||
const response = await got({ | ||
method: 'get', | ||
url: targetUrl, | ||
}); | ||
|
||
const $ = load(response.data); | ||
|
||
const alist = $('a.reference.external'); | ||
|
||
const list = alist | ||
.toArray() | ||
.map((item) => { | ||
item = $(item); | ||
|
||
const link = item.attr('href') || ''; | ||
const title = item.text() || ''; | ||
const pubDate = extractDateFromURL(link); | ||
|
||
return { | ||
title, | ||
link, | ||
pubDate, | ||
category: 'Uncategoried', | ||
}; | ||
}) | ||
.filter((item) => item.link.startsWith('notesen')); | ||
|
||
const items = await Promise.all( | ||
list.map((item) => | ||
cache.tryGet(item.link, async () => { | ||
const articleUrl = `${baseUrl}${item.link}`; | ||
const response = await got({ | ||
method: 'get', | ||
url: articleUrl, | ||
}); | ||
|
||
const $ = load(response.data); | ||
|
||
const author = $('tr.author.field td.field-body').text(); | ||
const articlePubDate = $('tr.added-on.field td.field-body').text(); | ||
|
||
item.author = author; | ||
// Some articles might be missing the added-on field. | ||
// As a safeguard, if the date from url is null, fallbacks to the article one. | ||
item.pubDate = parseDate(item.pubDate || articlePubDate); | ||
item.description = $('div.document').first().html(); | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
|
||
return { | ||
title: '0x80.pl articles', | ||
link: targetUrl, | ||
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,7 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: 'Wojciech Muła', | ||
url: '0x80.pl', | ||
description: '', | ||
}; |
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 { Route } from '@/types'; | ||
import got from '@/utils/got'; | ||
import { load } from 'cheerio'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
|
||
export const route: Route = { | ||
path: '/podcast/:id', | ||
categories: ['multimedia'], | ||
example: '/apple/podcast/id1559695855', | ||
parameters: { id: '播客id,可以在 Apple 播客app 内分享的播客的 URL 中找到' }, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['podcasts.apple.com/cn/podcast/:id'], | ||
}, | ||
], | ||
name: '播客', | ||
maintainers: ['Acring'], | ||
handler, | ||
url: 'https://www.apple.com.cn/apple-podcasts/', | ||
}; | ||
|
||
async function handler(ctx) { | ||
const link = `https://podcasts.apple.com/cn/podcast/${ctx.req.param('id')}`; | ||
const response = await got({ | ||
method: 'get', | ||
url: link, | ||
}); | ||
|
||
const $ = load(response.data); | ||
|
||
const page_data = JSON.parse($('#shoebox-media-api-cache-amp-podcasts').text()); | ||
|
||
const data = JSON.parse(page_data[Object.keys(page_data)[0]]).d[0]; | ||
const attributes = data.attributes; | ||
|
||
const episodes = data.relationships.episodes.data.map((item) => { | ||
const attr = item.attributes; | ||
return { | ||
title: attr.name, | ||
enclosure_url: attr.assetUrl, | ||
itunes_duration: attr.durationInMilliseconds / 1000, | ||
enclosure_type: 'audio/mp4', | ||
link: attr.url, | ||
pubDate: parseDate(attr.releaseDateTime), | ||
description: attr.description.standard.replaceAll('\n', '<br>'), | ||
}; | ||
}); | ||
|
||
return { | ||
title: attributes.name, | ||
link: attributes.url, | ||
itunes_author: attributes.artistName, | ||
item: episodes, | ||
description: attributes.description.standard, | ||
}; | ||
} |
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
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
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
Oops, something went wrong.