Expose more channel ids by looping through countryCodes

This commit is contained in:
CasperMcFadden95
2025-09-06 20:00:40 +00:00
committed by GitHub
parent baacb043c7
commit 9b73643070

View File

@@ -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,