mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update scripts
This commit is contained in:
parent
d681fcb3d5
commit
8e363d0e83
19 changed files with 562 additions and 141 deletions
39
scripts/core/dataProcessor.ts
Normal file
39
scripts/core/dataProcessor.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
import { DataLoaderData } from '../types/dataLoader'
|
||||
import { Collection } from '@freearhey/core'
|
||||
import { Channel, Feed, Guide, Stream } from '../models'
|
||||
|
||||
export class DataProcessor {
|
||||
constructor() {}
|
||||
|
||||
process(data: DataLoaderData) {
|
||||
let channels = new Collection(data.channels).map(data => new Channel(data))
|
||||
const channelsKeyById = channels.keyBy((channel: Channel) => channel.id)
|
||||
|
||||
const guides = new Collection(data.guides).map(data => new Guide(data))
|
||||
const guidesGroupedByStreamId = guides.groupBy((guide: Guide) => guide.getStreamId())
|
||||
|
||||
const streams = new Collection(data.streams).map(data => new Stream(data))
|
||||
const streamsGroupedById = streams.groupBy((stream: Stream) => stream.getId())
|
||||
|
||||
const feeds = new Collection(data.feeds).map(data =>
|
||||
new Feed(data)
|
||||
.withGuides(guidesGroupedByStreamId)
|
||||
.withStreams(streamsGroupedById)
|
||||
.withChannel(channelsKeyById)
|
||||
)
|
||||
const feedsGroupedByChannelId = feeds.groupBy((feed: Feed) => feed.channelId)
|
||||
|
||||
channels = channels.map((channel: Channel) => channel.withFeeds(feedsGroupedByChannelId))
|
||||
|
||||
return {
|
||||
feedsGroupedByChannelId,
|
||||
guidesGroupedByStreamId,
|
||||
streamsGroupedById,
|
||||
channelsKeyById,
|
||||
channels,
|
||||
streams,
|
||||
guides,
|
||||
feeds
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue