Skip all radio channels and duplicate channels

This commit is contained in:
Mahfud Harun 2024-09-02 23:45:05 +07:00
parent 270e85cfae
commit 1ccb266519
No known key found for this signature in database
GPG key ID: 4D347B8D6B2131A3

View file

@ -41,23 +41,30 @@ module.exports = {
.catch(console.error) .catch(console.error)
const $ = cheerio.load(result) const $ = cheerio.load(result)
const items = $('.home-content a').toArray() const itemGroups = $('.home-content').toArray()
const channels = [] const channels = []
items.forEach(item => { const processedIds = []
const $item = $(item)
const name = $item.find('p').text() itemGroups.forEach(group => {
if (name.toUpperCase().indexOf('FM') < 0 && name.toUpperCase().indexOf('RADIO') < 0) { const $group = $(group)
channels.push({ const props = $group.data('ahoy-props')
lang: 'id', const name = props.content_title
site_id: $item.attr('href').substr($item.attr('href').lastIndexOf('/') + 1).split('-')[0], const siteId = props.content_id
name
}) if (props.section.includes('Radio') || processedIds.includes(siteId)) {
return
} }
channels.push({
lang: 'id',
site_id: siteId,
name: name
})
processedIds.push(siteId)
}) })
return channels return channels
} }
} }
function parseStart($item, date) { function parseStart($item, date) {