parent
4b4bd10cd4
commit
ea809084f4
|
|
@ -197,3 +197,7 @@
|
|||
| 全部 | 蓝光 | 1080P | 720P | 3D | WEB-DL |
|
||||
| ---- | ------ | ----- | ---- | --- | ------ |
|
||||
| 留空 | bluray | 1080p | 720p | 3d | webdl |
|
||||
|
||||
## SoundCloud
|
||||
|
||||
<Route name="Tracks" author="fallenhh" example="/soundcloud/tracks/angeart" path="/soundcloud/tracks/:user" :paramsDesc="['用户名']" />
|
||||
|
|
|
|||
|
|
@ -1328,6 +1328,9 @@ router.get('/asahichinese-f/:category', require('./routes/asahichinese-f/index')
|
|||
// 7x24小时快讯
|
||||
router.get('/fx678/kx', require('./routes/fx678/kx'));
|
||||
|
||||
// SoundCloud
|
||||
router.get('/soundcloud/tracks/:user', require('./routes/soundcloud/tracks'));
|
||||
|
||||
// dilidili
|
||||
router.get('/dilidili/fanju/:id', require('./routes/dilidili/fanju'));
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
const util = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const user = ctx.params.user;
|
||||
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: `https://soundcloud.com/${user}/tracks`,
|
||||
headers: {
|
||||
Referer: `https://soundcloud.com/${user}/tracks`,
|
||||
},
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
|
||||
const $ = cheerio.load(data, { xmlMode: true });
|
||||
const list = $('body article.audible').get();
|
||||
const result = await util.ProcessFeed(list, ctx.cache);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: `https://soundcloud.com/${user}/tracks`,
|
||||
description: $('meta[name="description"]').attr('content') || $('title').text(),
|
||||
item: result,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
const url = require('url');
|
||||
|
||||
async function load(link) {
|
||||
const response = await axios.get(link);
|
||||
const $ = cheerio.load(response.data, { xmlMode: true });
|
||||
let result = '';
|
||||
const tmp = $('noscript article p');
|
||||
result += `<p>${tmp.html()}</p>`;
|
||||
const embed_url = $('noscript article div')
|
||||
.first()
|
||||
.children()
|
||||
.first()
|
||||
.attr('content');
|
||||
result += `<iframe width=85% src=${embed_url}/>`;
|
||||
return { description: result };
|
||||
}
|
||||
|
||||
const ProcessFeed = async (list, caches) => {
|
||||
const host = 'https://www.soundcloud.com';
|
||||
|
||||
return await Promise.all(
|
||||
list.map(async (item) => {
|
||||
const $ = cheerio.load(item);
|
||||
|
||||
const $title = $('h2')
|
||||
.children()
|
||||
.first();
|
||||
|
||||
const itemUrl = url.resolve(host, $title.attr('href'));
|
||||
|
||||
const author = $('h2')
|
||||
.children()
|
||||
.last()
|
||||
.text();
|
||||
|
||||
const date = new Date($('time').text());
|
||||
const timeZone = 8;
|
||||
const serverOffset = date.getTimezoneOffset() / 60;
|
||||
const pubDate = new Date(date.getTime() - 60 * 60 * 1000 * (timeZone + serverOffset)).toUTCString();
|
||||
const single = {
|
||||
title: $title.text(),
|
||||
link: itemUrl,
|
||||
guid: itemUrl,
|
||||
author,
|
||||
pubDate,
|
||||
};
|
||||
const other = await caches.tryGet(itemUrl, async () => await load(itemUrl));
|
||||
return Promise.resolve(Object.assign({}, single, other));
|
||||
})
|
||||
);
|
||||
};
|
||||
module.exports = {
|
||||
ProcessFeed,
|
||||
};
|
||||
Loading…
Reference in New Issue