mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-13 02:20:03 -04:00
Make code prettier
This commit is contained in:
parent
d9bef97c88
commit
97f0454d20
3 changed files with 115 additions and 72 deletions
|
@ -32,7 +32,11 @@ function main() {
|
|||
generateLanguages()
|
||||
console.log('Done.\n')
|
||||
|
||||
console.log(`Countries: ${Object.values(list.countries).length}. Languages: ${Object.values(list.languages).length}. Categories: ${Object.values(list.categories).length}. Channels: ${list.all.length}.`)
|
||||
console.log(
|
||||
`Countries: ${Object.values(list.countries).length}. Languages: ${
|
||||
Object.values(list.languages).length
|
||||
}. Categories: ${Object.values(list.categories).length}. Channels: ${list.all.length}.`
|
||||
)
|
||||
}
|
||||
|
||||
function createRootDirectory() {
|
||||
|
@ -50,12 +54,12 @@ function parseIndex() {
|
|||
let languages = {}
|
||||
let categories = {}
|
||||
|
||||
for(let rootItem of root.items) {
|
||||
for (let rootItem of root.items) {
|
||||
const playlist = helper.parsePlaylist(rootItem.url)
|
||||
const countryCode = helper.getBasename(rootItem.url).toLowerCase()
|
||||
const countryName = rootItem.name
|
||||
|
||||
for(let item of playlist.items) {
|
||||
for (let item of playlist.items) {
|
||||
const channel = helper.createChannel(item)
|
||||
channel.countryCode = countryCode
|
||||
channel.countryName = countryName
|
||||
|
@ -65,21 +69,21 @@ function parseIndex() {
|
|||
list.all.push(channel)
|
||||
|
||||
// country
|
||||
if(!countries[countryCode]) {
|
||||
if (!countries[countryCode]) {
|
||||
countries[countryCode] = []
|
||||
}
|
||||
countries[countryCode].push(channel)
|
||||
|
||||
// language
|
||||
const languageCode = helper.getISO6391Code(channel.language) || 'undefined'
|
||||
if(!languages[languageCode]) {
|
||||
if (!languages[languageCode]) {
|
||||
languages[languageCode] = []
|
||||
}
|
||||
languages[languageCode].push(channel)
|
||||
|
||||
// category
|
||||
const categoryCode = channel.group.toLowerCase() || 'other'
|
||||
if(!categories[categoryCode]) {
|
||||
if (!categories[categoryCode]) {
|
||||
categories[categoryCode] = []
|
||||
}
|
||||
categories[categoryCode].push(channel)
|
||||
|
@ -96,7 +100,7 @@ function generateIndex() {
|
|||
helper.createFile(filename, '#EXTM3U\n')
|
||||
|
||||
const channels = helper.sortBy(list.all, ['title', 'url'])
|
||||
for(let channel of channels) {
|
||||
for (let channel of channels) {
|
||||
helper.appendToFile(filename, channel.toString())
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +110,7 @@ function generateCountryIndex() {
|
|||
helper.createFile(filename, '#EXTM3U\n')
|
||||
|
||||
const channels = helper.sortBy(list.all, ['countryName', 'title', 'url'])
|
||||
for(let channel of channels) {
|
||||
for (let channel of channels) {
|
||||
const group = channel.group
|
||||
channel.group = channel.countryName
|
||||
helper.appendToFile(filename, channel.toString())
|
||||
|
@ -119,7 +123,7 @@ function generateLanguageIndex() {
|
|||
helper.createFile(filename, '#EXTM3U\n')
|
||||
|
||||
const channels = helper.sortBy(list.all, ['language', 'title', 'url'])
|
||||
for(let channel of channels) {
|
||||
for (let channel of channels) {
|
||||
const group = channel.group
|
||||
channel.group = channel.language
|
||||
helper.appendToFile(filename, channel.toString())
|
||||
|
@ -132,7 +136,7 @@ function generateCategoryIndex() {
|
|||
helper.createFile(filename, '#EXTM3U\n')
|
||||
|
||||
const channels = helper.sortBy(list.all, ['group', 'title', 'url'])
|
||||
for(let channel of channels) {
|
||||
for (let channel of channels) {
|
||||
helper.appendToFile(filename, channel.toString())
|
||||
}
|
||||
}
|
||||
|
@ -141,13 +145,13 @@ function generateCountries() {
|
|||
const outputDir = `${ROOT_DIR}/countries`
|
||||
helper.createDir(outputDir)
|
||||
|
||||
for(let cid in list.countries) {
|
||||
for (let cid in list.countries) {
|
||||
let country = list.countries[cid]
|
||||
const filename = `${outputDir}/${cid}.m3u`
|
||||
helper.createFile(filename, '#EXTM3U\n')
|
||||
|
||||
const channels = helper.sortBy(Object.values(country), ['title', 'url'])
|
||||
for(let channel of channels) {
|
||||
for (let channel of channels) {
|
||||
helper.appendToFile(filename, channel.toString())
|
||||
}
|
||||
}
|
||||
|
@ -157,13 +161,13 @@ function generateCategories() {
|
|||
const outputDir = `${ROOT_DIR}/categories`
|
||||
helper.createDir(outputDir)
|
||||
|
||||
for(let cid in list.categories) {
|
||||
for (let cid in list.categories) {
|
||||
let category = list.categories[cid]
|
||||
const filename = `${outputDir}/${cid}.m3u`
|
||||
helper.createFile(filename, '#EXTM3U\n')
|
||||
|
||||
const channels = helper.sortBy(Object.values(category), ['title', 'url'])
|
||||
for(let channel of channels) {
|
||||
for (let channel of channels) {
|
||||
helper.appendToFile(filename, channel.toString())
|
||||
}
|
||||
}
|
||||
|
@ -173,13 +177,13 @@ function generateLanguages() {
|
|||
const outputDir = `${ROOT_DIR}/languages`
|
||||
helper.createDir(outputDir)
|
||||
|
||||
for(let lid in list.languages) {
|
||||
for (let lid in list.languages) {
|
||||
let language = list.languages[lid]
|
||||
const filename = `${outputDir}/${lid}.m3u`
|
||||
helper.createFile(filename, '#EXTM3U\n')
|
||||
|
||||
const channels = helper.sortBy(Object.values(language), ['title', 'url'])
|
||||
for(let channel of channels) {
|
||||
for (let channel of channels) {
|
||||
helper.appendToFile(filename, channel.toString())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue