Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(route): update root url for newzmz #12158

Merged
merged 2 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor: migrate to v2
  • Loading branch information
TonyRL committed Mar 22, 2023
commit e9bcef9093d2539153d017ad3dec7e81bb1444e7
4 changes: 2 additions & 2 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -3696,8 +3696,8 @@ router.get('/gab/user/:username', lazyloadRouteHandler('./routes/gab/user'));
router.get('/gab/popular/:sort?', lazyloadRouteHandler('./routes/gab/explore'));

// NEW 字幕组
router.get('/newzmz/view/:id', lazyloadRouteHandler('./routes/newzmz/view'));
router.get('/newzmz/:category?', lazyloadRouteHandler('./routes/newzmz/index'));
// router.get('/newzmz/view/:id', lazyloadRouteHandler('./routes/newzmz/view'));
// router.get('/newzmz/:category?', lazyloadRouteHandler('./routes/newzmz/index'));

// Phrack Magazine
router.get('/phrack', lazyloadRouteHandler('./routes/phrack/index'));
Expand Down
11 changes: 6 additions & 5 deletions lib/routes/newzmz/index.js → lib/v2/newzmz/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const category = parseInt(ctx.params.category || '1');

const rootUrl = 'http://newzmz.com';
const response = await got({
method: 'get',
url: rootUrl,
url: `${rootUrl}/index.html`,
});

const $ = cheerio.load(response.data);
Expand All @@ -16,7 +17,6 @@ module.exports = async (ctx) => {
const links = await Promise.all(
target
.find('.slides li a')
.slice(0, 15)
.map((_, item) => {
item = $(item);

Expand All @@ -34,12 +34,13 @@ module.exports = async (ctx) => {
});
const $ = cheerio.load(resourceResponse.data);

item.link = $('.addgz').attr('href');
item.pubDate = new Date(
item.link = $('.addgz').attr('href').replace('http:', 'https:');
item.pubDate = parseDate(
$('.duration')
.not('.upday')
.text()
.replace(/更新时间:/, '')
).toUTCString();
);

return item;
})
Expand Down
4 changes: 4 additions & 0 deletions lib/v2/newzmz/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
'/:category?': ['nczitzk'],
'/view/:id?': ['nczitzk'],
};
19 changes: 19 additions & 0 deletions lib/v2/newzmz/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
'newzmz.com': {
_name: 'NEW 字幕组',
'.': [
{
title: '分类',
docs: 'https://docs.rsshub.app/multimedia.html#new-zi-mu-zu',
source: ['/'],
target: '/newzmz',
},
{
title: '指定剧集',
docs: 'https://docs.rsshub.app/multimedia.html#new-zi-mu-zu',
source: ['/view/:id'],
target: (params) => `/newzmz/view/${params.id.replace('.html', '')}`,
},
],
},
};
4 changes: 4 additions & 0 deletions lib/v2/newzmz/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = (router) => {
router.get('/:category?', require('./index'));
router.get('/view/:id', require('./view'));
};
File renamed without changes.