mirror of
https://github.com/iptv-org/epg
synced 2025-12-17 10:56:57 -05:00
Update scripts
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { Logger, Timer, Collection, Template } from '@freearhey/core'
|
import { Logger, Timer, Collection, Template } from '@freearhey/core'
|
||||||
import epgGrabber, { EPGGrabber, EPGGrabberMock } from 'epg-grabber'
|
import epgGrabber, { EPGGrabber, EPGGrabberMock } from 'epg-grabber'
|
||||||
import { loadJs, parseProxy, Queue, parseNumber } from '../../core'
|
import { loadJs, parseProxy, parseNumber } from '../../core'
|
||||||
import { CurlBody } from 'curl-generator/dist/bodies/body'
|
import { CurlBody } from 'curl-generator/dist/bodies/body'
|
||||||
import { Channel, Guide, Program } from '../../models'
|
import { Channel, Guide, Program } from '../../models'
|
||||||
import { SocksProxyAgent } from 'socks-proxy-agent'
|
import { SocksProxyAgent } from 'socks-proxy-agent'
|
||||||
@@ -187,9 +187,9 @@ async function main() {
|
|||||||
await loadData()
|
await loadData()
|
||||||
|
|
||||||
logger.info('creating queue...')
|
logger.info('creating queue...')
|
||||||
let index = 0
|
const queue = new Collection<QueueItem>()
|
||||||
const queue = new Queue()
|
|
||||||
|
|
||||||
|
let index = 0
|
||||||
for (const channel of channelsFromXML.all()) {
|
for (const channel of channelsFromXML.all()) {
|
||||||
channel.index = index++
|
channel.index = index++
|
||||||
if (!channel.site || !channel.site_id || !channel.name) continue
|
if (!channel.site || !channel.site_id || !channel.name) continue
|
||||||
@@ -204,12 +204,10 @@ async function main() {
|
|||||||
const dates = Array.from({ length: days }, (_, day) => currDate.add(day, 'd'))
|
const dates = Array.from({ length: days }, (_, day) => currDate.add(day, 'd'))
|
||||||
|
|
||||||
dates.forEach((date: Dayjs) => {
|
dates.forEach((date: Dayjs) => {
|
||||||
const key = `${channel.site}:${channel.lang}:${channel.xmltv_id}:${date.toJSON()}`
|
queue.add({
|
||||||
if (queue.has(key)) return
|
|
||||||
queue.add(key, {
|
|
||||||
channel,
|
channel,
|
||||||
date,
|
date,
|
||||||
config,
|
config: { ...config },
|
||||||
error: null
|
error: null
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -219,15 +217,13 @@ async function main() {
|
|||||||
|
|
||||||
const taskQueue = new TaskQueue(Promise as PromisyClass, maxConnections)
|
const taskQueue = new TaskQueue(Promise as PromisyClass, maxConnections)
|
||||||
|
|
||||||
const queueItems = queue.getItems()
|
|
||||||
|
|
||||||
const channels = new Collection<Channel>()
|
const channels = new Collection<Channel>()
|
||||||
const programs = new Collection<Program>()
|
const programs = new Collection<Program>()
|
||||||
|
|
||||||
let i = 1
|
let i = 1
|
||||||
const total = queueItems.count()
|
const total = queue.count()
|
||||||
|
|
||||||
const requests = queueItems.map(
|
const requests = queue.map(
|
||||||
taskQueue.wrap(async (queueItem: QueueItem) => {
|
taskQueue.wrap(async (queueItem: QueueItem) => {
|
||||||
const { channel, config, date } = queueItem
|
const { channel, config, date } = queueItem
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,2 @@
|
|||||||
export * from './htmlTable'
|
export * from './htmlTable'
|
||||||
export * from './utils'
|
export * from './utils'
|
||||||
export * from './queue'
|
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
import { Collection, Dictionary } from '@freearhey/core'
|
|
||||||
import { QueueItem } from '../types/queue'
|
|
||||||
|
|
||||||
export class Queue {
|
|
||||||
#items: Dictionary<QueueItem> = new Dictionary<QueueItem>()
|
|
||||||
|
|
||||||
add(key: string, data: QueueItem) {
|
|
||||||
this.#items.set(key, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
has(key: string): boolean {
|
|
||||||
return this.#items.has(key)
|
|
||||||
}
|
|
||||||
|
|
||||||
getItems(): Collection<QueueItem> {
|
|
||||||
return new Collection<QueueItem>(Object.values(this.#items.data()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user