Update scripts

This commit is contained in:
freearhey
2025-11-06 02:44:00 +03:00
parent 597fda689d
commit a1028fc6a8
3 changed files with 7 additions and 30 deletions

View File

@@ -1,6 +1,6 @@
import { Logger, Timer, Collection, Template } from '@freearhey/core'
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 { Channel, Guide, Program } from '../../models'
import { SocksProxyAgent } from 'socks-proxy-agent'
@@ -187,9 +187,9 @@ async function main() {
await loadData()
logger.info('creating queue...')
let index = 0
const queue = new Queue()
const queue = new Collection<QueueItem>()
let index = 0
for (const channel of channelsFromXML.all()) {
channel.index = index++
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'))
dates.forEach((date: Dayjs) => {
const key = `${channel.site}:${channel.lang}:${channel.xmltv_id}:${date.toJSON()}`
if (queue.has(key)) return
queue.add(key, {
queue.add({
channel,
date,
config,
config: { ...config },
error: null
})
})
@@ -219,15 +217,13 @@ async function main() {
const taskQueue = new TaskQueue(Promise as PromisyClass, maxConnections)
const queueItems = queue.getItems()
const channels = new Collection<Channel>()
const programs = new Collection<Program>()
let i = 1
const total = queueItems.count()
const total = queue.count()
const requests = queueItems.map(
const requests = queue.map(
taskQueue.wrap(async (queueItem: QueueItem) => {
const { channel, config, date } = queueItem

View File

@@ -1,3 +1,2 @@
export * from './htmlTable'
export * from './utils'
export * from './queue'

View File

@@ -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()))
}
}