Skip to content

Commit

Permalink
feat(route): add 6vdy (DIYgod#11907)
Browse files Browse the repository at this point in the history
* feat(route): add 6vdy

* fix(route): use tryGet for cache

* fix(route): fix cache bug

* fix(route): fix utils

* fix(route): fix utils

* fix: update route path

---------
  • Loading branch information
tc9011 authored Feb 23, 2023
1 parent 8f48c7e commit 434af10
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/multimedia.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ pageClass: routes

输出 Transcript 从而提供比官方(podcast)更好的使用体验。

## 6v 电影

### 最新电影

<Route author="tc9011" example="/6v123/latestMovies" path="/6v123/latestMovies" supportBT="1"/>

### 最新电视剧

<Route author="tc9011" example="/6v123/latestTVSeries" path="/6v123/latestTVSeries" supportBT="1"/>

## 7mmtv

### 分类
Expand Down
14 changes: 14 additions & 0 deletions lib/v2/6v123/latestMovies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { processItems } = require('./utils');

const baseURL = 'https://www.hao6v.cc/gvod/zx.html';

module.exports = async (ctx) => {
const item = await processItems(ctx, baseURL);

ctx.state.data = {
title: '6v电影-最新电影',
link: baseURL,
description: '6v最新电影RSS',
item,
};
};
14 changes: 14 additions & 0 deletions lib/v2/6v123/latestTVSeries.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { processItems } = require('./utils');

const baseURL = 'https://www.hao6v.tv/gvod/dsj.html';

module.exports = async (ctx) => {
const item = await processItems(ctx, baseURL);

ctx.state.data = {
title: '6v电影-最新电影',
link: baseURL,
description: '6v最新电影RSS',
item,
};
};
4 changes: 4 additions & 0 deletions lib/v2/6v123/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
'/latestMovies': ['tc9011'],
'/latestTVSeries': ['tc9011'],
};
23 changes: 23 additions & 0 deletions lib/v2/6v123/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const radarConfig = {
_name: '6v电影',
'.': [
{
title: '最新电影',
docs: 'https://docs.rsshub.app/multimedia.html#_6v-dian-ying',
source: ['/', '/gvod/zx.html'],
target: '/6v123/latestMovies',
},
{
title: '最新电视剧',
docs: 'https://docs.rsshub.app/multimedia.html#_6v-dian-ying',
source: ['/', '/gvod/dsj.html'],
target: '/6v123/latestTVSeries',
},
],
};

module.exports = {
'hao6v.cc': radarConfig,
'hao6v.tv': radarConfig,
'hao6v.com': radarConfig,
};
4 changes: 4 additions & 0 deletions lib/v2/6v123/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = (router) => {
router.get('/latestMovies', require('./latestMovies'));
router.get('/latestTVSeries', require('./latestTVSeries'));
};
81 changes: 81 additions & 0 deletions lib/v2/6v123/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
const got = require('@/utils/got');
const iconv = require('iconv-lite');
const cheerio = require('cheerio');

const utils = {
loadDetailPage: async function loadDetailPage(link) {
const response = await got.get(link, {
responseType: 'buffer',
});
response.data = iconv.decode(response.data, 'gb2312');

const $ = cheerio.load(response.data);

const detailInfo = {
title: $('title')
.text()
.replace(/,免费下载,迅雷下载|,6v电影/g, ''),
description: $('meta[name="description"]').attr('content'),
enclosure_urls: $('table td')
.map((i, e) => ({
title: $(e).text().replace('磁力:', ''),
magnet: $(e).find('a').attr('href'),
}))
.toArray()
.filter((item) => item.magnet?.includes('magnet')),
};
return detailInfo;
},
processItems: async (ctx, baseURL) => {
const response = await got.get(baseURL, {
responseType: 'buffer',
});
response.data = iconv.decode(response.data, 'gb2312');

const $ = cheerio.load(response.data);
const list = $('ul.list')[0].children;

const process = await Promise.all(
list.map((item) => {
const link = $(item).find('a');
const href = link.attr('href');
const pubDate = new Date($(item).find('span').text().replace(/[[\]]/g, '')).toUTCString();

if (href === undefined) {
return undefined;
}

const itemUrl = 'https://www.hao6v.cc' + link.attr('href');

return ctx.cache.tryGet(itemUrl, async () => {
const detailInfo = await utils.loadDetailPage(itemUrl);

if (detailInfo.enclosure_urls.length > 1) {
return detailInfo.enclosure_urls.map((url) => ({
enclosure_url: url.magnet,
enclosure_type: 'application/x-bittorrent',
title: `${link.text()} ( ${url.title} )`,
description: detailInfo.description,
pubDate,
link: itemUrl,
guid: `${itemUrl}#${url.title}`,
}));
}

return {
enclosure_url: detailInfo.enclosure_urls[0].magnet,
enclosure_type: 'application/x-bittorrent',
title: link.text(),
description: detailInfo.description,
pubDate,
link: itemUrl,
};
});
})
);

return process.filter((item) => item !== undefined).flat();
},
};

module.exports = utils;

0 comments on commit 434af10

Please sign in to comment.