mirror of
https://github.com/iptv-org/epg
synced 2025-12-16 10:26:41 -05:00
Expose more channel ids by looping through countryCodes
This commit is contained in:
@@ -34,24 +34,28 @@ module.exports = {
|
|||||||
async channels({ lang = 'en' }) {
|
async channels({ lang = 'en' }) {
|
||||||
const axios = require('axios')
|
const axios = require('axios')
|
||||||
const items = []
|
const items = []
|
||||||
let page = 0
|
const countryCodes = ['EG', 'SA', 'US']
|
||||||
while (true) {
|
for (let country of countryCodes) {
|
||||||
const result = await axios
|
let page = 0
|
||||||
.get(
|
while (true) {
|
||||||
`https://api2.shahid.net/proxy/v2.1/product/filter?filter=%7B"pageNumber":${page},"pageSize":100,"productType":"LIVESTREAM","productSubType":"LIVE_CHANNEL"%7D&country=SA&language=${lang}&Accept-Language=${lang}`
|
const result = await axios
|
||||||
)
|
.get(
|
||||||
.then(response => response.data)
|
`https://api2.shahid.net/proxy/v2.1/product/filter?filter=%7B"pageNumber":${page},"pageSize":100,"productType":"LIVESTREAM","productSubType":"LIVE_CHANNEL"%7D&country=${country}&language=${lang}&Accept-Language=${lang}`
|
||||||
.catch(console.error)
|
)
|
||||||
if (result.productList) {
|
.then(response => response.data)
|
||||||
items.push(...result.productList.products)
|
.catch(console.error)
|
||||||
if (result.productList.hasMore) {
|
if (result.productList) {
|
||||||
page++
|
items.push(...result.productList.products)
|
||||||
continue
|
if (result.productList.hasMore) {
|
||||||
|
page++
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
break
|
||||||
}
|
}
|
||||||
break
|
|
||||||
}
|
}
|
||||||
const channels = items.map(channel => {
|
const uniqueItems = Array.from(new Map(items.map(item => [item.id, item])).values())
|
||||||
|
const channels = uniqueItems.map(channel => {
|
||||||
return {
|
return {
|
||||||
lang,
|
lang,
|
||||||
site_id: channel.id,
|
site_id: channel.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user