add channels scraping

This commit is contained in:
theofficialomega
2026-04-18 12:51:50 +02:00
parent c61db1071f
commit a0990513dd
2 changed files with 37 additions and 17 deletions
+23 -2
View File
@@ -98,8 +98,29 @@ module.exports = {
return programs
},
channels() {
return 'Website provides no proper channel list, channels must be added manually'
async channels() {
try {
const response = await axios.get('https://www.france.tv/chaines/')
const data = response.data || ''
const channels = []
const channelRegex =
/<button[^>]+aria-controls="[^"]*content-([a-z0-9-]+)"[\s\S]*?<title>([^<]+)<\/title>/gi
let match
while ((match = channelRegex.exec(data)) !== null) {
channels.push({
lang: 'fr',
site_id: match[1],
name: match[2].trim()
})
}
return [...new Map(channels.map(channel => [channel.site_id, channel])).values()]
} catch (error) {
console.error('Failed to fetch channels list:', error.message)
return []
}
}
}