Fixes linter errors

This commit is contained in:
freearhey
2023-10-15 14:08:23 +03:00
parent 57e508fc3b
commit 63c86a2b30
393 changed files with 28447 additions and 28443 deletions

View File

@@ -1,77 +1,77 @@
const _ = require('lodash')
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
const timezone = require('dayjs/plugin/timezone')
dayjs.extend(utc)
dayjs.extend(timezone)
// category list is not complete
// const categories = {
// '00': 'Diğer',
// E0: 'Romantik Komedi',
// E1: 'Aksiyon',
// E4: 'Macera',
// E5: 'Dram',
// E6: 'Fantastik',
// E7: 'Komedi',
// E8: 'Korku',
// EB: 'Polisiye',
// EF: 'Western',
// FA: 'Macera',
// FB: 'Yarışma',
// FC: 'Eğlence',
// F0: 'Reality-Show',
// F2: 'Haberler',
// F4: 'Belgesel',
// F6: 'Eğitim',
// F7: 'Sanat ve Kültür',
// F9: 'Life Style'
// }
module.exports = {
site: 'digiturk.com.tr',
days: 2,
url: function ({ date, channel }) {
return `https://www.digiturk.com.tr/_Ajax/getBroadcast.aspx?channelNo=${
channel.site_id
}&date=${date.format('DD.MM.YYYY')}&tomorrow=false&primetime=false`
},
request: {
method: 'GET',
headers: {
Referer: 'https://www.digiturk.com.tr/'
}
},
parser: function ({ content }) {
let programs = []
const items = parseItems(content)
items.forEach(item => {
programs.push({
title: item.PName,
// description: item.LongDescription,
// category: parseCategory(item),
start: parseTime(item.PStartTime),
stop: parseTime(item.PEndTime)
})
})
programs = _.sortBy(programs, 'start')
return programs
}
}
function parseTime(time) {
let timestamp = parseInt(time.replace('/Date(', '').replace('+0300)/', ''))
return dayjs(timestamp)
}
// function parseCategory(item) {
// return (item.PGenre) ? categories[item.PGenre] : null
// }
function parseItems(content) {
if (!content) return []
const data = JSON.parse(content)
return data && data.BChannels && data.BChannels[0].CPrograms ? data.BChannels[0].CPrograms : []
}
const _ = require('lodash')
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
const timezone = require('dayjs/plugin/timezone')
dayjs.extend(utc)
dayjs.extend(timezone)
// category list is not complete
// const categories = {
// '00': 'Diğer',
// E0: 'Romantik Komedi',
// E1: 'Aksiyon',
// E4: 'Macera',
// E5: 'Dram',
// E6: 'Fantastik',
// E7: 'Komedi',
// E8: 'Korku',
// EB: 'Polisiye',
// EF: 'Western',
// FA: 'Macera',
// FB: 'Yarışma',
// FC: 'Eğlence',
// F0: 'Reality-Show',
// F2: 'Haberler',
// F4: 'Belgesel',
// F6: 'Eğitim',
// F7: 'Sanat ve Kültür',
// F9: 'Life Style'
// }
module.exports = {
site: 'digiturk.com.tr',
days: 2,
url: function ({ date, channel }) {
return `https://www.digiturk.com.tr/_Ajax/getBroadcast.aspx?channelNo=${
channel.site_id
}&date=${date.format('DD.MM.YYYY')}&tomorrow=false&primetime=false`
},
request: {
method: 'GET',
headers: {
Referer: 'https://www.digiturk.com.tr/'
}
},
parser: function ({ content }) {
let programs = []
const items = parseItems(content)
items.forEach(item => {
programs.push({
title: item.PName,
// description: item.LongDescription,
// category: parseCategory(item),
start: parseTime(item.PStartTime),
stop: parseTime(item.PEndTime)
})
})
programs = _.sortBy(programs, 'start')
return programs
}
}
function parseTime(time) {
let timestamp = parseInt(time.replace('/Date(', '').replace('+0300)/', ''))
return dayjs(timestamp)
}
// function parseCategory(item) {
// return (item.PGenre) ? categories[item.PGenre] : null
// }
function parseItems(content) {
if (!content) return []
const data = JSON.parse(content)
return data && data.BChannels && data.BChannels[0].CPrograms ? data.BChannels[0].CPrograms : []
}

View File

@@ -1,49 +1,49 @@
// npm run grab -- --site=digiturk.com.tr
const { parser, url } = require('./digiturk.com.tr.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-01-19', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '14',
xmltv_id: 'beINMovies2Action.qa'
}
it('can generate valid url', () => {
const result = url({ date, channel })
expect(result).toBe(
'https://www.digiturk.com.tr/_Ajax/getBroadcast.aspx?channelNo=14&date=19.01.2023&tomorrow=false&primetime=false'
)
})
it('can parse response', () => {
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
const results = parser({ content }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(results[0]).toMatchObject({
start: '2023-01-18T20:40:00.000Z',
stop: '2023-01-18T22:32:00.000Z',
title: 'PARÇALANMIŞ'
})
expect(results[10]).toMatchObject({
start: '2023-01-19T05:04:00.000Z',
stop: '2023-01-19T06:42:00.000Z',
title: 'HIZLI VE ÖFKELİ: TOKYO YARIŞI'
})
})
it('can handle empty guide', () => {
const result = parser({ content: '' })
expect(result).toMatchObject([])
})
// npm run grab -- --site=digiturk.com.tr
const { parser, url } = require('./digiturk.com.tr.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-01-19', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '14',
xmltv_id: 'beINMovies2Action.qa'
}
it('can generate valid url', () => {
const result = url({ date, channel })
expect(result).toBe(
'https://www.digiturk.com.tr/_Ajax/getBroadcast.aspx?channelNo=14&date=19.01.2023&tomorrow=false&primetime=false'
)
})
it('can parse response', () => {
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
const results = parser({ content }).map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(results[0]).toMatchObject({
start: '2023-01-18T20:40:00.000Z',
stop: '2023-01-18T22:32:00.000Z',
title: 'PARÇALANMIŞ'
})
expect(results[10]).toMatchObject({
start: '2023-01-19T05:04:00.000Z',
stop: '2023-01-19T06:42:00.000Z',
title: 'HIZLI VE ÖFKELİ: TOKYO YARIŞI'
})
})
it('can handle empty guide', () => {
const result = parser({ content: '' })
expect(result).toMatchObject([])
})