From 9e29c55e5561e338b7299dfc0303b9a04549d905 Mon Sep 17 00:00:00 2001 From: freearhey Date: Fri, 7 May 2021 18:34:09 +0300 Subject: [PATCH 1/5] Update parser.js --- scripts/parser.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/parser.js b/scripts/parser.js index 10bad2ca7..e91c14df7 100644 --- a/scripts/parser.js +++ b/scripts/parser.js @@ -3,6 +3,8 @@ const utils = require('./utils') const categories = require('./categories') const path = require('path') +const sfwCategories = categories.filter(c => !c.nsfw).map(c => c.name) + const parser = {} parser.parseIndex = function () { @@ -226,6 +228,10 @@ class Channel { } } } + + isSFW() { + return sfwCategories.includes(this.category) + } } module.exports = parser From cdcd0b090720b2adc4f3924cec99c8cbf0cf4b2d Mon Sep 17 00:00:00 2001 From: freearhey Date: Fri, 7 May 2021 18:34:14 +0300 Subject: [PATCH 2/5] Update generate.js --- scripts/generate.js | 285 +++++++++++++++++++++++--------------------- 1 file changed, 149 insertions(+), 136 deletions(-) diff --git a/scripts/generate.js b/scripts/generate.js index 369483ecd..9d18e342e 100644 --- a/scripts/generate.js +++ b/scripts/generate.js @@ -9,14 +9,13 @@ function main() { createRootDirectory() createNoJekyllFile() generateIndex() - generateSFWIndex() - generateChannelsJson() + generateCategoryIndex() generateCountryIndex() generateLanguageIndex() - generateCategoryIndex() generateCategories() generateLanguages() generateCountries() + generateChannelsJson() finish() } @@ -35,20 +34,163 @@ function generateIndex() { const filename = `${ROOT_DIR}/index.m3u` utils.createFile(filename, '#EXTM3U\n') + const sfwFilename = `${ROOT_DIR}/index.sfw.m3u` + utils.createFile(sfwFilename, '#EXTM3U\n') + const channels = db.channels.sortBy(['name', 'url']).all() for (const channel of channels) { utils.appendToFile(filename, channel.toString()) + if (channel.isSFW()) { + utils.appendToFile(sfwFilename, channel.toString()) + } } } -function generateSFWIndex() { - console.log('Generating index.sfw.m3u...') - const filename = `${ROOT_DIR}/index.sfw.m3u` +function generateCategoryIndex() { + console.log('Generating index.category.m3u...') + const filename = `${ROOT_DIR}/index.category.m3u` utils.createFile(filename, '#EXTM3U\n') - const channels = db.channels.sortBy(['name', 'url']).sfw() + const sfwFilename = `${ROOT_DIR}/index.category.sfw.m3u` + utils.createFile(sfwFilename, '#EXTM3U\n') + + const channels = db.channels.sortBy(['category', 'name', 'url']).all() for (const channel of channels) { utils.appendToFile(filename, channel.toString()) + if (channel.isSFW()) { + utils.appendToFile(sfwFilename, channel.toString()) + } + } +} + +function generateCountryIndex() { + console.log('Generating index.country.m3u...') + const filename = `${ROOT_DIR}/index.country.m3u` + utils.createFile(filename, '#EXTM3U\n') + + const sfwFilename = `${ROOT_DIR}/index.country.sfw.m3u` + utils.createFile(sfwFilename, '#EXTM3U\n') + + const unsorted = db.playlists.only(['unsorted'])[0] + for (const channel of unsorted.channels) { + const category = channel.category + const sfw = channel.isSFW() + channel.category = '' + utils.appendToFile(filename, channel.toString()) + if (sfw) { + utils.appendToFile(sfwFilename, channel.toString()) + } + channel.category = category + } + + const playlists = db.playlists.sortBy(['country']).except(['unsorted']) + for (const playlist of playlists) { + for (const channel of playlist.channels) { + const category = channel.category + const sfw = channel.isSFW() + channel.category = playlist.country + utils.appendToFile(filename, channel.toString()) + if (sfw) { + utils.appendToFile(sfwFilename, channel.toString()) + } + channel.category = category + } + } +} + +function generateLanguageIndex() { + console.log('Generating index.language.m3u...') + const filename = `${ROOT_DIR}/index.language.m3u` + utils.createFile(filename, '#EXTM3U\n') + + const sfwFilename = `${ROOT_DIR}/index.language.sfw.m3u` + utils.createFile(sfwFilename, '#EXTM3U\n') + + const channels = db.channels.sortBy(['name', 'url']).forLanguage({ code: null }).get() + for (const channel of channels) { + const category = channel.category + const sfw = channel.isSFW() + channel.category = '' + utils.appendToFile(filename, channel.toString()) + if (sfw) { + utils.appendToFile(sfwFilename, 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).get() + for (const channel of channels) { + const category = channel.category + const sfw = channel.isSFW() + channel.category = language.name + utils.appendToFile(filename, channel.toString()) + if (sfw) { + utils.appendToFile(sfwFilename, channel.toString()) + } + channel.category = category + } + } +} + +function generateCategories() { + console.log(`Generating /categories...`) + const outputDir = `${ROOT_DIR}/categories` + utils.createDir(outputDir) + + for (const category of [...db.categories.all(), { id: 'other' }]) { + const filename = `${outputDir}/${category.id}.m3u` + utils.createFile(filename, '#EXTM3U\n') + + const channels = db.channels.sortBy(['name', 'url']).forCategory(category).get() + for (const channel of channels) { + utils.appendToFile(filename, channel.toString()) + } + } +} + +function generateCountries() { + console.log(`Generating /countries...`) + const outputDir = `${ROOT_DIR}/countries` + utils.createDir(outputDir) + + for (const country of [...db.countries.all(), { code: 'undefined' }]) { + const filename = `${outputDir}/${country.code}.m3u` + utils.createFile(filename, '#EXTM3U\n') + + const sfwFilename = `${outputDir}/${country.code}.sfw.m3u` + utils.createFile(sfwFilename, '#EXTM3U\n') + + const channels = db.channels.sortBy(['name', 'url']).forCountry(country).get() + for (const channel of channels) { + utils.appendToFile(filename, channel.toString()) + if (channel.isSFW()) { + utils.appendToFile(sfwFilename, channel.toString()) + } + } + } +} + +function generateLanguages() { + console.log(`Generating /languages...`) + const outputDir = `${ROOT_DIR}/languages` + utils.createDir(outputDir) + + for (const language of [...db.languages.all(), { code: 'undefined' }]) { + const filename = `${outputDir}/${language.code}.m3u` + utils.createFile(filename, '#EXTM3U\n') + + const sfwFilename = `${outputDir}/${language.code}.sfw.m3u` + utils.createFile(sfwFilename, '#EXTM3U\n') + + const channels = db.channels.sortBy(['name', 'url']).forLanguage(language).get() + for (const channel of channels) { + utils.appendToFile(filename, channel.toString()) + if (channel.isSFW()) { + utils.appendToFile(sfwFilename, channel.toString()) + } + } } } @@ -62,135 +204,6 @@ function generateChannelsJson() { utils.createFile(filename, JSON.stringify(channels)) } -function generateCountryIndex() { - console.log('Generating index.country.m3u...') - const filename = `${ROOT_DIR}/index.country.m3u` - utils.createFile(filename, '#EXTM3U\n') - - const unsorted = db.playlists.only(['unsorted'])[0] - for (const channel of unsorted.channels) { - const category = channel.category - channel.category = '' - utils.appendToFile(filename, channel.toString()) - channel.category = category - } - - const playlists = db.playlists.sortBy(['country']).except(['unsorted']) - for (const playlist of playlists) { - for (const channel of playlist.channels) { - const category = channel.category - channel.category = playlist.country - utils.appendToFile(filename, channel.toString()) - channel.category = category - } - } -} - -function generateLanguageIndex() { - console.log('Generating index.language.m3u...') - const filename = `${ROOT_DIR}/index.language.m3u` - utils.createFile(filename, '#EXTM3U\n') - - const channels = db.channels.sortBy(['name', 'url']).forLanguage({ code: null }).get() - for (const channel of channels) { - const category = channel.category - 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).get() - for (const channel of channels) { - const category = channel.category - channel.category = language.name - utils.appendToFile(filename, channel.toString()) - channel.category = category - } - } -} - -function generateCategoryIndex() { - console.log('Generating index.category.m3u...') - const filename = `${ROOT_DIR}/index.category.m3u` - utils.createFile(filename, '#EXTM3U\n') - - const channels = db.channels.sortBy(['category', 'name', 'url']).all() - for (const channel of channels) { - utils.appendToFile(filename, channel.toString()) - } -} - -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).get() - 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 }).get() - utils.createFile(other, '#EXTM3U\n') - for (const channel of channels) { - utils.appendToFile(other, channel.toString()) - } -} - -function generateCountries() { - console.log(`Generating /countries...`) - const outputDir = `${ROOT_DIR}/countries` - utils.createDir(outputDir) - - 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']).forCountry(country).get() - for (const channel of channels) { - utils.appendToFile(filename, channel.toString()) - } - } - - const other = `${outputDir}/undefined.m3u` - const channels = db.channels.sortBy(['name', 'url']).forCountry({ code: null }).get() - 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` - utils.createDir(outputDir) - - 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']).forLanguage(language).get() - for (const channel of channels) { - utils.appendToFile(filename, channel.toString()) - } - } - - const other = `${outputDir}/undefined.m3u` - const channels = db.channels.sortBy(['name', 'url']).forLanguage({ code: null }).get() - utils.createFile(other, '#EXTM3U\n') - for (const channel of channels) { - utils.appendToFile(other, channel.toString()) - } -} - function finish() { console.log( `\nTotal: ${db.channels.count()} channels, ${db.countries.count()} countries, ${db.languages.count()} languages, ${db.categories.count()} categories.` From 919ba2f8c70399dd9cdd6707f9250fa608bda87b Mon Sep 17 00:00:00 2001 From: freearhey Date: Fri, 7 May 2021 18:34:20 +0300 Subject: [PATCH 3/5] Update db.js --- scripts/db.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/db.js b/scripts/db.js index 91795217e..e4072cbd0 100644 --- a/scripts/db.js +++ b/scripts/db.js @@ -2,6 +2,8 @@ const categories = require('./categories') const parser = require('./parser') const utils = require('./utils') +const sfwCategories = categories.filter(c => !c.nsfw).map(c => c.name) + const db = {} db.load = function () { @@ -38,7 +40,7 @@ db.channels = { if (this.filter) { switch (this.filter.field) { case 'countries': - if (!this.filter.value) { + if (this.filter.value === 'undefined') { output = this.list.filter(channel => !channel.countries.length) } else { output = this.list.filter(channel => @@ -47,7 +49,7 @@ db.channels = { } break case 'languages': - if (!this.filter.value) { + if (this.filter.value === 'undefined') { output = this.list.filter(channel => !channel.languages.length) } else { output = this.list.filter(channel => @@ -56,7 +58,7 @@ db.channels = { } break case 'category': - if (!this.filter.value) { + if (this.filter.value === 'other') { output = this.list.filter(channel => !channel.category) } else { output = this.list.filter( @@ -77,8 +79,6 @@ db.channels = { return this.list }, sfw() { - const sfwCategories = categories.filter(c => !c.nsfw).map(c => c.name) - return this.list.filter(i => sfwCategories.includes(i.category)) }, forCountry(country) { From bc3b4c40a8cf422182dd8924ac3680b387b6ef1a Mon Sep 17 00:00:00 2001 From: freearhey Date: Fri, 7 May 2021 18:36:03 +0300 Subject: [PATCH 4/5] Update template.md --- .readme/template.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.readme/template.md b/.readme/template.md index 23b268962..04398206e 100644 --- a/.readme/template.md +++ b/.readme/template.md @@ -9,7 +9,7 @@ Internet Protocol television (IPTV) is the delivery of television content over I ## Usage -To watch IPTV you just need to paste this link `https://iptv-org.github.io/iptv/index.m3u` to any player which supports M3U-playlists. You can also use the SFW version of the playlist `https://iptv-org.github.io/iptv/index.sfw.m3u`. +To watch IPTV you just need to paste this link `https://iptv-org.github.io/iptv/index.m3u` to any player which supports M3U-playlists. ![VLC Network Panel](.readme/preview.png) @@ -53,6 +53,9 @@ Or select one of the playlists from the list below. #include "./.readme/_countries.md" +
+ +Also each playlist has a "Safe For Work" version. In order to use it, just add `sfw` to the file name, like this: `https://iptv-org.github.io/iptv/countries/fr.sfw.m3u`. ## For Developers From 572a134eb0722ddba6485cba6a1a253214a4b1bf Mon Sep 17 00:00:00 2001 From: freearhey Date: Fri, 7 May 2021 18:50:31 +0300 Subject: [PATCH 5/5] Update template.md --- .readme/template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readme/template.md b/.readme/template.md index 04398206e..e08e7c9c5 100644 --- a/.readme/template.md +++ b/.readme/template.md @@ -55,7 +55,7 @@ Or select one of the playlists from the list below.
-Also each playlist has a "Safe For Work" version. In order to use it, just add `sfw` to the file name, like this: `https://iptv-org.github.io/iptv/countries/fr.sfw.m3u`. +NOTE: Add `.sfw` to the end of the filename for the lists without any adult channels (For example: `https://iptv-org.github.io/iptv/countries/fr.sfw.m3u`). ## For Developers