Update generate.js

This commit is contained in:
Aleksandr Statciuk 2021-09-20 17:14:50 +03:00
parent 63db7140cf
commit b2c3e452f4
1 changed files with 15 additions and 8 deletions

View File

@ -36,7 +36,11 @@ function createNoJekyllFile() {
function generateIndex() { function generateIndex() {
log.print('Generating index.m3u...\n') log.print('Generating index.m3u...\n')
const channels = db.channels.sortBy(['name', 'url']).removeDuplicates().removeOffline().get() const channels = db.channels
.sortBy(['name', 'status', 'resolution.height', 'url'], ['asc', 'asc', 'desc', 'asc'])
.removeDuplicates()
.removeOffline()
.get()
const guides = channels.map(channel => channel.tvg.url) const guides = channels.map(channel => channel.tvg.url)
const filename = `${ROOT_DIR}/index.m3u` const filename = `${ROOT_DIR}/index.m3u`
@ -57,7 +61,10 @@ function generateIndex() {
function generateCategoryIndex() { function generateCategoryIndex() {
log.print('Generating index.category.m3u...\n') log.print('Generating index.category.m3u...\n')
const channels = db.channels const channels = db.channels
.sortBy(['category', 'name', 'url']) .sortBy(
['category', 'name', 'status', 'resolution.height', 'url'],
['asc', 'asc', 'asc', 'desc', 'asc']
)
.removeDuplicates() .removeDuplicates()
.removeOffline() .removeOffline()
.get() .get()
@ -79,7 +86,7 @@ function generateCountryIndex() {
const lines = [] const lines = []
for (const country of [{ code: 'undefined' }, ...db.countries.sortBy(['name']).all()]) { for (const country of [{ code: 'undefined' }, ...db.countries.sortBy(['name']).all()]) {
const channels = db.channels const channels = db.channels
.sortBy(['name', 'url']) .sortBy(['name', 'status', 'resolution.height', 'url'], ['asc', 'asc', 'desc', 'asc'])
.forCountry(country) .forCountry(country)
.removeDuplicates() .removeDuplicates()
.removeNSFW() .removeNSFW()
@ -106,7 +113,7 @@ function generateLanguageIndex() {
const lines = [] const lines = []
for (const language of [{ code: 'undefined' }, ...db.languages.sortBy(['name']).all()]) { for (const language of [{ code: 'undefined' }, ...db.languages.sortBy(['name']).all()]) {
const channels = db.channels const channels = db.channels
.sortBy(['name', 'url']) .sortBy(['name', 'status', 'resolution.height', 'url'], ['asc', 'asc', 'desc', 'asc'])
.forLanguage(language) .forLanguage(language)
.removeDuplicates() .removeDuplicates()
.removeNSFW() .removeNSFW()
@ -133,7 +140,7 @@ function generateCategories() {
for (const category of [...db.categories.all(), { id: 'other' }]) { for (const category of [...db.categories.all(), { id: 'other' }]) {
const channels = db.channels const channels = db.channels
.sortBy(['name', 'url']) .sortBy(['name', 'status', 'resolution.height', 'url'], ['asc', 'asc', 'desc', 'asc'])
.forCategory(category) .forCategory(category)
.removeDuplicates() .removeDuplicates()
.removeOffline() .removeOffline()
@ -156,7 +163,7 @@ function generateCountries() {
for (const country of [...db.countries.all(), { code: 'undefined' }]) { for (const country of [...db.countries.all(), { code: 'undefined' }]) {
const channels = db.channels const channels = db.channels
.sortBy(['name', 'url']) .sortBy(['name', 'status', 'resolution.height', 'url'], ['asc', 'asc', 'desc', 'asc'])
.forCountry(country) .forCountry(country)
.removeDuplicates() .removeDuplicates()
.removeOffline() .removeOffline()
@ -180,7 +187,7 @@ function generateLanguages() {
for (const language of [...db.languages.all(), { code: 'undefined' }]) { for (const language of [...db.languages.all(), { code: 'undefined' }]) {
const channels = db.channels const channels = db.channels
.sortBy(['name', 'url']) .sortBy(['name', 'status', 'resolution.height', 'url'], ['asc', 'asc', 'desc', 'asc'])
.forLanguage(language) .forLanguage(language)
.removeDuplicates() .removeDuplicates()
.removeOffline() .removeOffline()
@ -201,7 +208,7 @@ function generateChannelsJson() {
log.print('Generating channels.json...\n') log.print('Generating channels.json...\n')
const filename = `${ROOT_DIR}/channels.json` const filename = `${ROOT_DIR}/channels.json`
const channels = db.channels const channels = db.channels
.sortBy(['name', 'url']) .sortBy(['name', 'status', 'resolution.height', 'url'], ['asc', 'asc', 'desc', 'asc'])
.get() .get()
.map(c => c.toObject()) .map(c => c.toObject())
file.create(filename, JSON.stringify(channels)) file.create(filename, JSON.stringify(channels))