Merge branch 'master' into MapGuy11-patch-3

This commit is contained in:
Dum4G 2021-09-19 20:07:47 +03:00 committed by GitHub
commit 6bb6c619a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 95 additions and 12 deletions

View File

@ -1683,8 +1683,10 @@ https://a.jsrdn.com/broadcast/e6bdcb5ae9/+0000/c.m3u8
https://d155hi8td9k2ns.cloudfront.net/out/wapo-medialive3-rtmp/live.m3u8 https://d155hi8td9k2ns.cloudfront.net/out/wapo-medialive3-rtmp/live.m3u8
#EXTINF:-1 tvg-id="TheWallStreetJournalLive.us" tvg-country="US" tvg-language="English" tvg-logo="https://i.imgur.com/ZzyXAKm.jpg" group-title="News",The Wall Street Journal Live (1080p) #EXTINF:-1 tvg-id="TheWallStreetJournalLive.us" tvg-country="US" tvg-language="English" tvg-logo="https://i.imgur.com/ZzyXAKm.jpg" group-title="News",The Wall Street Journal Live (1080p)
https://wsjlivehls-lh.akamaihd.net/i/events1_1@174990/master.m3u8 https://wsjlivehls-lh.akamaihd.net/i/events1_1@174990/master.m3u8
#EXTINF:-1 tvg-id="TheWeatherChannel.us" tvg-country="US" tvg-language="English" tvg-logo="http://i.imgur.com/D4vJyy9.png" group-title="Weather",The Weather Channel (720p) [Geo-blocked] #EXTINF:-1 tvg-id="TheWeatherChannel.us" tvg-country="US" tvg-language="English" tvg-logo="http://i.imgur.com/D4vJyy9.png" group-title="Weather",The Weather Channel
https://weather-lh.akamaihd.net/i/twc_1@92006/master.m3u8 https://cdn88.theus6tv.tk/united-states/cable/the-weather-channel.m3u8
#EXTINF:-1 tvg-id="TheWeatherChannel.us" tvg-country="US" tvg-language="English" tvg-logo="http://i.imgur.com/D4vJyy9.png" group-title="Weather",The Weather Channel (Alternative)
https://cdn88.theus6tv.tk/united-states/cable/the-weather-channel-alt.m3u8
#EXTINF:-1 tvg-id="ThisTVNetwork.us" tvg-country="US" tvg-language="English" tvg-logo="https://i.imgur.com/FQCVaSR.png" group-title="",This TV Network (480p) #EXTINF:-1 tvg-id="ThisTVNetwork.us" tvg-country="US" tvg-language="English" tvg-logo="https://i.imgur.com/FQCVaSR.png" group-title="",This TV Network (480p)
https://cdn.igocast.com/channel11_hls/channel11_master.m3u8 https://cdn.igocast.com/channel11_hls/channel11_master.m3u8
#EXTINF:-1 tvg-id="TNTEast.us" tvg-country="US" tvg-language="English" tvg-logo="https://i.imgur.com/xvL9KPI.png" group-title="General",TNT East [Geo-blocked] #EXTINF:-1 tvg-id="TNTEast.us" tvg-country="US" tvg-language="English" tvg-logo="https://i.imgur.com/xvL9KPI.png" group-title="General",TNT East [Geo-blocked]

View File

