Update generate.js
This commit is contained in:
parent
77aabda898
commit
6a710f607b
|
@ -14,6 +14,8 @@ function main() {
|
||||||
parseIndex()
|
parseIndex()
|
||||||
console.log('Creating public directory...')
|
console.log('Creating public directory...')
|
||||||
createPublicDirectory()
|
createPublicDirectory()
|
||||||
|
console.log('Generating index.m3u...')
|
||||||
|
generateIndex()
|
||||||
console.log('Generating index.country.m3u...')
|
console.log('Generating index.country.m3u...')
|
||||||
generateCountryIndex()
|
generateCountryIndex()
|
||||||
console.log('Generating index.language.m3u...')
|
console.log('Generating index.language.m3u...')
|
||||||
|
@ -22,6 +24,8 @@ function main() {
|
||||||
generateContentIndex()
|
generateContentIndex()
|
||||||
console.log('Generating index.full.m3u...')
|
console.log('Generating index.full.m3u...')
|
||||||
generateFullIndex()
|
generateFullIndex()
|
||||||
|
console.log('Generating /countries...')
|
||||||
|
generateCountries()
|
||||||
console.log('Generating /categories...')
|
console.log('Generating /categories...')
|
||||||
generateCategories()
|
generateCategories()
|
||||||
console.log('Generating /languages...')
|
console.log('Generating /languages...')
|
||||||
|
@ -82,6 +86,23 @@ function parseIndex() {
|
||||||
list.categories = categories
|
list.categories = categories
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generateIndex() {
|
||||||
|
const filename = `${ROOT_DIR}/index.m3u`
|
||||||
|
helper.createFile(filename, '#EXTM3U\n')
|
||||||
|
|
||||||
|
const channels = list.all.sort((a, b) => {
|
||||||
|
if(a.title.toLowerCase() < b.title.toLowerCase()) { return -1 }
|
||||||
|
if(a.title.toLowerCase() > b.title.toLowerCase()) { return 1 }
|
||||||
|
if(a.url < b.url) { return -1 }
|
||||||
|
if(a.url > b.url) { return 1 }
|
||||||
|
return 0
|
||||||
|
})
|
||||||
|
|
||||||
|
for(let channel of channels) {
|
||||||
|
helper.appendToFile(filename, channel.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function generateCountryIndex() {
|
function generateCountryIndex() {
|
||||||
const filename = `${ROOT_DIR}/index.country.m3u`
|
const filename = `${ROOT_DIR}/index.country.m3u`
|
||||||
helper.createFile(filename, '#EXTM3U\n')
|
helper.createFile(filename, '#EXTM3U\n')
|
||||||
|
@ -159,6 +180,20 @@ function generateFullIndex() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generateCountries() {
|
||||||
|
const outputDir = `${ROOT_DIR}/countries`
|
||||||
|
helper.createDir(outputDir)
|
||||||
|
|
||||||
|
for(let cid in list.countries) {
|
||||||
|
let country = list.countries[cid]
|
||||||
|
const filename = `${outputDir}/${cid}.m3u`
|
||||||
|
helper.createFile(filename, '#EXTM3U\n')
|
||||||
|
for(let channel of country) {
|
||||||
|
helper.appendToFile(filename, channel.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function generateCategories() {
|
function generateCategories() {
|
||||||
const outputDir = `${ROOT_DIR}/categories`
|
const outputDir = `${ROOT_DIR}/categories`
|
||||||
helper.createDir(outputDir)
|
helper.createDir(outputDir)
|
||||||
|
@ -176,7 +211,7 @@ function generateCategories() {
|
||||||
function generateLanguages() {
|
function generateLanguages() {
|
||||||
const outputDir = `${ROOT_DIR}/languages`
|
const outputDir = `${ROOT_DIR}/languages`
|
||||||
helper.createDir(outputDir)
|
helper.createDir(outputDir)
|
||||||
|
|
||||||
for(let lid in list.languages) {
|
for(let lid in list.languages) {
|
||||||
let language = list.languages[lid]
|
let language = list.languages[lid]
|
||||||
const filename = `${outputDir}/${lid}.m3u`
|
const filename = `${outputDir}/${lid}.m3u`
|
||||||
|
|
Loading…
Reference in New Issue