Merge pull request #3134 from iptv-org/add-www.tv-tokyo.co.jp

Add www.tv-tokyo.co.jp
This commit is contained in:
PopeyeTheSai10r
2026-05-09 09:23:01 -07:00
committed by GitHub
5 changed files with 153 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,21 @@
# www.tv-tokyo.co.jp
https://www.tv-tokyo.co.jp/timetable/
### Download the guide
```sh
npm run grab --- --sites=www.tv-tokyo.co.jp
```
### Update channel list
```sh
npm run channels:parse --- --config=./sites/www.tv-tokyo.co.jp/www.tv-tokyo.co.jp.config.js --output=./sites/www.tv-tokyo.co.jp/www.tv-tokyo.co.jp.channels.xml
```
### Test
```sh
npm test --- www.tv-tokyo.co.jp
```

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<channels>
<channel site="www.tv-tokyo.co.jp" site_id="bs-tv-tokyo-4k" lang="ja" xmltv_id="BSTVTokyo4K.jp@SD">BSテレ東 4K</channel>
<channel site="www.tv-tokyo.co.jp" site_id="bs-tv-tokyo" lang="ja" xmltv_id="BSTVTokyo.jp@SD">BSテレ東</channel>
</channels>

View File

@@ -0,0 +1,67 @@
const dayjs = require('dayjs')
module.exports = {
site: 'www.tv-tokyo.co.jp',
days: 2,
delay: 5000,
request: {
cache: {
ttl: 60 * 60 * 1000 // 1 hour
},
headers: {
'User-Agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36'
}
},
url({ date }) {
return `https://www.tv-tokyo.co.jp/tbcms/assets/data/${date.format('YYYYMMDD')}.json`
},
parser({ content, channel }) {
let programs = []
const items = parseItems(content, channel)
items.forEach(item => {
programs.push({
title: item.title,
description: item.description,
image: parseImage(item),
start: dayjs(item.sts),
stop: dayjs(item.ets)
})
})
return programs
},
channels() {
return [
{
name: 'BSテレ東',
site_id: 'bs-tv-tokyo',
lang: 'ja',
xmltv_id: 'BSTVTokyo.jp@SD'
},
{
name: 'BSテレ東 4K',
site_id: 'bs-tv-tokyo-4k',
lang: 'ja',
xmltv_id: 'BSTVTokyo4K.jp@SD'
}
]
}
}
function parseImage(item) {
return item.image?.file_path ? `https://www.tv-tokyo.co.jp${item.image.file_path}` : null
}
function parseItems(content, channel) {
try {
const data = JSON.parse(content)
if (!data) return []
const events = Object.values(data).flatMap(group => Object.values(group))
if (!Array.isArray(events)) return []
return events.filter(i => i.channel === channel.site_id)
} catch {
return []
}
}

View File

@@ -0,0 +1,59 @@
const { parser, url, request } = require('./www.tv-tokyo.co.jp.config.js')
const fs = require('fs')
const path = require('path')
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(customParseFormat)
dayjs.extend(utc)
const date = dayjs.utc('2026-05-06', 'YYYY-MM-DD').startOf('d')
const channel = { site_id: 'bs-tv-tokyo-4k' }
it('can generate valid url', () => {
expect(url({ channel, date })).toBe('https://www.tv-tokyo.co.jp/tbcms/assets/data/20260506.json')
})
it('can generate valid request headers', () => {
expect(request.headers).toMatchObject({
'User-Agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36'
})
})
it('can parse response', () => {
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
const results = parser({ content, channel }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(results.length).toBe(33)
expect(results[0]).toMatchObject({
title: '快適!ショッピングスタジオDX',
description:
'ジャパネットたかたテレビショッピング。今だけの期間限定商品をお得に手にする大チャンス!さらに生放送だからできる旬な商品をご紹介します!',
image:
'https://www.tv-tokyo.co.jp/tbcms/assets/images/alt_bs-tv-tokyo-4k.png?width=320&height=180&color=ffffff',
start: '2026-05-06T03:00:00.000Z',
stop: '2026-05-06T04:56:00.000Z'
})
expect(results[32]).toMatchObject({
title: '乗れない鉄道に乗ってみた! 一挙放送',
description:
'乗れない鉄道に「乗った気分」になって、普段見ることのない景色にゆったり浸れる情景ドキュメンタリー番組。',
image:
'https://www.tv-tokyo.co.jp/tbcms/assets/images/alt_bs-tv-tokyo-4k.png?width=320&height=180&color=ffffff',
start: '2026-05-05T23:58:00.000Z',
stop: '2026-05-06T03:00:00.000Z'
})
})
it('can handle empty guide', () => {
const results = parser({ content: '', channel })
expect(results).toMatchObject([])
})