Added support multiple playlist types
This commit is contained in:
parent
be2371eb60
commit
8a393dd4c1
@ -1,7 +1,7 @@
|
|||||||
const util = require('./util')
|
const util = require('./util')
|
||||||
const urlParser = require('url')
|
const urlParser = require('url')
|
||||||
|
|
||||||
const outputFile = 'index.full.m3u'
|
const types = ['country', 'topic']
|
||||||
const debug = false
|
const debug = false
|
||||||
let cache = {}
|
let cache = {}
|
||||||
let stats = {
|
let stats = {
|
||||||
@ -17,7 +17,9 @@ function init() {
|
|||||||
countries = countries.slice(0, 1)
|
countries = countries.slice(0, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
util.createFile(outputFile, '#EXTM3U\n')
|
for(const type of types) {
|
||||||
|
util.createFile(`index.${type}.m3u`, '#EXTM3U\n')
|
||||||
|
}
|
||||||
|
|
||||||
for(let country of countries) {
|
for(let country of countries) {
|
||||||
|
|
||||||
@ -28,9 +30,10 @@ function init() {
|
|||||||
for(let item of playlist) {
|
for(let item of playlist) {
|
||||||
|
|
||||||
const channel = util.parseChannelData(item)
|
const channel = util.parseChannelData(item)
|
||||||
const groupTitle = [ countryName, channel.group ].filter(i => i).join(';')
|
|
||||||
|
|
||||||
const info = `-1 tvg-id="${channel.id}" tvg-name="${channel.name}" tvg-logo="${channel.logo}" group-title="${groupTitle}",${channel.title}`
|
|
||||||
|
|
||||||
|
|
||||||
const file = channel.file
|
const file = channel.file
|
||||||
|
|
||||||
if(checkCache(file)) {
|
if(checkCache(file)) {
|
||||||
@ -39,9 +42,21 @@ function init() {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const data = '#EXTINF:' + info + '\n' + file + '\n'
|
for(const type of types) {
|
||||||
|
let groupTitle = ''
|
||||||
|
if(type === 'full') {
|
||||||
|
groupTitle = [ countryName, channel.group ].filter(i => i).join(';')
|
||||||
|
} else if(type === 'country') {
|
||||||
|
groupTitle = countryName
|
||||||
|
} else if(type === 'topic') {
|
||||||
|
groupTitle = channel.group
|
||||||
|
}
|
||||||
|
|
||||||
util.writeToFile(outputFile, data)
|
const info = `-1 tvg-id="${channel.id}" tvg-name="${channel.name}" tvg-logo="${channel.logo}" group-title="${groupTitle}",${channel.title}`
|
||||||
|
const data = '#EXTINF:' + info + '\n' + file + '\n'
|
||||||
|
|
||||||
|
util.writeToFile(`index.${type}.m3u`, data)
|
||||||
|
}
|
||||||
|
|
||||||
addToCache(file)
|
addToCache(file)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user