Merge pull request #2862 from iptv-org/shahid-country-code

Shahid: Expose more channel ids by looping through countryCodes
This commit is contained in:
Ismaël Moret
2025-09-28 09:41:09 +02:00
committed by GitHub
4 changed files with 55 additions and 58 deletions

View File

@@ -34,24 +34,28 @@ module.exports = {
async channels({ lang = 'en' }) {
const axios = require('axios')
const items = []
let page = 0
while (true) {
const result = await axios
.get(
`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}`
)
.then(response => response.data)
.catch(console.error)
if (result.productList) {
items.push(...result.productList.products)
if (result.productList.hasMore) {
page++
continue
const countryCodes = ['EG', 'SA', 'US']
for (let country of countryCodes) {
let page = 0
while (true) {
const result = await axios
.get(
`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}`
)
.then(response => response.data)
.catch(console.error)
if (result.productList) {
items.push(...result.productList.products)
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 {
lang,
site_id: channel.id,