|
1 | 1 | const got = require('@/utils/got'); |
2 | 2 | const cheerio = require('cheerio'); |
3 | 3 | const url = 'https://www.ibc.co.jp/radio/maitta/audio/'; |
| 4 | +const { parseDate } = require('@/utils/parse-date'); |
4 | 5 |
|
5 | 6 | module.exports = async (ctx) => { |
6 | | - const res = await got.get(url); |
| 7 | + const res = await got(url); |
7 | 8 | const $ = cheerio.load(res.data); |
8 | | - const items = $('.broadcast').get(); |
| 9 | + const items = $('.up').toArray(); |
9 | 10 | ctx.state.data = { |
10 | 11 | title: 'IBCラジオ イヤーマイッタマイッタ|IBC岩手放送', |
11 | 12 | link: 'http://www.ibc.co.jp/radio/maitta/audio', |
12 | 13 | description: $('meta[name=description]').attr('content'), |
13 | 14 | itunes_author: '水越アナと大塚アナ', |
14 | | - image: 'https://cdn.ibc.co.jp/radio/maitta/audio/images/og.png', |
| 15 | + image: 'https://cdn.ibc.co.jp/radio/maitta/audio/images/header.png', |
15 | 16 | language: 'ja', |
16 | 17 | item: items.map((item) => { |
17 | 18 | item = $(item); |
| 19 | + const link = new URL(item.find('a').attr('href'), url).href; |
| 20 | + const uid = link.match(/\/(\d+)\/$/)[1]; |
18 | 21 | return { |
19 | 22 | title: item.find('h3').text(), |
20 | | - description: item.find('.linecontent').text().trim(), |
21 | | - link: `https:${item.find('a').first().attr('href').split('?')[0]}`, |
22 | | - pubDate: new Date(item.find('.onairdate').text().split('日')[0].replace(/年|月/g, '-')).toUTCString(), |
23 | | - itunes_item_image: 'https://cdn.ibc.co.jp/radio/maitta/audio/images/og.png', |
24 | | - enclosure_url: `https:${item.find('a').first().attr('href').split('?')[0]}`, // 音频链接 |
| 23 | + description: item.find('.audio_intro').text().trim(), |
| 24 | + link, |
| 25 | + pubDate: parseDate(item.find('.onair_date').text().split('日')[0].replace(/年|月/g, '-')), |
| 26 | + itunes_item_image: 'https://assets.blubrry.com/coverart/300/357155.png', |
| 27 | + enclosure_url: `https://media-data.cdn.ibc.co.jp/out/sound/28_${uid}/28_${uid}.mp3`, // 音频链接 |
25 | 28 | enclosure_type: 'audio/mpeg', |
26 | 29 | }; |
27 | 30 | }), |
|
0 commit comments