mirror of
https://github.com/iptv-org/epg
synced 2026-09-06 03:49:49 -04:00
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<channels>
|
||||
<channel site="ntv.co.jp" site_id="#" lang="ja" xmltv_id="JOAXDTV.jp">Nippon TV</channel>
|
||||
</channels>
|
||||
@@ -0,0 +1,67 @@
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(timezone)
|
||||
dayjs.extend(customParseFormat)
|
||||
|
||||
module.exports = {
|
||||
site: 'ntv.co.jp',
|
||||
days: 7,
|
||||
url: 'https://www.ntv.co.jp/program/json/program_list.json',
|
||||
request: {
|
||||
cache: {
|
||||
ttl: 60 * 60 * 1000
|
||||
}
|
||||
},
|
||||
parser({ buffer, date }) {
|
||||
const items = parseItems(buffer, date)
|
||||
|
||||
return items.map(item => {
|
||||
return {
|
||||
title: item.program_title,
|
||||
description: item.program_detail,
|
||||
actors: Array.isArray(item.performers) ? item.performers.map(p => p.performer) : [],
|
||||
start: dayjs.tz(
|
||||
item.actual_datetime.broadcast_date + item.actual_datetime.start_time,
|
||||
'YYYYMMDDHHmm',
|
||||
'Asia/Tokyo'
|
||||
),
|
||||
stop: dayjs.tz(
|
||||
item.actual_datetime.broadcast_date + item.actual_datetime.end_time,
|
||||
'YYYYMMDDHHmm',
|
||||
'Asia/Tokyo'
|
||||
)
|
||||
}
|
||||
})
|
||||
},
|
||||
channels() {
|
||||
return [
|
||||
{
|
||||
name: 'Nippon TV',
|
||||
xmltv_id: 'JOAXDTV.jp',
|
||||
site_id: '#',
|
||||
lang: 'ja'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
function parseItems(buffer, date) {
|
||||
try {
|
||||
const cleanJsonText = String(buffer)
|
||||
.replace(/^\uFEFF/, '')
|
||||
.trim()
|
||||
const data = JSON.parse(cleanJsonText)
|
||||
if (!data) return []
|
||||
|
||||
const requestedDate = date.format('YYYYMMDD')
|
||||
const items = data.filter(item => item.actual_datetime.broadcast_date === requestedDate)
|
||||
|
||||
return items
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
const { parser, url } = require('./ntv.co.jp.config.js')
|
||||
const dayjs = require('dayjs')
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
const date = dayjs.utc('2026-08-03', 'YYYY-MM-DD').startOf('d')
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe('https://www.ntv.co.jp/program/json/program_list.json')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const buffer = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
|
||||
const results = parser({ buffer, date }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results.length).toBe(22)
|
||||
expect(results[0]).toMatchObject({
|
||||
title: 'NNNドキュメント’26「原爆ドーム~目から消えるものは、心からも消える~」[解][字]',
|
||||
description:
|
||||
'世界遺産の登録から30年を迎える「原爆ドーム」。「崩れるままに崩れてしまえばいい」。被爆者にとって、あの日の記憶を呼び起こす原爆の象徴は戦後20年あまり放置された。「目から消えるものは、心からも消える」。保存を求めて声を上げたのは、子どもたち。その歩みと重なる東北の震災遺構があった。広島のシンボルは、なぜそこに立ち続けるのか。被爆から81年。原爆ドームに思いを託す、人々を見つめる。',
|
||||
actors: ['吉川晃司'],
|
||||
start: '2026-08-02T15:55:00.000Z',
|
||||
stop: '2026-08-02T16:50:00.000Z'
|
||||
})
|
||||
expect(results[1]).toMatchObject({
|
||||
title: 'ライターズ!',
|
||||
description: 'ゲストは『踊る!さんま御殿!!』から平野ノラ!番組の魅力を「特殊」と語る背景とは',
|
||||
actors: ['ゲスト:平野ノラ\r\nライター:アーバン・タカト'],
|
||||
start: '2026-08-02T16:50:00.000Z',
|
||||
stop: '2026-08-02T17:10:00.000Z'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const results = parser({ content: '', date })
|
||||
|
||||
expect(results).toMatchObject([])
|
||||
})
|
||||
@@ -0,0 +1,21 @@
|
||||
# ntv.co.jp
|
||||
|
||||
https://www.ntv.co.jp/program/
|
||||
|
||||
### Download the guide
|
||||
|
||||
```sh
|
||||
npm run grab --- --sites=ntv.co.jp
|
||||
```
|
||||
|
||||
### Update channel list
|
||||
|
||||
```sh
|
||||
npm run channels:parse --- --config=./sites/ntv.co.jp/ntv.co.jp.config.js --output=./sites/ntv.co.jp/ntv.co.jp.channels.xml
|
||||
```
|
||||
|
||||
### Test
|
||||
|
||||
```sh
|
||||
npm test --- ntv.co.jp
|
||||
```
|
||||
Reference in New Issue
Block a user