mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
commit
55d306456b
1 changed files with 51 additions and 11 deletions
|
@ -34,25 +34,65 @@ module.exports = {
|
||||||
return programs
|
return programs
|
||||||
},
|
},
|
||||||
async channels({ country }) {
|
async channels({ country }) {
|
||||||
|
const channels = []
|
||||||
|
|
||||||
const data = await axios
|
const data = await axios
|
||||||
.get(`https://www.tvtv.${country}/api/stations`)
|
.get(`https://www.tvtv.${country}/api/stations`)
|
||||||
.then(r => r.data)
|
.then(r => r.data)
|
||||||
.catch(console.log)
|
.catch(console.log)
|
||||||
|
|
||||||
return data.data
|
const stations = data.data.filter(i => !['Radio Station'].includes(i.type))
|
||||||
.filter(i => ['Satellite'].includes(i.type))
|
for (const station of stations) {
|
||||||
.map(item => {
|
const stationData = await axios
|
||||||
return {
|
.get(`https://www.tvtv.us/gn/d/v1.1/stations/${station.id}`)
|
||||||
lang: 'en',
|
.then(r => r.data[0] || {})
|
||||||
site_id: item.id,
|
.catch(console.log)
|
||||||
xmltv_id: item.shortName,
|
if (!stationData) continue
|
||||||
name: item.name,
|
|
||||||
logo: item.logo
|
let channel
|
||||||
}
|
const logo = parseChannelLogo(stationData.preferredImage)
|
||||||
})
|
switch (stationData.type) {
|
||||||
|
case 'Low Power Broadcast':
|
||||||
|
case 'Full Power Broadcast':
|
||||||
|
channel = {
|
||||||
|
site_id: station.id,
|
||||||
|
name: stationData.name,
|
||||||
|
xmltv_id: parseChannelId(stationData),
|
||||||
|
logo
|
||||||
|
}
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
channel = {
|
||||||
|
site_id: station.id,
|
||||||
|
name: stationData.name,
|
||||||
|
logo
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if (channel) {
|
||||||
|
channels.push(channel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return channels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseChannelLogo(image) {
|
||||||
|
return image && image.uri ? `http://tvtv.tmsimg.com/${image.uri}` : null
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseChannelId(data) {
|
||||||
|
if (!data.callSign) return null
|
||||||
|
if (/^((CB|C[F-K]|V[A-G]|VO|VX|VY|X[J-O])[0-9A-Z-]+)/.test(data.callSign))
|
||||||
|
return `${data.callSign}.ca`
|
||||||
|
if (/^((XH|XE)[0-9A-Z-]+)/.test(data.callSign)) return `${data.callSign}.mx`
|
||||||
|
if (/^((K|N|W)[0-9A-Z-]+)/.test(data.callSign)) return `${data.callSign}.us`
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
function parseItems(content) {
|
function parseItems(content) {
|
||||||
return JSON.parse(content)
|
return JSON.parse(content)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue