From a1028fc6a872f10641cd302a4ab3e9c8c83611dd Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Thu, 6 Nov 2025 02:44:00 +0300 Subject: [PATCH] Update scripts --- scripts/commands/epg/grab.ts | 18 +++++++----------- scripts/core/index.ts | 1 - scripts/core/queue.ts | 18 ------------------ 3 files changed, 7 insertions(+), 30 deletions(-) delete mode 100644 scripts/core/queue.ts diff --git a/scripts/commands/epg/grab.ts b/scripts/commands/epg/grab.ts index cc858ae7..9ef58dc0 100644 --- a/scripts/commands/epg/grab.ts +++ b/scripts/commands/epg/grab.ts @@ -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() + 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() const programs = new Collection() 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 diff --git a/scripts/core/index.ts b/scripts/core/index.ts index fbe32262..687374da 100644 --- a/scripts/core/index.ts +++ b/scripts/core/index.ts @@ -1,3 +1,2 @@ export * from './htmlTable' export * from './utils' -export * from './queue' diff --git a/scripts/core/queue.ts b/scripts/core/queue.ts deleted file mode 100644 index 1237e5d0..00000000 --- a/scripts/core/queue.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Collection, Dictionary } from '@freearhey/core' -import { QueueItem } from '../types/queue' - -export class Queue { - #items: Dictionary = new Dictionary() - - add(key: string, data: QueueItem) { - this.#items.set(key, data) - } - - has(key: string): boolean { - return this.#items.has(key) - } - - getItems(): Collection { - return new Collection(Object.values(this.#items.data())) - } -}