Merge pull request #2070 from iptv-org/add-sfw-version

Add SFW version
This commit is contained in:
Aleksandr Statciuk 2021-01-27 19:00:38 +03:00 committed by GitHub
commit c24750cba8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 0 deletions

View File

@ -18,6 +18,8 @@ function main() {
createNoJekyllFile()
console.log('Generating index.m3u...')
generateIndex()
console.log('Generating index.sfw.m3u...')
generateSFWIndex()
console.log('Generating channels.json...')
generateChannels()
console.log('Generating index.country.m3u...')
@ -118,6 +120,17 @@ function generateIndex() {
}
}
function generateSFWIndex() {
const filename = `${ROOT_DIR}/index.sfw.m3u`
helper.createFile(filename, '#EXTM3U\n')
const sorted = helper.sortBy(list.all, ['name', 'url'])
const channels = helper.filterNSFW(sorted)
for (let channel of channels) {
helper.appendToFile(filename, channel.toString())
}
}
function generateChannels() {
const filename = `${ROOT_DIR}/channels.json`
const sorted = helper.sortBy(list.all, ['name', 'url'])

View File

@ -241,6 +241,41 @@ helper.filterGroup = function (groupTitle) {
return this.supportedCategories[groupTitle.toLowerCase()] || ''
}
helper.filterNSFW = function (arr) {
const sfwCategories = [
'Auto',
'Business',
'Classic',
'Comedy',
'Documentary',
'Education',
'Entertainment',
'Family',
'Fashion',
'Food',
'General',
'Health',
'History',
'Hobby',
'Kids',
'Legislative',
'Lifestyle',
'Local',
'Movies',
'Music',
'News',
'Quiz',
'Religious',
'Sci-Fi',
'Shop',
'Sport',
'Travel',
'Weather'
]
return arr.filter(i => sfwCategories.includes(i.category))
}
helper.sleep = function (ms) {
return function (x) {
return new Promise(resolve => setTimeout(() => resolve(x), ms))