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,11 +34,13 @@ module.exports = {
async channels({ lang = 'en' }) {
const axios = require('axios')
const items = []
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=SA&language=${lang}&Accept-Language=${lang}`
`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)
@@ -51,7 +53,9 @@ module.exports = {
}
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,