Update generate.js

pull/2138/head
freearhey 4 years ago
parent cfd11b481b
commit 1d11c69ba4

@ -26,7 +26,7 @@ function createRootDirectory() {
}
function createNoJekyllFile() {
console.log('Creating .nojekyll...')
console.log('Creating .nojekyll file...')
utils.createFile(`${ROOT_DIR}/.nojekyll`)
}
@ -93,13 +93,24 @@ function generateLanguageIndex() {
const filename = `${ROOT_DIR}/index.language.m3u`
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) {
const category = channel.category
channel.category = channel.tvgLanguage
channel.category = ''
utils.appendToFile(filename, channel.toString())
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() {
@ -113,48 +124,55 @@ function generateCategoryIndex() {
}
}
function generateCountries() {
console.log('Generating /countries...')
const outputDir = `${ROOT_DIR}/countries`
function generateCategories() {
console.log('Generating a playlist for each category...')
const outputDir = `${ROOT_DIR}/categories`
utils.createDir(outputDir)
for (const country of db.countries.all()) {
const filename = `${outputDir}/${country.code}.m3u`
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']).forCountry(country)
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 generateLanguages() {
console.log('Generating /languages...')
const outputDir = `${ROOT_DIR}/languages`
function generateCountries() {
console.log('Generating a playlist for each country...')
const outputDir = `${ROOT_DIR}/countries`
utils.createDir(outputDir)
for (const language of db.languages.all()) {
const filename = `${outputDir}/${language.code}.m3u`
for (const country of db.countries.all()) {
const filename = `${outputDir}/${country.code}.m3u`
utils.createFile(filename, '#EXTM3U\n')
const channels = db.channels.sortBy(['name', 'url']).forLanguage(language)
const channels = db.channels.sortBy(['name', 'url']).forCountry(country)
for (const channel of channels) {
utils.appendToFile(filename, channel.toString())
}
}
}
function generateCategories() {
console.log('Generating /categories...')
const outputDir = `${ROOT_DIR}/categories`
function generateLanguages() {
console.log('Generating a playlist for each language...')
const outputDir = `${ROOT_DIR}/languages`
utils.createDir(outputDir)
for (const category of db.categories.all()) {
const filename = `${outputDir}/${category.id}.m3u`
for (const language of db.languages.all()) {
const filename = `${outputDir}/${language.code}.m3u`
utils.createFile(filename, '#EXTM3U\n')
const channels = db.channels.sortBy(['name', 'url']).forCategory(category)
const channels = db.channels.sortBy(['name', 'url']).forLanguage(language)
for (const channel of channels) {
utils.appendToFile(filename, channel.toString())
}

Loading…
Cancel
Save