Update sjonvarp.is

This commit is contained in:
freearhey 2023-11-27 13:59:26 +03:00
parent e7516fbed7
commit 83b4327a4c
4 changed files with 63 additions and 22 deletions

View file

@ -38,6 +38,32 @@ module.exports = {
})
return programs
},
async channels() {
const axios = require('axios')
const cheerio = require('cheerio')
const data = await axios
.get(`https://sjonvarp.is/`)
.then(r => r.data)
.catch(console.log)
let channels = []
const $ = cheerio.load(data)
$('.listing-row').each((i, el) => {
const site_id = $(el).attr('id')
const title = $(el).find('a.channel').first().attr('title')
const [, name] = title.match(/^Skoða dagskránna á (.*) í dag$/)
channels.push({
lang: 'is',
site_id,
name
})
})
return channels
}
}