Update generate.js

Removed extra check
This commit is contained in:
freearhey 2021-04-24 16:11:19 +03:00
parent f5dc1387ce
commit ed490849fb
1 changed files with 16 additions and 33 deletions

View File

@ -41,11 +41,9 @@ function generateIndex() {
const info = channel.getInfo()
if (!buffer.includes(info)) {
utils.appendToFile(filename, channel.toString())
if (channel.filename !== 'unsorted') {
buffer.push(info)
}
}
}
}
function generateSFWIndex() {
@ -59,11 +57,9 @@ function generateSFWIndex() {
const info = channel.getInfo()
if (!buffer.includes(info)) {
utils.appendToFile(filename, channel.toString())
if (channel.filename !== 'unsorted') {
buffer.push(info)
}
}
}
}
function generateChannelsJson() {
@ -81,15 +77,19 @@ function generateCountryIndex() {
const filename = `${ROOT_DIR}/index.country.m3u`
utils.createFile(filename, '#EXTM3U\n')
const buffer = []
const unsorted = db.playlists.only(['unsorted'])[0]
for (const channel of unsorted.channels) {
const category = channel.category
channel.category = ''
const info = channel.getInfo()
if (!buffer.includes(info)) {
utils.appendToFile(filename, channel.toString())
buffer.push(info)
}
channel.category = category
}
const buffer = []
const playlists = db.playlists.sortBy(['country']).except(['unsorted'])
for (const playlist of playlists) {
for (const channel of playlist.channels) {
@ -118,16 +118,13 @@ function generateLanguageIndex() {
const info = channel.getInfo()
if (!buffer.includes(info)) {
utils.appendToFile(filename, channel.toString())
if (channel.filename !== 'unsorted') {
buffer.push(info)
}
}
channel.category = category
}
const languages = db.languages.sortBy(['name']).all()
for (const language of languages) {
const buffer = []
const channels = db.channels.sortBy(['name', 'url']).forLanguage(language).get()
for (const channel of channels) {
const category = channel.category
@ -153,11 +150,9 @@ function generateCategoryIndex() {
const info = channel.getInfo()
if (!buffer.includes(info)) {
utils.appendToFile(filename, channel.toString())
if (channel.filename !== 'unsorted') {
buffer.push(info)
}
}
}
}
function generateCategories() {
@ -175,12 +170,10 @@ function generateCategories() {
const info = channel.getInfo()
if (!buffer.includes(info)) {
utils.appendToFile(filename, channel.toString())
if (channel.filename !== 'unsorted') {
buffer.push(info)
}
}
}
}
const buffer = []
const other = `${outputDir}/other.m3u`
@ -190,11 +183,9 @@ function generateCategories() {
const info = channel.getInfo()
if (!buffer.includes(info)) {
utils.appendToFile(other, channel.toString())
if (channel.filename !== 'unsorted') {
buffer.push(info)
}
}
}
}
function generateCountries() {
@ -212,12 +203,10 @@ function generateCountries() {
const info = channel.getInfo()
if (!buffer.includes(info)) {
utils.appendToFile(filename, channel.toString())
if (channel.filename !== 'unsorted') {
buffer.push(info)
}
}
}
}
const buffer = []
const other = `${outputDir}/undefined.m3u`
@ -227,11 +216,9 @@ function generateCountries() {
const info = channel.getInfo()
if (!buffer.includes(info)) {
utils.appendToFile(other, channel.toString())
if (channel.filename !== 'unsorted') {
buffer.push(info)
}
}
}
}
function generateLanguages() {
@ -249,12 +236,10 @@ function generateLanguages() {
const info = channel.getInfo()
if (!buffer.includes(info)) {
utils.appendToFile(filename, channel.toString())
if (channel.filename !== 'unsorted') {
buffer.push(info)
}
}
}
}
const buffer = []
const other = `${outputDir}/undefined.m3u`
@ -264,11 +249,9 @@ function generateLanguages() {
const info = channel.getInfo()
if (!buffer.includes(info)) {
utils.appendToFile(other, channel.toString())
if (channel.filename !== 'unsorted') {
buffer.push(info)
}
}
}
}
function finish() {