Skip to content

Commit 7610f7b

Browse files
authored
Merge pull request #2409 from Animenosekai/master
Adding the `s.mxtv.jp` and `www.skyperfectv.co.jp` sites and mapping IDs for `tvguide.myjcom.jp`
2 parents a3e7661 + aa77d8a commit 7610f7b

10 files changed

+513
-15
lines changed

sites/s.mxtv.jp/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# s.mxtv.jp
2+
3+
<https://s.mxtv.jp>
4+
5+
## Index
6+
7+
- [Index](#index)
8+
- [Download the guide](#download-the-guide)
9+
- [Update channel list](#update-channel-list)
10+
- [Test](#test)
11+
12+
## Download the guide
13+
14+
```sh
15+
npm run grab -- --site=s.mxtv.jp
16+
```
17+
18+
## Update channel list
19+
20+
```sh
21+
npm run channels:parse -- --config=./sites/s.mxtv.jp/s.mxtv.jp.config.js --output=./sites/s.mxtv.jp/s.mxtv.jp.channels.xml
22+
```
23+
24+
## Test
25+
26+
```sh
27+
npm test -- s.mxtv.jp
28+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<channels>
3+
<channel site="s.mxtv.jp" lang="ja" xmltv_id="TokyoMX1.jp" site_id="1">Tokyo MX1</channel>
4+
<channel site="s.mxtv.jp" lang="ja" xmltv_id="TokyoMX2.jp" site_id="2">Tokyo MX2</channel>
5+
</channels>

sites/s.mxtv.jp/s.mxtv.jp.config.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
const dayjs = require('dayjs')
2+
const duration = require("dayjs/plugin/duration")
3+
const utc = require('dayjs/plugin/utc')
4+
const timezone = require('dayjs/plugin/timezone')
5+
const customParseFormat = require('dayjs/plugin/customParseFormat')
6+
7+
dayjs.extend(utc)
8+
dayjs.extend(timezone)
9+
dayjs.extend(customParseFormat)
10+
dayjs.extend(duration)
11+
12+
module.exports = {
13+
site: 's.mxtv.jp',
14+
days: 1,
15+
lang: 'ja',
16+
url: function ({ date, channel }) {
17+
const id = `SV${channel.site_id}EPG${date.format('YYYYMMDD')}`
18+
return `https://s.mxtv.jp/bangumi_file/json01/${id}.json`
19+
},
20+
parser: function ({ content }) {
21+
let programs = []
22+
const items = parseItems(content)
23+
items.forEach(item => {
24+
programs.push({
25+
title: item.Event_name,
26+
description: item.Event_text,
27+
category: parseCategory(item),
28+
image: parseImage(item),
29+
start: parseStart(item),
30+
stop: parseStop(item)
31+
})
32+
})
33+
return programs
34+
},
35+
channels() {
36+
return [
37+
{
38+
lang: 'ja',
39+
site_id: '1',
40+
name: 'Tokyo MX1',
41+
xmltv_id: 'TokyoMX1.jp'
42+
},
43+
{
44+
lang: 'ja',
45+
site_id: '2',
46+
name: 'Tokyo MX2',
47+
xmltv_id: 'TokyoMX2.jp'
48+
}
49+
]
50+
}
51+
}
52+
53+
function parseImage(item) {
54+
// Should return a string if we can output an image URL
55+
// Might be done with `https://s.mxtv.jp/bangumi/link/weblinkU.csv?1722421896752` ?
56+
return null
57+
}
58+
59+
function parseCategory(item) {
60+
// Should return a string if we can determine the category
61+
// Might be done with `https://s.mxtv.jp/index_set/csv/ranking_bangumi_allU.csv` ?
62+
return null
63+
}
64+
65+
function parseStart(item) {
66+
return dayjs.tz(item.Start_time.toString(), 'YYYY年MM月DD日HH時mm分ss秒', 'Asia/Tokyo')
67+
}
68+
69+
function parseStop(item) {
70+
// Add the duration to the start time
71+
const durationDate = dayjs(item.Duration, 'HH:mm:ss');
72+
return parseStart(item).add(dayjs.duration({
73+
hours: durationDate.hour(),
74+
minutes: durationDate.minute(),
75+
seconds: durationDate.second()
76+
}))
77+
}
78+
79+
function parseItems(content) {
80+
return JSON.parse(content) || []
81+
}

sites/s.mxtv.jp/s.mxtv.jp.test.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
const { parser, url } = require('./s.mxtv.jp.config.js')
2+
const dayjs = require('dayjs')
3+
const utc = require('dayjs/plugin/utc')
4+
const customParseFormat = require('dayjs/plugin/customParseFormat')
5+
dayjs.extend(customParseFormat)
6+
dayjs.extend(utc)
7+
8+
const date = dayjs.utc('2024-08-01', 'YYYY-MM-DD').startOf('d')
9+
const channel = {
10+
site_id: '2',
11+
name: 'Tokyo MX2',
12+
xmltv_id: 'TokyoMX2.jp'
13+
}
14+
const content = `[{ "Event_id": "0x6a57", "Start_time": "2024年07月27日05時00分00秒", "Duration": "01:00:00", "Event_name": "ヒーリングタイム&ヘッドラインニュース", "Event_text": "ねこの足跡", "Component": "480i 16:9 パンベクトルなし", "Sound": "ステレオ", "Event_detail": ""}]`
15+
16+
it('can generate valid url', () => {
17+
const result = url({ date, channel })
18+
expect(result).toBe('https://s.mxtv.jp/bangumi_file/json01/SV2EPG20240801.json')
19+
})
20+
21+
it('can parse response', () => {
22+
const result = parser({ date, channel, content }).map(p => {
23+
p.start = p.start.toJSON()
24+
p.stop = p.stop.toJSON()
25+
return p
26+
})
27+
28+
expect(result).toMatchObject([
29+
{
30+
start: '2024-07-26T20:00:00.000Z', // UTC time
31+
stop: '2024-07-26T21:00:00.000Z', // UTC
32+
title: 'ヒーリングタイム&ヘッドラインニュース',
33+
description: 'ねこの足跡',
34+
image: null,
35+
category: null
36+
}
37+
])
38+
})
39+
40+
it('can handle empty guide', () => {
41+
const result = parser({
42+
date,
43+
channel,
44+
content: '[]'
45+
})
46+
expect(result).toMatchObject([])
47+
})

sites/skyperfectv.co.jp/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# skyperfectv.co.jp
2+
3+
<https://www.skyperfectv.co.jp>
4+
5+
## Index
6+
7+
- [Index](#index)
8+
- [Download the guide](#download-the-guide)
9+
- [Update channel list](#update-channel-list)
10+
- [Test](#test)
11+
12+
## Download the guide
13+
14+
```sh
15+
npm run grab -- --site=skyperfectv.co.jp
16+
```
17+
18+
## Update channel list
19+
20+
```sh
21+
npm run channels:parse -- --config=./sites/skyperfectv.co.jp/skyperfectv.co.jp.config.js --output=./sites/skyperfectv.co.jp/skyperfectv.co.jp.channels.xml
22+
```
23+
24+
## Test
25+
26+
```sh
27+
npm test -- skyperfectv.co.jp
28+
```

0 commit comments

Comments
 (0)