@ -1,10 +1,12 @@
const IPTVChecker = require('iptv-checker') const axios = require('axios')
const normalize = require('normalize-url')
const { program } = require('commander') const { program } = require('commander')
const normalize = require('normalize-url')
const IPTVChecker = require('iptv-checker')
const parser = require('./helpers/parser') const parser = require('./helpers/parser')
const utils = require('./helpers/utils') const utils = require('./helpers/utils')
const file = require('./helpers/file') const file = require('./helpers/file')
const log = require('./helpers/log') const log = require('./helpers/log')
const epg = require('./helpers/epg')
const ignoreStatus = ['Geo-blocked', 'Not 24/7'] const ignoreStatus = ['Geo-blocked', 'Not 24/7']
@ -51,13 +53,28 @@ async function updatePlaylist(playlist) {
const total = playlist.channels.length const total = playlist.channels.length
log.print(`Processing '${playlist.url}'...\n`) log.print(`Processing '${playlist.url}'...\n`)
let channels = {}
let codes = {}
if (!config.offline) {
channels = await loadChannelsJson()
codes = await loadCodes()
}
buffer = {} buffer = {}
origins = {} origins = {}
for (const [i, channel] of playlist.channels.entries()) { for (const [i, channel] of playlist.channels.entries()) {
const curr = i + 1 const curr = i + 1
updateDescription(channel, playlist) updateTvgName(channel)
updateTvgId(channel, playlist)
updateTvgCountry(channel, playlist)
normalizeUrl(channel) normalizeUrl(channel)
const data = channels[channel.tvg.id]
const epgData = codes[channel.tvg.id]
updateLogo(channel, data, epgData)
updateGroupTitle(channel, data)
updateTvgLanguage(channel, data)
if (config.offline || ignoreStatus.includes(channel.status)) { if (config.offline || ignoreStatus.includes(channel.status)) {
continue continue
} }
@ -186,21 +203,49 @@ function parseRequests(requests) {
return requests return requests
} }
function updateDescription(channel, playlist) { function updateTvgName(channel) {
if (!channel.tvg.name) {
channel.tvg.name = channel.name.replace(/\"/gi, '')
}
}
function updateTvgId(channel, playlist) {
const code = playlist.country.code const code = playlist.country.code
// tvg-id
if (!channel.tvg.id && channel.tvg.name) { if (!channel.tvg.id && channel.tvg.name) {
const id = utils.name2id(channel.tvg.name) const id = utils.name2id(channel.tvg.name)
channel.tvg.id = id ? `${id}.${code}` : '' channel.tvg.id = id ? `${id}.${code}` : ''
} }
// country }
function updateTvgCountry(channel, playlist) {
const code = playlist.country.code
if (!channel.countries.length) { if (!channel.countries.length) {
const name = utils.code2name(code) const name = utils.code2name(code)
channel.countries = name ? [{ code, name }] : [] channel.countries = name ? [{ code, name }] : []
channel.tvg.country = channel.countries.map(c => c.code.toUpperCase()).join(';') channel.tvg.country = channel.countries.map(c => c.code.toUpperCase()).join(';')
} }
// group-title }
channel.group.title = channel.category
function updateLogo(channel, data, epgData) {
if (!channel.logo) {
if (data) {
channel.logo = data.logo
} else if (epgData) {
channel.logo = epgData.logo
}
}
}
function updateTvgLanguage(channel, data) {
if (!channel.tvg.language && data) {
channel.tvg.language = data.languages.map(l => l.name).join(';')
}
}
function updateGroupTitle(channel, data) {
if (!channel.group.title && data) {
channel.group.title = channel.category || data.category || ''
}
} }
function normalizeUrl(channel) { function normalizeUrl(channel) {
@ -213,4 +258,38 @@ function parseNumber(str) {
return parseInt(str) return parseInt(str)
} }
function loadCodes() {
return epg.codes
.load()
.then(codes => {
let output = {}
codes.forEach(item => {
output[item['tvg_id']] = item
})
return output
})
.catch(console.log)
}
function loadChannelsJson() {
return axios
.get('https://iptv-org.github.io/iptv/channels.json')
.then(r => r.data)
.then(channels => {
let output = {}
channels.forEach(channel => {
const item = output[channel.tvg.id]
if (!item) {
output[channel.tvg.id] = channel
} else {
item.logo = item.logo || channel.logo
item.languages = item.languages.length ? item.languages : channel.languages
item.category = item.category || channel.category
}
})
return output
})
.catch(console.log)
}
main() main()

View File

@ -109,9 +109,11 @@ module.exports = class Channel {
} }
getInfo() { getInfo() {
let info = `-1 tvg-id="${this.tvg.id}" tvg-country="${this.tvg.country}" tvg-language="${this.tvg.language}" tvg-logo="${this.logo}"` let info = `-1 tvg-id="${this.tvg.id}" tvg-country="${this.tvg.country || ''}" tvg-language="${
this.tvg.language || ''
}" tvg-logo="${this.logo || ''}"`
info += ` group-title="${this.group.title}",${this.name}` info += ` group-title="${this.group.title || ''}",${this.name}`
if (this.resolution.height) { if (this.resolution.height) {
info += ` (${this.resolution.height}p)` info += ` (${this.resolution.height}p)`