Skip to content

Commit

Permalink
fix(route): update root url for newzmz (DIYgod#12158)
Browse files Browse the repository at this point in the history
* fix(route): update rootUrl for newzmz

* refactor: migrate to v2

---------
  • Loading branch information
5upernova-heng authored Mar 22, 2023
1 parent 4150a7c commit 7111c2c
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 9 deletions.
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
13 changes: 7 additions & 6 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 = 'https://newzmz.com';
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'));
};
2 changes: 1 addition & 1 deletion lib/routes/newzmz/view.js → lib/v2/newzmz/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const cheerio = require('cheerio');
module.exports = async (ctx) => {
const id = ctx.params.id;

const rootUrl = `https://ysfx.tv`;
const rootUrl = `https://s.newzmz.com`;
const currentUrl = `${rootUrl}/view/${id}.html`;

const response = await got({
Expand Down

0 comments on commit 7111c2c

Please sign in to comment.