Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- name: Commit changed *.channels.xml files
if: steps.files.outputs.channels_any_changed == 'true'
run: |
git add streams
git add sites
git status
git commit -m "[Bot] Format *.channels.xml files" -m "Committed by [iptv-bot](https://github.com/apps/iptv-bot) via [format](https://github.com/iptv-org/epg/actions/runs/${{ github.run_id }}) workflow." --no-verify
- name: Push all changes to the repository
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/node_modules/
/temp/
/channels.xml
/custom.xml
/guide.xml
/guide.xml.gz
.secrets
Expand Down
18 changes: 7 additions & 11 deletions scripts/commands/epg/grab.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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
Expand All @@ -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
})
})
Expand All @@ -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

Expand Down
1 change: 0 additions & 1 deletion scripts/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './htmlTable'
export * from './utils'
export * from './queue'
18 changes: 0 additions & 18 deletions scripts/core/queue.ts

This file was deleted.

12 changes: 5 additions & 7 deletions tests/__data__/expected/epg_grab/custom_channels.guide.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
<channel id="Channel1.us"><display-name>Channel 1</display-name><icon src="https://i.imgur.com/GPzH88J.png"/><url>https://example2.com</url></channel>
<channel id="Channel4.us@HD"><display-name>Channel 4</display-name><icon src="https://i.imgur.com/BPzH88J.png"/><url>https://example2.com</url></channel>
<channel id="Channel3.us@Wrong"><display-name>Channel 3</display-name><icon src="https://upload.wikimedia.org/wikipedia/commons/6/64/6%27eren_2015.png"/><url>https://example2.com</url></channel>
<channel id="Channel1.us"><display-name>Channel 1</display-name><icon src="https://i.imgur.com/GPzH88J.png"/><url>https://example.com</url></channel>
<channel id="140"><display-name>Channel 1</display-name><url>https://example.com</url></channel>
<channel id="Channel2.us"><display-name>Custom Channel 2</display-name><icon src="https://i.imgur.com/qmRnD0M.png"/><url>https://example.com</url></channel>
<programme start="20221020043100 +0000" stop="20221020071000 +0000" channel="Channel1.us"><title lang="en">Program1 (example2.com)</title></programme>
<programme start="20221021043100 +0000" stop="20221021071000 +0000" channel="Channel1.us"><title lang="en">Program1 (example2.com)</title></programme>
<programme start="20221020043100 +0000" stop="20221020071000 +0000" channel="Channel1.us"><title lang="en">Program1 (example.com)</title></programme>
<programme start="20221021043100 +0000" stop="20221021071000 +0000" channel="Channel1.us"><title lang="en">Program1 (example.com)</title></programme>
<programme start="20221021044000 +0000" stop="20221021071000 +0000" channel="Channel1.us"><title lang="fr">Programme1 (example2.com)</title></programme>
<programme start="20221020044000 +0000" stop="20221020071000 +0000" channel="Channel1.us"><title lang="fr">Programme1 (example2.com)</title></programme>
<programme start="20221021043100 +0000" stop="20221021071000 +0000" channel="Channel4.us@HD"><title lang="en">Program1 (example2.com)</title></programme>
<programme start="20221020043100 +0000" stop="20221020071000 +0000" channel="Channel4.us@HD"><title lang="en">Program1 (example2.com)</title></programme>
<programme start="20221021043100 +0000" stop="20221021071000 +0000" channel="Channel3.us@Wrong"><title lang="en">Program1 (example2.com)</title></programme>
<programme start="20221020043100 +0000" stop="20221020071000 +0000" channel="Channel3.us@Wrong"><title lang="en">Program1 (example2.com)</title></programme>
<programme start="20221021044000 +0000" stop="20221021071000 +0000" channel="Channel1.us"><title lang="fr">Programme1 (example2.com)</title></programme>
<programme start="20221020044000 +0000" stop="20221020071000 +0000" channel="Channel1.us"><title lang="fr">Programme1 (example2.com)</title></programme>
<programme start="20221021043100 +0000" stop="20221021071000 +0000" channel="Channel2.us"><title lang="en">Program1 (example2.com)</title></programme>
<programme start="20221020043100 +0000" stop="20221020071000 +0000" channel="Channel2.us"><title lang="en">Program1 (example2.com)</title></programme>
<programme start="20221021043000 +0000" stop="20221021071000 +0000" channel="140"><title lang="fr">Programme1 (example.com)</title></programme>
<programme start="20221020043000 +0000" stop="20221020071000 +0000" channel="140"><title lang="fr">Programme1 (example.com)</title></programme>
</tv>
14 changes: 6 additions & 8 deletions tests/__data__/expected/epg_grab/multiple_channels.guide.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@
<channel id="Channel3.us"><display-name>Channel 3</display-name><icon src="https://upload.wikimedia.org/wikipedia/commons/6/64/6%27eren_2015.png"/><url>https://example.com</url></channel>
<channel id="140"><display-name>Channel 1</display-name><url>https://example.com</url></channel>
<channel id="Channel2.us"><display-name>Channel 2</display-name><icon src="https://i.imgur.com/qmRnD0M.png"/><url>https://example.com</url><lcn>36</lcn></channel>
<programme start="20221020043100 +0000" stop="20221020071000 +0000" channel="Channel1.us@HD"><title lang="en">Program1 (example2.com)</title></programme>
<programme start="20221021043100 +0000" stop="20221021071000 +0000" channel="Channel1.us@HD"><title lang="en">Program1 (example2.com)</title></programme>
<programme start="20221020043100 +0000" stop="20221020071000 +0000" channel="Channel1.us@HD"><title lang="en">Program1 (example.com)</title></programme>
<programme start="20221021043100 +0000" stop="20221021071000 +0000" channel="Channel1.us@HD"><title lang="en">Program1 (example.com)</title></programme>
<programme start="20221021044000 +0000" stop="20221021071000 +0000" channel="Channel1.us"><title lang="fr">Programme1 (example2.com)</title></programme>
<programme start="20221020044000 +0000" stop="20221020071000 +0000" channel="Channel1.us"><title lang="fr">Programme1 (example2.com)</title></programme>
<programme start="20221021043100 +0000" stop="20221021071000 +0000" channel="Channel4.us@HD"><title lang="en">Program1 (example2.com)</title></programme>
<programme start="20221020043100 +0000" stop="20221020071000 +0000" channel="Channel4.us@HD"><title lang="en">Program1 (example2.com)</title></programme>
<programme start="20221021043100 +0000" stop="20221021071000 +0000" channel="Channel3.us"><title lang="en">Program1 (example2.com)</title></programme>
<programme start="20221020043100 +0000" stop="20221020071000 +0000" channel="Channel3.us"><title lang="en">Program1 (example2.com)</title></programme>
<programme start="20221021043100 +0000" stop="20221021071000 +0000" channel="Channel3.us"><title lang="it">Program1 (example2.com)</title></programme>
<programme start="20221020043100 +0000" stop="20221020071000 +0000" channel="Channel3.us"><title lang="it">Program1 (example2.com)</title></programme>
<programme start="20221021044000 +0000" stop="20221021071000 +0000" channel="140"><title lang="fr">Programme1 (example2.com)</title></programme>
<programme start="20221020044000 +0000" stop="20221020071000 +0000" channel="140"><title lang="fr">Programme1 (example2.com)</title></programme>
<programme start="20221021043100 +0000" stop="20221021071000 +0000" channel="Channel2.us"><title lang="en">Program1 (example2.com)</title></programme>
<programme start="20221020043100 +0000" stop="20221020071000 +0000" channel="Channel2.us"><title lang="en">Program1 (example2.com)</title></programme>
<programme start="20221021043100 +0000" stop="20221021071000 +0000" channel="Channel3.us"><title lang="it">Program1 (example.com)</title></programme>
<programme start="20221020043100 +0000" stop="20221020071000 +0000" channel="Channel3.us"><title lang="it">Program1 (example.com)</title></programme>
<programme start="20221021043000 +0000" stop="20221021071000 +0000" channel="140"><title lang="fr">Programme1 (example.com)</title></programme>
<programme start="20221020043000 +0000" stop="20221020071000 +0000" channel="140"><title lang="fr">Programme1 (example.com)</title></programme>
</tv>
2 changes: 1 addition & 1 deletion tests/__data__/input/epg_grab/custom.channels.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<channels>
<channel site="example.com" lang="en" xmltv_id="Channel1.us" site_id="140">Custom Channel 1</channel>
<channel site="example.com" lang="en" xmltv_id="Channel2.us" site_id="142" logo="https://i.imgur.com/qmRnD0M.png">Custom Channel 2</channel>
<channel site="example.com" lang="fr" xmltv_id="Channel1.us" site_id="140">Channel 1</channel>
<channel site="example.com" lang="fr" xmltv_id="" site_id="140">Channel 1</channel>
<channel site="example2.com" lang="en" xmltv_id="Channel3.us@Wrong" site_id="150">Channel 3</channel>
<channel site="example2.com" lang="en" xmltv_id="Channel4.us@HD" site_id="152">Channel 4</channel>
<channel site="example2.com" lang="fr" xmltv_id="Channel1.us" site_id="140">Channel 1</channel>
Expand Down