Update generate.js

This commit is contained in:
Aleksandr Statciuk 2021-08-06 07:49:43 +03:00
parent 546c8ff7b1
commit 04ed1bf955
1 changed files with 11 additions and 2 deletions

View File

@ -42,7 +42,7 @@ function generateIndex() {
const nsfwFilename = `${ROOT_DIR}/index.nsfw.m3u` const nsfwFilename = `${ROOT_DIR}/index.nsfw.m3u`
file.create(nsfwFilename, '#EXTM3U\n') file.create(nsfwFilename, '#EXTM3U\n')
const channels = db.channels.sortBy(['name', 'url']).removeDuplicates().get() const channels = db.channels.sortBy(['name', 'url']).removeDuplicates().removeOffline().get()
for (const channel of channels) { for (const channel of channels) {
if (!channel.isNSFW()) { if (!channel.isNSFW()) {
file.append(filename, channel.toString()) file.append(filename, channel.toString())
@ -56,7 +56,11 @@ function generateCategoryIndex() {
const filename = `${ROOT_DIR}/index.category.m3u` const filename = `${ROOT_DIR}/index.category.m3u`
file.create(filename, '#EXTM3U\n') file.create(filename, '#EXTM3U\n')
const channels = db.channels.sortBy(['category', 'name', 'url']).removeDuplicates().get() const channels = db.channels
.sortBy(['category', 'name', 'url'])
.removeDuplicates()
.removeOffline()
.get()
for (const channel of channels) { for (const channel of channels) {
file.append(filename, channel.toString()) file.append(filename, channel.toString())
} }
@ -72,6 +76,7 @@ function generateCountryIndex() {
.sortBy(['name', 'url']) .sortBy(['name', 'url'])
.forCountry(country) .forCountry(country)
.removeDuplicates() .removeDuplicates()
.removeOffline()
.get() .get()
for (const channel of channels) { for (const channel of channels) {
const groupTitle = channel.group.title const groupTitle = channel.group.title
@ -95,6 +100,7 @@ function generateLanguageIndex() {
.sortBy(['name', 'url']) .sortBy(['name', 'url'])
.forLanguage(language) .forLanguage(language)
.removeDuplicates() .removeDuplicates()
.removeOffline()
.get() .get()
for (const channel of channels) { for (const channel of channels) {
const groupTitle = channel.group.title const groupTitle = channel.group.title
@ -121,6 +127,7 @@ function generateCategories() {
.sortBy(['name', 'url']) .sortBy(['name', 'url'])
.forCategory(category) .forCategory(category)
.removeDuplicates() .removeDuplicates()
.removeOffline()
.get() .get()
for (const channel of channels) { for (const channel of channels) {
file.append(filename, channel.toString()) file.append(filename, channel.toString())
@ -141,6 +148,7 @@ function generateCountries() {
.sortBy(['name', 'url']) .sortBy(['name', 'url'])
.forCountry(country) .forCountry(country)
.removeDuplicates() .removeDuplicates()
.removeOffline()
.get() .get()
for (const channel of channels) { for (const channel of channels) {
if (!channel.isNSFW()) { if (!channel.isNSFW()) {
@ -163,6 +171,7 @@ function generateLanguages() {
.sortBy(['name', 'url']) .sortBy(['name', 'url'])
.forLanguage(language) .forLanguage(language)
.removeDuplicates() .removeDuplicates()
.removeOffline()
.get() .get()
for (const channel of channels) { for (const channel of channels) {
if (!channel.isNSFW()) { if (!channel.isNSFW()) {