[update] add @BellezaEmporium code

This commit is contained in:
Animenosekai 2024-08-27 18:01:09 +02:00
parent f641443a9d
commit 55ab874160

View file

@ -18,14 +18,24 @@ module.exports = {
url: function ({ date, channel }) {
let [type, ...code] = channel.site_id.split('_')
code = code.join('_')
console.log(`https://www.skyperfectv.co.jp/program/schedule/${type}/channel:${code}/date:${date.format('YYMMDD')}`)
return `https://www.skyperfectv.co.jp/program/schedule/${type}/channel:${code}/date:${date.format('YYMMDD')}`
},
logo: function ({channel}) {
logo: function ({ channel }) {
return `https://www.skyperfectv.co.jp/library/common/img/channel/icon/basic/m_${channel.site_id.toLowerCase()}.gif`
},
parser: function ({ content, date }) {
const $ = cheerio.load(content)
// Specific function that permits to gather NSFW channels (needs confirmation)
async fetchSchedule({ date, channel }) {
const url = this.url({ date, channel })
const response = await axios.get(url, {
headers: {
'Cookie': 'adult_auth=true'
}
})
return response.data
},
async parser({ date, channel }) {
const sched = await this.fetchSchedule({ date, channel })
const $ = cheerio.load(sched)
const programs = []
const sections = [
@ -39,26 +49,20 @@ module.exports = {
// `td` is a column for a day
// the next `td` will be the next day
const today = date.add(index + addition, 'd').tz('Asia/Tokyo')
const parseTime = (timeString) => {
// timeString is in the format "HH:mm"
// replace `today` with the time from timeString
const [hour, minute] = timeString.split(':').map(Number)
return today.hour(hour).minute(minute)
}
const $element = $(element) // Wrap element with Cheerio
$element.find('.p-program__item').each((itemIndex, itemElement) => {
const $itemElement = $(itemElement) // Wrap itemElement with Cheerio
const [start, stop] = $itemElement.find('.p-program__range').first().text().split('〜').map(parseTime)
const title = $itemElement.find('.p-program__name').first().text()
const image = $itemElement.find('.js-program_thumbnail').first().attr('data-lazysrc')
console.log({
title,
start,
stop,
image
})
programs.push({
title,
start,
@ -68,7 +72,7 @@ module.exports = {
})
})
})
return programs
},
async channels() {
@ -78,18 +82,22 @@ module.exports = {
const $ = cheerio.load(content)
const channels = []
$('.p-channel').each((index, element) => {
const site_id = `${type}_${$(element).find('.p-channel__id').text()}`
const name = $(element).find('.p-channel__name').text()
channels.push({ site_id, name, lang: 'ja' })
})
return channels
}
const getChannels = async (type) => {
const response = await axios.get(`https://www.skyperfectv.co.jp/program/schedule/${type}/`)
const response = await axios.get(`https://www.skyperfectv.co.jp/program/schedule/${type}/`, {
headers: {
'Cookie': 'adult_auth=true;'
}
})
return pageParser(response.data, type)
}
@ -102,4 +110,4 @@ module.exports = {
return await fetchAllChannels()
}
}
}