mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-11 17:40:07 -04:00
Update tvtv.us.config.js
This commit is contained in:
parent
46693e08e5
commit
6b5ae3492a
1 changed files with 60 additions and 19 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
const axios = require('axios')
|
||||||
const dayjs = require('dayjs')
|
const dayjs = require('dayjs')
|
||||||
const utc = require('dayjs/plugin/utc')
|
const utc = require('dayjs/plugin/utc')
|
||||||
|
|
||||||
|
@ -5,38 +6,78 @@ dayjs.extend(utc)
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
site: 'tvtv.us',
|
site: 'tvtv.us',
|
||||||
|
ignore: true, // NOTE: site_id of most channels must be re-mapped
|
||||||
url: function ({ date, channel }) {
|
url: function ({ date, channel }) {
|
||||||
return `https://tvtv.us/tvm/t/tv/v4/stations/${
|
return `https://www.tvtv.us/gn/d/v1.1/stations/${
|
||||||
channel.site_id
|
channel.site_id
|
||||||
}/listings?start=${date.format()}&end=${date.add(1, 'd').format()}`
|
}/airings?startDateTime=${date.format()}&endDateTime=${date.add(1, 'd').format()}`
|
||||||
},
|
},
|
||||||
logo({ channel }) {
|
logo({ channel }) {
|
||||||
return channel.logo
|
return channel.logo
|
||||||
},
|
},
|
||||||
parser: function ({ content }) {
|
parser: function ({ content }) {
|
||||||
let programs = []
|
let programs = []
|
||||||
const items = JSON.parse(content)
|
|
||||||
if (!items.length) return programs
|
const items = parseItems(content)
|
||||||
items.forEach(item => {
|
items.forEach(item => {
|
||||||
const start = dayjs.utc(item.listDateTime)
|
|
||||||
const stop = start.add(item.duration, 'm')
|
|
||||||
const icon = item.showPicture
|
|
||||||
? `https://cdn.tvpassport.com/image/show/480x720/${item.showPicture}`
|
|
||||||
: null
|
|
||||||
let title = item.showName
|
|
||||||
if (title === 'Movie') {
|
|
||||||
title = item.episodeTitle
|
|
||||||
}
|
|
||||||
programs.push({
|
programs.push({
|
||||||
title: title,
|
title: parseTitle(item),
|
||||||
description: item.description,
|
description: parseDescription(item),
|
||||||
category: item.showType,
|
category: parseCategory(item),
|
||||||
start: start.toString(),
|
start: parseStart(item),
|
||||||
stop: stop.toString(),
|
stop: parseStop(item),
|
||||||
icon
|
icon: parseIcon(item)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
return programs
|
return programs
|
||||||
|
},
|
||||||
|
async channels({ country }) {
|
||||||
|
const data = await axios
|
||||||
|
.get(`https://www.tvtv.${country}/api/stations`)
|
||||||
|
.then(r => r.data)
|
||||||
|
.catch(console.log)
|
||||||
|
|
||||||
|
return data.data
|
||||||
|
.filter(i => ['Satellite'].includes(i.type))
|
||||||
|
.map(item => {
|
||||||
|
return {
|
||||||
|
lang: 'en',
|
||||||
|
site_id: item.id,
|
||||||
|
xmltv_id: item.shortName,
|
||||||
|
name: item.name,
|
||||||
|
logo: item.logo
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseItems(content) {
|
||||||
|
return JSON.parse(content)
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseStart(item) {
|
||||||
|
return dayjs(item.startTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseStop(item) {
|
||||||
|
return dayjs(item.endTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseTitle(item) {
|
||||||
|
return item.program.title
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseDescription(item) {
|
||||||
|
return item.program.longDescription
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseCategory(item) {
|
||||||
|
return item.program.genres || []
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseIcon(item) {
|
||||||
|
return item.program.preferredImage && item.program.preferredImage.uri
|
||||||
|
? `http://tvtv.tmsimg.com/${item.program.preferredImage.uri}`
|
||||||
|
: null
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue