|
| 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 | +} |
0 commit comments