mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-12 10:00:05 -04:00
Create format.js
This commit is contained in:
parent
78038b9505
commit
4a8afcc0eb
1 changed files with 26 additions and 0 deletions
26
scripts/commands/playlist/format.js
Normal file
26
scripts/commands/playlist/format.js
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
const { create: createPlaylist } = require('../../core/playlist')
|
||||||
|
const { db, logger, file } = require('../../core')
|
||||||
|
const { orderBy } = require('natural-orderby')
|
||||||
|
const _ = require('lodash')
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
logger.info('loading streams...')
|
||||||
|
await db.streams.load()
|
||||||
|
let streams = await db.streams.find({})
|
||||||
|
|
||||||
|
logger.info('sorting links...')
|
||||||
|
streams = orderBy(
|
||||||
|
streams,
|
||||||
|
['channel', s => (s.channel ? '' : s.title), 'url'],
|
||||||
|
['asc', 'asc', 'asc']
|
||||||
|
)
|
||||||
|
|
||||||
|
logger.info('saving...')
|
||||||
|
const files = _.groupBy(streams, 'filepath')
|
||||||
|
for (const filepath in files) {
|
||||||
|
const playlist = createPlaylist(files[filepath], { public: false })
|
||||||
|
await file.create(filepath, playlist.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
Loading…
Add table
Add a link
Reference in a new issue