forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add router yahoo-jp-tv (Yahoo!テレビ) (DIYgod#3928)
- Loading branch information
1 parent
7eee7cd
commit f2bb385
Showing
3 changed files
with
36 additions
and
0 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
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,27 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const querystring = require('querystring'); | ||
|
||
module.exports = async (ctx) => { | ||
const query = querystring.stringify({ q: ctx.params.query }); | ||
const link = `https://tv.yahoo.co.jp/search/?${query}`; | ||
const response = await got(link); | ||
const $ = cheerio.load(response.body); | ||
const [title] = $('.search_result') | ||
.find('p') | ||
.text() | ||
.split(':'); | ||
const item = $('.programlist li') | ||
.map((index, item) => { | ||
const $item = $(item); | ||
const title = `${$item | ||
.find('.leftarea') | ||
.text() | ||
.replace(/\n/g, '')} ${$item.find('.yjLS').text()}`; | ||
const link = `https://tv.yahoo.co.jp${$item.find('div.rightarea p.yjLS.pb5p a').attr('href')}`; | ||
const description = $item.find('p.yjMS:nth-child(3)').text(); | ||
return { title, description, link }; | ||
}) | ||
.get(); | ||
ctx.state.data = { title, link, item }; | ||
}; |