-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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 #32 from DIYgod/master
[pull] master from diygod:master
- Loading branch information
Showing
28 changed files
with
284 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/recent-releases': ['user4302'], | ||
}; |
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,13 @@ | ||
module.exports = { | ||
'gogoanimehd.io': { | ||
_name: 'Gogoanime', | ||
developer: [ | ||
{ | ||
title: 'Recent Releases', | ||
docs: 'https://docs.rsshub.app/routes/anime#gogoanimehd', | ||
source: ['/'], | ||
target: '/gogoanimehd/recent-releases', | ||
}, | ||
], | ||
}, | ||
}; |
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,37 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
|
||
module.exports = async (ctx) => { | ||
const rootUrl = 'https://gogoanimehd.io'; | ||
|
||
const response = await got({ | ||
method: 'get', | ||
url: rootUrl, | ||
}); | ||
|
||
const $ = cheerio.load(response.data); | ||
const recentReleases = $('.last_episodes'); | ||
const listItems = $(recentReleases).find('li'); | ||
|
||
const arrayOfItems = listItems.toArray().map((item) => { | ||
const title = $(item).find('.name a').attr('title'); | ||
const episode = $(item).find('.episode').text(); | ||
const link = $(item).find('.name a').attr('href'); | ||
const img = $(item).find('.img a img').attr('src'); | ||
|
||
const formattedDescription = `<h2>${episode}</h2><br/><img src='${img}' alt='${title}'>`; | ||
|
||
const structuredData = { | ||
title, | ||
description: formattedDescription, | ||
link, | ||
}; | ||
return structuredData; | ||
}); | ||
|
||
ctx.state.data = { | ||
title: $('title').text(), | ||
link: rootUrl, | ||
item: arrayOfItems, | ||
}; | ||
}; |
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,3 @@ | ||
module.exports = function (router) { | ||
router.get('/recent-releases', require('./recent-releases')); | ||
}; |
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,68 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const timezone = require('@/utils/timezone'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
module.exports = async (ctx) => { | ||
const { category = 'tzgg_191' } = ctx.params; | ||
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 15; | ||
|
||
const rootUrl = 'https://gzw.cq.gov.cn'; | ||
const currentUrl = new URL(category, rootUrl).href; | ||
|
||
const { data: response } = await got(currentUrl); | ||
|
||
const $ = cheerio.load(response); | ||
|
||
let items = $('ul.tab-item li.clearfix') | ||
.slice(0, limit) | ||
.toArray() | ||
.map((item) => { | ||
item = $(item); | ||
|
||
const a = item.find('a'); | ||
|
||
return { | ||
title: a.text(), | ||
link: new URL(a.prop('href').replace(/^\./, category), rootUrl).href, | ||
pubDate: parseDate(item.find('span').text()), | ||
}; | ||
}); | ||
|
||
items = await Promise.all( | ||
items.map((item) => | ||
ctx.cache.tryGet(item.link, async () => { | ||
const { data: detailResponse } = await got(item.link); | ||
|
||
const content = cheerio.load(detailResponse); | ||
|
||
item.title = content('meta[name="ArticleTitle"]').prop('content'); | ||
item.description = content('div.trs_paper_default').html(); | ||
item.author = content('meta[name="ContentSource"]').prop('content'); | ||
item.category = content('meta[name="Keywords"]') | ||
.prop('content') | ||
.split(/;/) | ||
.filter((c) => c); | ||
item.pubDate = timezone(parseDate(content('meta[name="PubDate"]').prop('content')), +8); | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
|
||
const icon = new URL('favicon.ico', rootUrl).href; | ||
|
||
ctx.state.data = { | ||
item: items, | ||
title: `${$('title').text()} - ${$('meta[name="ColumnName"]').prop('content')}`, | ||
link: currentUrl, | ||
description: $('meta[name="ColumnDescription"]').prop('content'), | ||
language: $('html').prop('lang'), | ||
image: new URL($('div.logo img').prop('src'), rootUrl).href, | ||
icon, | ||
logo: icon, | ||
subtitle: $('meta[name="ColumnKeywords"]').prop('content'), | ||
author: $('meta[name="SiteName"]').prop('content'), | ||
allowEmpty: true, | ||
}; | ||
}; |
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
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,50 @@ | ||
// Require necessary modules | ||
const got = require('@/utils/got'); // a customised got | ||
const cheerio = require('cheerio'); // an HTML parser with a jQuery-like API | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
module.exports = async (ctx) => { | ||
const baseUrl = 'https://hackyournews.com'; | ||
const { data: response } = await got(baseUrl); | ||
const $ = cheerio.load(response); | ||
|
||
const item = $('tr.story') | ||
.map((_, story) => { | ||
const title = $(story).find('a').first().text(); | ||
const nextRow = $(story).next(); | ||
const metas = nextRow.text().trimStart().split('|'); | ||
const upvotes = parseInt(metas[0].split(' points')[0].trim()); | ||
const author = metas[0].split('by')[1].trim(); | ||
const pubDate = parseDate(metas[1].trim()); | ||
let category = []; | ||
// NOTE: If the summary is not already proceeded, we cannot get the category. | ||
if (metas.length === 5) { | ||
category = [metas[2].trim(), metas[3].trim()]; | ||
} | ||
const a = nextRow.find('a'); | ||
const link = a.attr('href'); | ||
const comments = parseInt(a.text()); | ||
const description = nextRow | ||
.find('p') | ||
.map((_, p) => $(p).text()) | ||
.get() | ||
.join('<br>'); | ||
return { | ||
title, | ||
link, | ||
author, | ||
category, | ||
comments, | ||
upvotes, | ||
pubDate, | ||
description, | ||
}; | ||
}) | ||
.get(); | ||
|
||
ctx.state.data = { | ||
title: 'Index', | ||
link: baseUrl, | ||
item, | ||
}; | ||
}; |
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,3 @@ | ||
module.exports = { | ||
'/': ['ftiasch'], | ||
}; |
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,13 @@ | ||
module.exports = { | ||
'hackyournews.com': { | ||
_name: 'HackYourNews', | ||
'.': [ | ||
{ | ||
title: 'Index', | ||
docs: 'https://docs.rsshub.app/routes/programming#hack-your-news', | ||
source: ['/'], | ||
target: '/hackyournews', | ||
}, | ||
], | ||
}, | ||
}; |
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,3 @@ | ||
module.exports = (router) => { | ||
router.get('/', require('./index')); | ||
}; |
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
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
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
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.