mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-12 01:50:04 -04:00
Update scripts
This commit is contained in:
parent
89b87ad5c8
commit
bb2935878d
16 changed files with 248 additions and 231 deletions
|
@ -1,36 +1,43 @@
|
|||
import { DATA_DIR } from '../../constants'
|
||||
import { Collection, Dictionary, IssueLoader, Storage } from '../../core'
|
||||
import { Blocked, Channel, Stream } from '../../models'
|
||||
import { DATA_DIR, STREAMS_DIR } from '../../constants'
|
||||
import { Collection, Dictionary, IssueLoader, Storage, Logger, PlaylistParser } from '../../core'
|
||||
import { Blocked, Channel, Issue, Stream } from '../../models'
|
||||
|
||||
async function main() {
|
||||
const logger = new Logger()
|
||||
const loader = new IssueLoader()
|
||||
|
||||
const storage = new Storage(DATA_DIR)
|
||||
|
||||
logger.info('loading channels from api...')
|
||||
const channelsContent = await storage.json('channels.json')
|
||||
const groupedChannels = new Collection(channelsContent)
|
||||
.map(data => new Channel(data))
|
||||
.groupBy((channel: Channel) => channel.id)
|
||||
|
||||
const streamsContent = await storage.json('streams.json')
|
||||
const groupedStreams = new Collection(streamsContent)
|
||||
.map(data => new Stream(data))
|
||||
.groupBy((stream: Stream) => stream.url)
|
||||
|
||||
logger.info('loading blocklist from api...')
|
||||
const blocklistContent = await storage.json('blocklist.json')
|
||||
const groupedBlocklist = new Collection(blocklistContent)
|
||||
.map(data => new Blocked(data))
|
||||
.groupBy((blocked: Blocked) => blocked.channel)
|
||||
|
||||
logger.info('loading streams...')
|
||||
const streamsStorage = new Storage(STREAMS_DIR)
|
||||
const parser = new PlaylistParser({ storage: streamsStorage })
|
||||
const files = await streamsStorage.list('**/*.m3u')
|
||||
const streams = await parser.parse(files)
|
||||
const groupedStreams = streams.groupBy((stream: Stream) => stream.url)
|
||||
|
||||
logger.info('loading issue from github...')
|
||||
const issues = await loader.load({ labels: ['streams:add'] })
|
||||
|
||||
logger.info('creating report...')
|
||||
const buffer = new Dictionary()
|
||||
const report = issues.map(data => {
|
||||
const channelId = data.get('channel_id') || undefined
|
||||
const streamUrl = data.get('stream_url') || undefined
|
||||
const report = issues.map((issue: Issue) => {
|
||||
const channelId = issue.data.get('channel_id') || undefined
|
||||
const streamUrl = issue.data.get('stream_url') || undefined
|
||||
|
||||
const result = new Dictionary({
|
||||
issueNumber: data.get('issue_number'),
|
||||
issueNumber: issue.number,
|
||||
channelId,
|
||||
status: undefined
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue