Merge pull request #1759 from iptv-org/add-tving.com
Add guide from tving.com
This commit is contained in:
6 files changed
+198
No files matched your search
@@ -0,0 +1,17 @@
|
||||
name: tving.com
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 3 * * *'
|
||||
workflow_dispatch:
|
||||
workflow_run:
|
||||
workflows: [_trigger]
|
||||
types:
|
||||
- completed
|
||||
jobs:
|
||||
load:
|
||||
uses: ./.github/workflows/_load.yml
|
||||
with:
|
||||
site: ${{github.workflow}}
|
||||
secrets:
|
||||
APP_ID: ${{ secrets.APP_ID }}
|
||||
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
|
||||
@@ -0,0 +1 @@
|
||||
cb({"header":{"message":"OK","status":200},"body":{"result":[{"id":"63c9227434fc5f27f8f873ee","schedule_code":"C00551","broadcast_date":20230122,"broadcast_start_time":20230122224000,"broadcast_end_time":20230123000000,"schedule_type":"CSMD0100","rerun_yn":"N","stream_type":"120","channel":{"code":"C00551","name":{"prefix_ko":null,"ko":"tvN","en":null},"category_code":"CG110","category_name":{"prefix_ko":null,"ko":"드라마","en":null},"description":{"prefix_ko":null,"ko":"티비앤","en":null},"quality":"CVPR0200","hd_yn":"Y","price":{"krw":1900,"usd":0,"appstore":0,"playstore":0,"rental":0,"collect":0},"free_yn":"N","adult_yn":"N","item_sale_yn":"Y","guest_watch_yn":"N","oversea_watch_yn":"Y","image":[{"url":"/upload/cms/caic/CAIC0100/C00551.png","url2":null,"code":"CAIC0100"},{"url":"/upload/cms/caic/CAIC0300/C00551.png","url2":null,"code":"CAIC0300"},{"url":"/upload/cms/caic/CAIC0400/C00551.png","url2":null,"code":"CAIC0400"},{"url":"/upload/cms/caic/CAIC0500/C00551.png","url2":null,"code":"CAIC0500"},{"url":"/upload/cms/caic/20110303182808IMG_FILE_5.jpg","url2":null,"code":"CAIC0600"},{"url":"/upload/cms/caic/CAIC0700/C00551.png","url2":null,"code":"CAIC0700"},{"url":"/upload/cms/caic/CAIC0800/C00551.png","url2":null,"code":"CAIC0800"},{"url":"/upload/cms/caic/20110517154214IMG_FILE_8.png","url2":null,"code":"CAIC0900"},{"url":"/upload/cms/caic/CAIC1100/C00551.png","url2":null,"code":"CAIC1100"},{"url":"/upload/cms/caic/CAIC1200/C00551.png","url2":null,"code":"CAIC1200"},{"url":"/upload/cms/caic/CAIC1300/C00551.png","url2":null,"code":"CAIC1300"},{"url":"/upload/cms/caic/CAIC1400/C00551.png","url2":null,"code":"CAIC1400"},{"url":"/upload/cms/caic/CAIC1500/C00551.png","url2":null,"code":"CAIC1500"},{"url":"/upload/cms/caic/CAIC1600/C00551.png","url2":null,"code":"CAIC1600"},{"url":"/upload/cms/caic/CAIC1700/C00551.png","url2":null,"code":"CAIC1700"},{"url":"/upload/cms/caic/CAIC1800/C00551.png","url2":null,"code":"CAIC1800"},{"url":"/upload/cms/caic/CAIC1900/C00551.png","url2":null,"code":"CAIC1900"},{"url":"/upload/cms/caic/CAIC2100/C00551.png","url2":null,"code":"CAIC2100"},{"url":"/upload/cms/caic/CAIC2200/C00551.png","url2":null,"code":"CAIC2200"},{"url":"/upload/cms/caic/CAIC2300/C00551.png","url2":null,"code":"CAIC2300"}],"no":2,"sort_no":9,"stick_channel_no":13,"mcp_code":"1115","scp_code":"18","time_shift_time":120,"type":"CPCS0100","broadcast_type":"CPSE0200","service_yn":"Y","fan_yn":"N","parent_code":"","enm_code":"EA","ch_home_url":"http://tvn.tving.com/tvn","ch_home_m_url":"http://tvn.m.tving.com/tvn","adpre":"","admid":"","drm_multi_yn":null,"contenttype":"","dai_asset_id":""},"multiview_url":null,"preview_url":null,"insert_date":20230116004453,"program":{"code":"P001661154","name":{"ko":"외계+인 1부"},"category1_code":"PCB","category1_name":{"ko":""},"category2_code":"PCB015","category2_name":{"ko":""},"product_year":2022,"director":["최동훈"],"actor":["김우빈","류준열"],"synopsis":{"ko":"외계+인 1부"},"story":{"ko":""},"image":[{"url":"/upload/cms/caip/CAIP0200/P001661154.jpg","url2":null,"code":"CAIP0200"},{"url":"/upload/cms/caip/CAIP0400/P001661154.jpg","url2":null,"code":"CAIP0400"},{"url":"/upload/cms/caip/CAIP0500/P001661154.jpg","url2":null,"code":"CAIP0500"},{"url":"/upload/cms/caip/CAIP0600/P001661154.jpg","url2":null,"code":"CAIP0600"},{"url":"/upload/cms/caip/CAIP0800/P001661154.jpg","url2":null,"code":"CAIP0800"}],"display_category1":[],"display_category2":[],"grade_code":"CPTG0300","adult_yn":"N","keywords1":null,"keywords2":null,"enm_code":"","stream_meta_info":"","pgm_home_url":"","pgm_home_m_url":"","script":"","broad_state":"","broad_dt":"","broad_end_dt":"","broad_week":"","broad_hour":"","broad_minu":"","smr_program_code":"","quickup_yn":"N","season_pgm_code":"","season_pgm_no":"1","season_etc_vod_yn":"N","tving_original_yn":"N","tving_exclusive_yn":"N","channel_code":"C14447","series_code":"","fan_yn":"N","image_url":null},"episode":null,"movie":null,"clip":null,"ad":null,"broadcast_url":[{"block_yn":"N","broad_url1":"http://tvn-mcdn.tving.com/tvn/live1000.smil/playlist.m3u8","broad_url2":"http://tvn-mcdn.tving.com/tvn/live500.smil/playlist.m3u8","broad_url3":"http://tvn-mcdn.tving.com/tvn/live1500.smil/playlist.m3u8","broad_url4":"http://tvn-mcdn.tving.com/tvn/live2000.smil/playlist.m3u8","broad_url5":"http://tvn-mcdn.tving.com/tvn/live5000.smil/playlist.m3u8","broad_url6":"","broad_url7":"","multiview_url":"","preview_url":"","audio_url":"","abr_url":"","stillshot_url":"","ndvr_host":"http://tvn-ndvr-mcdn.tving.com","subpolicy_code":"type1","network_code":"CSND0900","os_code":"CSOD0900","screen_code":"CSSD0200","tele_code":"CSCD0900"}],"support_info":["CSSD0500,CSND0900,CSOD0900,CSCD0900","CSSD0300,CSND0200,CSOD0200,CSCD0900","CSSD1100,CSND0900,CSOD0900,CSCD0900","CSSD0400,CSND0900,CSOD0900,CSCD0900","CSSD0100,CSND0900,CSOD0900,CSCD0900","CSSD0200,CSND0100,CSOD0100,CSCD0100","CSSD0600,CSND0900,CSOD0900,CSCD0900","CSSD0200,CSND0200,CSOD0200,CSCD090Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
cb({"header":{"message":"OK","status":200},"body":{"result":[],"total_count":0,"has_more":"N"}});
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site site="tving.com">
|
||||
<channels>
|
||||
<channel lang="ko" xmltv_id="ChannelA.kr" site_id="C01583">채널a</channel>
|
||||
<channel lang="ko" xmltv_id="ChannelAPlus.kr" site_id="C17141">채널a plus</channel>
|
||||
<channel lang="ko" xmltv_id="ChunghwaTV.kr" site_id="C00544">중화TV</channel>
|
||||
<channel lang="ko" xmltv_id="HistoryKorea.kr" site_id="C17341">히스토리</channel>
|
||||
<channel lang="ko" xmltv_id="JTBC.kr" site_id="C01582">jtbc</channel>
|
||||
<channel lang="ko" xmltv_id="JTBC2.kr" site_id="C15741">jtbc2</channel>
|
||||
<channel lang="ko" xmltv_id="JTBC4.kr" site_id="C22041">jtbc4</channel>
|
||||
<channel lang="ko" xmltv_id="MBN.kr" site_id="C00708">MBN</channel>
|
||||
<channel lang="ko" xmltv_id="MBNPlus.kr" site_id="C17142">MBN Plus</channel>
|
||||
<channel lang="ko" xmltv_id="Mnet.kr" site_id="C00579">Mnet</channel>
|
||||
<channel lang="ko" xmltv_id="OCN.kr" site_id="C07381">OCN</channel>
|
||||
<channel lang="ko" xmltv_id="OCNMovies.kr" site_id="C04601">Ch. CGV</channel>
|
||||
<channel lang="ko" xmltv_id="OCNThrills.kr" site_id="C07382">super Action</channel>
|
||||
<channel lang="ko" xmltv_id="OGN.kr" site_id="C00590">OGN</channel>
|
||||
<channel lang="ko" xmltv_id="Olive.kr" site_id="C00575">Olive</channel>
|
||||
<channel lang="ko" xmltv_id="Onstyle.kr" site_id="C01142">Onstyle</channel>
|
||||
<channel lang="ko" xmltv_id="OTVN.kr" site_id="C01143">OtvN</channel>
|
||||
<channel lang="ko" xmltv_id="Tooniverse.kr" site_id="C06941">Tooniverse</channel>
|
||||
<channel lang="ko" xmltv_id="TVChosun.kr" site_id="C01581">tv조선</channel>
|
||||
<channel lang="ko" xmltv_id="TVChosun2.kr" site_id="C00585">c time</channel>
|
||||
<channel lang="ko" xmltv_id="tvN.kr" site_id="C00551">tvN</channel>
|
||||
<channel lang="ko" xmltv_id="XTVN.kr" site_id="C01141">Xtvn</channel>
|
||||
<channel lang="ko" xmltv_id="YonhapNewsTV.kr" site_id="C01723">연합뉴스</channel>
|
||||
<channel lang="ko" xmltv_id="YTN.kr" site_id="C00593">YTN</channel>
|
||||
<channel lang="ko" xmltv_id="YTN2.kr" site_id="C01101">YTN life</channel>
|
||||
<channel lang="ko" xmltv_id="YTNScience.kr" site_id="C15347">YTN science</channel>
|
||||
<!-- <channel lang="ko" xmltv_id="" site_id="C00611">life time</channel> -->
|
||||
<!-- <channel lang="ko" xmltv_id="" site_id="C00805">jtbc3</channel> -->
|
||||
<!-- <channel lang="ko" xmltv_id="" site_id="C05661">디즈니</channel> -->
|
||||
<!-- <channel lang="ko" xmltv_id="" site_id="C15152">DAI TV</channel> -->
|
||||
</channels>
|
||||
</site>
|
||||
@@ -0,0 +1,94 @@
|
||||
const axios = require('axios')
|
||||
const cheerio = require('cheerio')
|
||||
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: 'tving.com',
|
||||
days: 2,
|
||||
url: function ({ channel, date }) {
|
||||
return `https://api.tving.com/v2/media/schedules/${channel.site_id}/${date.format(
|
||||
'YYYYMMDD'
|
||||
)}?callback=cb&pageNo=1&pageSize=500&screenCode=CSSD0200&networkCode=CSND0900&osCode=CSOD0900&teleCode=CSCD0900&apiKey=4263d7d76161f4a19a9efe9ca7903ec4`
|
||||
},
|
||||
parser: function ({ content }) {
|
||||
let programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
programs.push({
|
||||
title: item.program.name.ko,
|
||||
description: item.program.synopsis.ko,
|
||||
categories: parseCategories(item),
|
||||
date: item.program.product_year,
|
||||
directors: item.program.director,
|
||||
actors: item.program.actor,
|
||||
start: parseStart(item),
|
||||
stop: parseStop(item),
|
||||
icon: parseIcon(item)
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
let items = await axios
|
||||
.get(`https://m.tving.com/guide/schedule.tving`)
|
||||
.then(r => r.data)
|
||||
.then(html => {
|
||||
let $ = cheerio.load(html)
|
||||
|
||||
return $('ul.cb > li').toArray()
|
||||
})
|
||||
.catch(console.log)
|
||||
|
||||
return items.map(item => {
|
||||
let $item = cheerio.load(item)
|
||||
let [, site_id] = $item('a')
|
||||
.attr('href')
|
||||
.match(/\?id\=(.*)/) || [null, null]
|
||||
let name = $item('img').attr('alt')
|
||||
|
||||
return {
|
||||
lang: 'ko',
|
||||
site_id,
|
||||
name
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function parseIcon(item) {
|
||||
return item.program.image.length ? `https://image.tving.com${item.program.image[0].url}` : null
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.tz(item.broadcast_start_time.toString(), `YYYYMMDDHHmmss`, 'Asia/Seoul')
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
return dayjs.tz(item.broadcast_end_time.toString(), `YYYYMMDDHHmmss`, 'Asia/Seoul')
|
||||
}
|
||||
|
||||
function parseCategories(item) {
|
||||
const categories = []
|
||||
|
||||
if (item.category1_name) categories.push(item.category1_name.ko)
|
||||
if (item.category2_name) categories.push(item.category2_name.ko)
|
||||
|
||||
return categories.filter(Boolean)
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
let data = (content.match(/cb\((.*)\)/) || [null, null])[1]
|
||||
if (!data) return []
|
||||
let json = JSON.parse(data)
|
||||
if (!json || !json.body || !Array.isArray(json.body.result)) return []
|
||||
|
||||
return json.body.result
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// npm run channels:parse -- --config=./sites/tving.com/tving.com.config.js --output=./sites/tving.com/tving.com.channels.xml
|
||||
// npx epg-grabber --config=sites/tving.com/tving.com.config.js --channels=sites/tving.com/tving.com.channels.xml --output=guide.xml --days=2
|
||||
|
||||
const { parser, url, request } = require('./tving.com.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('2023-01-23', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: 'C00551',
|
||||
xmltv_id: 'tvN.kr'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe(
|
||||
`https://api.tving.com/v2/media/schedules/C00551/20230123?callback=cb&pageNo=1&pageSize=500&screenCode=CSSD0200&networkCode=CSND0900&osCode=CSOD0900&teleCode=CSCD0900&apiKey=4263d7d76161f4a19a9efe9ca7903ec4`
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.txt'), 'utf8')
|
||||
const results = parser({ content }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results[0]).toMatchObject({
|
||||
title: '외계+인 1부',
|
||||
description: '외계+인 1부',
|
||||
icon: 'https://image.tving.com/upload/cms/caip/CAIP0200/P001661154.jpg',
|
||||
date: 2022,
|
||||
categories: [],
|
||||
directors: ['최동훈'],
|
||||
actors: ['김우빈', '류준열'],
|
||||
start: '2023-01-22T13:40:00.000Z',
|
||||
stop: '2023-01-22T15:00:00.000Z'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/no_content.txt'), 'utf8')
|
||||
|
||||
expect(parser({ content })).toMatchObject([])
|
||||
})
|
||||
Reference in new issue
Block a user