mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -04:00
Fixes linter errors
This commit is contained in:
parent
57e508fc3b
commit
63c86a2b30
393 changed files with 28447 additions and 28443 deletions
|
@ -1,70 +1,70 @@
|
|||
const cheerio = require('cheerio')
|
||||
const dayjs = require('dayjs')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
const _ = require('lodash')
|
||||
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(timezone)
|
||||
|
||||
module.exports = {
|
||||
site: 'streamingtvguides.com',
|
||||
days: 2,
|
||||
url({ channel }) {
|
||||
return `https://streamingtvguides.com/Channel/${channel.site_id}`
|
||||
},
|
||||
parser({ content, date }) {
|
||||
let programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
const $item = cheerio.load(item)
|
||||
const start = parseStart($item)
|
||||
if (!date.isSame(start, 'd')) return
|
||||
|
||||
programs.push({
|
||||
title: parseTitle($item),
|
||||
description: parseDescription($item),
|
||||
start,
|
||||
stop: parseStop($item)
|
||||
})
|
||||
})
|
||||
|
||||
programs = _.orderBy(_.uniqBy(programs, 'start'), 'start')
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseTitle($item) {
|
||||
return $item('.card-body > .prog-contains > .card-title')
|
||||
.clone()
|
||||
.children()
|
||||
.remove()
|
||||
.end()
|
||||
.text()
|
||||
.trim()
|
||||
}
|
||||
|
||||
function parseDescription($item) {
|
||||
return $item('.card-body > .card-text').clone().children().remove().end().text().trim()
|
||||
}
|
||||
|
||||
function parseStart($item) {
|
||||
const date = $item('.card-body').clone().children().remove().end().text().trim()
|
||||
const [time] = date.split(' - ')
|
||||
|
||||
return dayjs.tz(time, 'YYYY-MM-DD HH:mm:ss [PST]', 'PST').utc()
|
||||
}
|
||||
|
||||
function parseStop($item) {
|
||||
const date = $item('.card-body').clone().children().remove().end().text().trim()
|
||||
const [, time] = date.split(' - ')
|
||||
|
||||
return dayjs.tz(time, 'YYYY-MM-DD HH:mm:ss [PST]', 'PST').utc()
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const $ = cheerio.load(content)
|
||||
|
||||
return $('.container').toArray()
|
||||
}
|
||||
const cheerio = require('cheerio')
|
||||
const dayjs = require('dayjs')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
const _ = require('lodash')
|
||||
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(timezone)
|
||||
|
||||
module.exports = {
|
||||
site: 'streamingtvguides.com',
|
||||
days: 2,
|
||||
url({ channel }) {
|
||||
return `https://streamingtvguides.com/Channel/${channel.site_id}`
|
||||
},
|
||||
parser({ content, date }) {
|
||||
let programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
const $item = cheerio.load(item)
|
||||
const start = parseStart($item)
|
||||
if (!date.isSame(start, 'd')) return
|
||||
|
||||
programs.push({
|
||||
title: parseTitle($item),
|
||||
description: parseDescription($item),
|
||||
start,
|
||||
stop: parseStop($item)
|
||||
})
|
||||
})
|
||||
|
||||
programs = _.orderBy(_.uniqBy(programs, 'start'), 'start')
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseTitle($item) {
|
||||
return $item('.card-body > .prog-contains > .card-title')
|
||||
.clone()
|
||||
.children()
|
||||
.remove()
|
||||
.end()
|
||||
.text()
|
||||
.trim()
|
||||
}
|
||||
|
||||
function parseDescription($item) {
|
||||
return $item('.card-body > .card-text').clone().children().remove().end().text().trim()
|
||||
}
|
||||
|
||||
function parseStart($item) {
|
||||
const date = $item('.card-body').clone().children().remove().end().text().trim()
|
||||
const [time] = date.split(' - ')
|
||||
|
||||
return dayjs.tz(time, 'YYYY-MM-DD HH:mm:ss [PST]', 'PST').utc()
|
||||
}
|
||||
|
||||
function parseStop($item) {
|
||||
const date = $item('.card-body').clone().children().remove().end().text().trim()
|
||||
const [, time] = date.split(' - ')
|
||||
|
||||
return dayjs.tz(time, 'YYYY-MM-DD HH:mm:ss [PST]', 'PST').utc()
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const $ = cheerio.load(content)
|
||||
|
||||
return $('.container').toArray()
|
||||
}
|
||||
|
|
|
@ -1,55 +1,55 @@
|
|||
// npm run grab -- --site=streamingtvguides.com
|
||||
|
||||
const { parser, url } = require('./streamingtvguides.com.config.js')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
const date = dayjs.utc('2023-06-27', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: 'GMAPNY',
|
||||
xmltv_id: 'GMAPinoyTVUSACanada.ph'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel })).toBe('https://streamingtvguides.com/Channel/GMAPNY')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'), 'utf8')
|
||||
let results = parser({ content, date })
|
||||
results = results.map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results.length).toBe(38)
|
||||
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2023-06-27T00:40:00.000Z',
|
||||
stop: '2023-06-27T02:00:00.000Z',
|
||||
title: '24 Oras',
|
||||
description: 'Up to the minute news around the world.'
|
||||
})
|
||||
|
||||
expect(results[37]).toMatchObject({
|
||||
start: '2023-06-27T21:50:00.000Z',
|
||||
stop: '2023-06-28T00:00:00.000Z',
|
||||
title: 'Eat Bulaga',
|
||||
description: 'Rousing and engrossing segments with engaging hosts.'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'), 'utf8')
|
||||
const result = parser({
|
||||
date,
|
||||
content
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
// npm run grab -- --site=streamingtvguides.com
|
||||
|
||||
const { parser, url } = require('./streamingtvguides.com.config.js')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(utc)
|
||||
|
||||
const date = dayjs.utc('2023-06-27', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: 'GMAPNY',
|
||||
xmltv_id: 'GMAPinoyTVUSACanada.ph'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel })).toBe('https://streamingtvguides.com/Channel/GMAPNY')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'), 'utf8')
|
||||
let results = parser({ content, date })
|
||||
results = results.map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results.length).toBe(38)
|
||||
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2023-06-27T00:40:00.000Z',
|
||||
stop: '2023-06-27T02:00:00.000Z',
|
||||
title: '24 Oras',
|
||||
description: 'Up to the minute news around the world.'
|
||||
})
|
||||
|
||||
expect(results[37]).toMatchObject({
|
||||
start: '2023-06-27T21:50:00.000Z',
|
||||
stop: '2023-06-28T00:00:00.000Z',
|
||||
title: 'Eat Bulaga',
|
||||
description: 'Rousing and engrossing segments with engaging hosts.'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'), 'utf8')
|
||||
const result = parser({
|
||||
date,
|
||||
content
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue