Update generate.js
This commit is contained in:
parent
cfd11b481b
commit
1d11c69ba4
@ -26,7 +26,7 @@ function createRootDirectory() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createNoJekyllFile() {
|
function createNoJekyllFile() {
|
||||||
console.log('Creating .nojekyll...')
|
console.log('Creating .nojekyll file...')
|
||||||
utils.createFile(`${ROOT_DIR}/.nojekyll`)
|
utils.createFile(`${ROOT_DIR}/.nojekyll`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,13 +93,24 @@ function generateLanguageIndex() {
|
|||||||
const filename = `${ROOT_DIR}/index.language.m3u`
|
const filename = `${ROOT_DIR}/index.language.m3u`
|
||||||
utils.createFile(filename, '#EXTM3U\n')
|
utils.createFile(filename, '#EXTM3U\n')
|
||||||
|
|
||||||
const channels = db.channels.sortBy(['tvgLanguage', 'name', 'url']).all()
|
const channels = db.channels.sortBy(['name', 'url']).forLanguage({ code: null })
|
||||||
for (const channel of channels) {
|
for (const channel of channels) {
|
||||||
const category = channel.category
|
const category = channel.category
|
||||||
channel.category = channel.tvgLanguage
|
channel.category = ''
|
||||||
utils.appendToFile(filename, channel.toString())
|
utils.appendToFile(filename, channel.toString())
|
||||||
channel.category = category
|
channel.category = category
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const languages = db.languages.sortBy(['name']).all()
|
||||||
|
for (const language of languages) {
|
||||||
|
const channels = db.channels.sortBy(['name', 'url']).forLanguage(language)
|
||||||
|
for (const channel of channels) {
|
||||||
|
const category = channel.category
|
||||||
|
channel.category = language.name
|
||||||
|
utils.appendToFile(filename, channel.toString())
|
||||||
|
channel.category = category
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateCategoryIndex() {
|
function generateCategoryIndex() {
|
||||||
@ -113,8 +124,31 @@ function generateCategoryIndex() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generateCategories() {
|
||||||
|
console.log('Generating a playlist for each category...')
|
||||||
|
const outputDir = `${ROOT_DIR}/categories`
|
||||||
|
utils.createDir(outputDir)
|
||||||
|
|
||||||
|
for (const category of db.categories.all()) {
|
||||||
|
const filename = `${outputDir}/${category.id}.m3u`
|
||||||
|
utils.createFile(filename, '#EXTM3U\n')
|
||||||
|
|
||||||
|
const channels = db.channels.sortBy(['name', 'url']).forCategory(category)
|
||||||
|
for (const channel of channels) {
|
||||||
|
utils.appendToFile(filename, channel.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const other = `${outputDir}/other.m3u`
|
||||||
|
const channels = db.channels.sortBy(['name', 'url']).forCategory({ id: null })
|
||||||
|
utils.createFile(other, '#EXTM3U\n')
|
||||||
|
for (const channel of channels) {
|
||||||
|
utils.appendToFile(other, channel.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function generateCountries() {
|
function generateCountries() {
|
||||||
console.log('Generating /countries...')
|
console.log('Generating a playlist for each country...')
|
||||||
const outputDir = `${ROOT_DIR}/countries`
|
const outputDir = `${ROOT_DIR}/countries`
|
||||||
utils.createDir(outputDir)
|
utils.createDir(outputDir)
|
||||||
|
|
||||||
@ -130,7 +164,7 @@ function generateCountries() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function generateLanguages() {
|
function generateLanguages() {
|
||||||
console.log('Generating /languages...')
|
console.log('Generating a playlist for each language...')
|
||||||
const outputDir = `${ROOT_DIR}/languages`
|
const outputDir = `${ROOT_DIR}/languages`
|
||||||
utils.createDir(outputDir)
|
utils.createDir(outputDir)
|
||||||
|
|
||||||
@ -145,22 +179,6 @@ function generateLanguages() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateCategories() {
|
|
||||||
console.log('Generating /categories...')
|
|
||||||
const outputDir = `${ROOT_DIR}/categories`
|
|
||||||
utils.createDir(outputDir)
|
|
||||||
|
|
||||||
for (const category of db.categories.all()) {
|
|
||||||
const filename = `${outputDir}/${category.id}.m3u`
|
|
||||||
utils.createFile(filename, '#EXTM3U\n')
|
|
||||||
|
|
||||||
const channels = db.channels.sortBy(['name', 'url']).forCategory(category)
|
|
||||||
for (const channel of channels) {
|
|
||||||
utils.appendToFile(filename, channel.toString())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function finish() {
|
function finish() {
|
||||||
console.log(
|
console.log(
|
||||||
`Countries: ${db.countries.count()}. Languages: ${db.languages.count()}. Categories: ${db.categories.count()}. Channels: ${db.channels.count()}.`
|
`Countries: ${db.countries.count()}. Languages: ${db.languages.count()}. Categories: ${db.categories.count()}. Channels: ${db.channels.count()}.`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user