mirror of
https://github.com/iptv-org/epg
synced 2026-04-28 21:46:58 -04:00
Fixes linter errors
This commit is contained in:
@@ -1,74 +1,74 @@
|
||||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(customParseFormat)
|
||||
|
||||
module.exports = {
|
||||
site: 'tvplus.com.tr',
|
||||
days: 2,
|
||||
url: 'https://izmottvsc23.tvplus.com.tr:33207/EPG/JSON/PlayBillList',
|
||||
request: {
|
||||
method: 'POST',
|
||||
async headers() {
|
||||
const response = await axios
|
||||
.post('https://izmottvsc23.tvplus.com.tr:33207/EPG/JSON/Authenticate', {
|
||||
terminaltype: 'WEBTV_WIDEVINE',
|
||||
userType: '3',
|
||||
timezone: 'UTC'
|
||||
})
|
||||
.catch(console.log)
|
||||
const cookie = Array.isArray(response.headers['set-cookie'])
|
||||
? response.headers['set-cookie'].join('; ')
|
||||
: ''
|
||||
|
||||
return { cookie }
|
||||
},
|
||||
data({ date, channel }) {
|
||||
return {
|
||||
type: '2',
|
||||
channelid: channel.site_id,
|
||||
begintime: date.format('YYYYMMDDHHmmss'),
|
||||
endtime: date.add(1, 'd').format('YYYYMMDDHHmmss')
|
||||
}
|
||||
}
|
||||
},
|
||||
parser: function ({ content }) {
|
||||
let programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
const start = parseStart(item)
|
||||
const stop = parseStop(item)
|
||||
programs.push({
|
||||
title: item.name,
|
||||
category: item.genres,
|
||||
description: item.introduce,
|
||||
icon: parseIcon(item),
|
||||
start: start.toJSON(),
|
||||
stop: stop.toJSON()
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseIcon(item) {
|
||||
return item.pictures && item.pictures.length ? item.pictures[0].href : null
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.utc(item.starttime, 'YYYYMMDDHHmmss')
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
return dayjs.utc(item.endtime, 'YYYYMMDDHHmmss')
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const data = JSON.parse(content)
|
||||
|
||||
return data.playbilllist || []
|
||||
}
|
||||
const axios = require('axios')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(customParseFormat)
|
||||
|
||||
module.exports = {
|
||||
site: 'tvplus.com.tr',
|
||||
days: 2,
|
||||
url: 'https://izmottvsc23.tvplus.com.tr:33207/EPG/JSON/PlayBillList',
|
||||
request: {
|
||||
method: 'POST',
|
||||
async headers() {
|
||||
const response = await axios
|
||||
.post('https://izmottvsc23.tvplus.com.tr:33207/EPG/JSON/Authenticate', {
|
||||
terminaltype: 'WEBTV_WIDEVINE',
|
||||
userType: '3',
|
||||
timezone: 'UTC'
|
||||
})
|
||||
.catch(console.log)
|
||||
const cookie = Array.isArray(response.headers['set-cookie'])
|
||||
? response.headers['set-cookie'].join('; ')
|
||||
: ''
|
||||
|
||||
return { cookie }
|
||||
},
|
||||
data({ date, channel }) {
|
||||
return {
|
||||
type: '2',
|
||||
channelid: channel.site_id,
|
||||
begintime: date.format('YYYYMMDDHHmmss'),
|
||||
endtime: date.add(1, 'd').format('YYYYMMDDHHmmss')
|
||||
}
|
||||
}
|
||||
},
|
||||
parser: function ({ content }) {
|
||||
let programs = []
|
||||
const items = parseItems(content)
|
||||
items.forEach(item => {
|
||||
const start = parseStart(item)
|
||||
const stop = parseStop(item)
|
||||
programs.push({
|
||||
title: item.name,
|
||||
category: item.genres,
|
||||
description: item.introduce,
|
||||
icon: parseIcon(item),
|
||||
start: start.toJSON(),
|
||||
stop: stop.toJSON()
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseIcon(item) {
|
||||
return item.pictures && item.pictures.length ? item.pictures[0].href : null
|
||||
}
|
||||
|
||||
function parseStart(item) {
|
||||
return dayjs.utc(item.starttime, 'YYYYMMDDHHmmss')
|
||||
}
|
||||
|
||||
function parseStop(item) {
|
||||
return dayjs.utc(item.endtime, 'YYYYMMDDHHmmss')
|
||||
}
|
||||
|
||||
function parseItems(content) {
|
||||
const data = JSON.parse(content)
|
||||
|
||||
return data.playbilllist || []
|
||||
}
|
||||
|
||||
@@ -1,55 +1,55 @@
|
||||
// npm run grab -- --site=tvplus.com.tr
|
||||
|
||||
const { parser, url, request } = require('./tvplus.com.tr.config.js')
|
||||
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('2021-11-07', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '32',
|
||||
xmltv_id: '24TV.tr'
|
||||
}
|
||||
const content =
|
||||
'{"counttotal":"23","playbilllist":[{"country":"","starttime":"20211107000000","type":"PROGRAM","isBlackout":"0","rerun":"0","ppvsubscribed":"0","foreignsn":"134383557","isLive":"0","ratingid":"0","episodeTotalCount":"0","id":"134383557","keyword":"24 Portre","contentType":"0","isnpvr":"1","slsType":"0","iscpvr":"0","advisory":[],"genreIds":["1179"],"istvod":"0","name":"24 Portre","tvodStatus":"0","pictures":[{"href":"https://izmottvsc23.tvplus.com.tr:33207/CPS/images/universal/film/program/202111/20211104/35/20211104000026695lh5.jpg","resolution":["null","null"],"imageType":"0"}],"externalContentCode":"105445035962202111070300","genres":"Yaşam","visittimes":"0","issubscribed":"0","programType":"program","gapFiller":"0","introduce":"Kendi alanında büyük başarılar elde etmiş insanların kendi ağzından hayat hikayeleri ekrana geliyor.","priceType":[{"value":"0","key":"BTV"},{"value":"0","key":"TVOD"}],"endtime":"20211107010000","seasonTotalCount":"0","recordedMediaIds":[],"picture":{},"isLoyalty":"0","isppv":"0","mainGenre":"0","contentRight":"[{\\"mediaId\\":\\"3000435\\",\\"businessType\\":\\"13\\",\\"enable\\":\\"0\\"},{\\"mediaId\\":\\"3000435\\",\\"businessType\\":\\"14\\",\\"enable\\":\\"0\\"},{\\"mediaId\\":\\"3000435\\",\\"businessType\\":\\"15\\",\\"enable\\":\\"1\\"},{\\"mediaId\\":\\"100067919\\",\\"businessType\\":\\"13\\",\\"enable\\":\\"0\\"},{\\"mediaId\\":\\"100067919\\",\\"businessType\\":\\"14\\",\\"enable\\":\\"0\\"},{\\"mediaId\\":\\"100067919\\",\\"businessType\\":\\"15\\",\\"enable\\":\\"1\\"}]","channelid":"32"}],"playbillVersion":[{"channelId":"32","date":"20211108","version":"20211106000043"},{"channelId":"32","date":"20211107","version":"20211105000027"}]}'
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe('https://izmottvsc23.tvplus.com.tr:33207/EPG/JSON/PlayBillList')
|
||||
})
|
||||
|
||||
it('can generate valid request data', () => {
|
||||
const result = request.data({ date, channel })
|
||||
expect(result).toMatchObject({
|
||||
type: '2',
|
||||
channelid: '32',
|
||||
begintime: '20211107000000',
|
||||
endtime: '20211108000000'
|
||||
})
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const result = parser({ date, channel, content })
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2021-11-07T00:00:00.000Z',
|
||||
stop: '2021-11-07T01:00:00.000Z',
|
||||
title: '24 Portre',
|
||||
category: 'Yaşam',
|
||||
icon: 'https://izmottvsc23.tvplus.com.tr:33207/CPS/images/universal/film/program/202111/20211104/35/20211104000026695lh5.jpg',
|
||||
description:
|
||||
'Kendi alanında büyük başarılar elde etmiş insanların kendi ağzından hayat hikayeleri ekrana geliyor.'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
content:
|
||||
'{"counttotal":"0","playbilllist":[],"playbillVersion":[{"channelId":"10000","date":"20211108","version":"20211107163253"},{"channelId":"10000","date":"20211107","version":"20211107163253"}]}'
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
// npm run grab -- --site=tvplus.com.tr
|
||||
|
||||
const { parser, url, request } = require('./tvplus.com.tr.config.js')
|
||||
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('2021-11-07', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '32',
|
||||
xmltv_id: '24TV.tr'
|
||||
}
|
||||
const content =
|
||||
'{"counttotal":"23","playbilllist":[{"country":"","starttime":"20211107000000","type":"PROGRAM","isBlackout":"0","rerun":"0","ppvsubscribed":"0","foreignsn":"134383557","isLive":"0","ratingid":"0","episodeTotalCount":"0","id":"134383557","keyword":"24 Portre","contentType":"0","isnpvr":"1","slsType":"0","iscpvr":"0","advisory":[],"genreIds":["1179"],"istvod":"0","name":"24 Portre","tvodStatus":"0","pictures":[{"href":"https://izmottvsc23.tvplus.com.tr:33207/CPS/images/universal/film/program/202111/20211104/35/20211104000026695lh5.jpg","resolution":["null","null"],"imageType":"0"}],"externalContentCode":"105445035962202111070300","genres":"Yaşam","visittimes":"0","issubscribed":"0","programType":"program","gapFiller":"0","introduce":"Kendi alanında büyük başarılar elde etmiş insanların kendi ağzından hayat hikayeleri ekrana geliyor.","priceType":[{"value":"0","key":"BTV"},{"value":"0","key":"TVOD"}],"endtime":"20211107010000","seasonTotalCount":"0","recordedMediaIds":[],"picture":{},"isLoyalty":"0","isppv":"0","mainGenre":"0","contentRight":"[{\\"mediaId\\":\\"3000435\\",\\"businessType\\":\\"13\\",\\"enable\\":\\"0\\"},{\\"mediaId\\":\\"3000435\\",\\"businessType\\":\\"14\\",\\"enable\\":\\"0\\"},{\\"mediaId\\":\\"3000435\\",\\"businessType\\":\\"15\\",\\"enable\\":\\"1\\"},{\\"mediaId\\":\\"100067919\\",\\"businessType\\":\\"13\\",\\"enable\\":\\"0\\"},{\\"mediaId\\":\\"100067919\\",\\"businessType\\":\\"14\\",\\"enable\\":\\"0\\"},{\\"mediaId\\":\\"100067919\\",\\"businessType\\":\\"15\\",\\"enable\\":\\"1\\"}]","channelid":"32"}],"playbillVersion":[{"channelId":"32","date":"20211108","version":"20211106000043"},{"channelId":"32","date":"20211107","version":"20211105000027"}]}'
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url).toBe('https://izmottvsc23.tvplus.com.tr:33207/EPG/JSON/PlayBillList')
|
||||
})
|
||||
|
||||
it('can generate valid request data', () => {
|
||||
const result = request.data({ date, channel })
|
||||
expect(result).toMatchObject({
|
||||
type: '2',
|
||||
channelid: '32',
|
||||
begintime: '20211107000000',
|
||||
endtime: '20211108000000'
|
||||
})
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const result = parser({ date, channel, content })
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: '2021-11-07T00:00:00.000Z',
|
||||
stop: '2021-11-07T01:00:00.000Z',
|
||||
title: '24 Portre',
|
||||
category: 'Yaşam',
|
||||
icon: 'https://izmottvsc23.tvplus.com.tr:33207/CPS/images/universal/film/program/202111/20211104/35/20211104000026695lh5.jpg',
|
||||
description:
|
||||
'Kendi alanında büyük başarılar elde etmiş insanların kendi ağzından hayat hikayeleri ekrana geliyor.'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
date,
|
||||
channel,
|
||||
content:
|
||||
'{"counttotal":"0","playbilllist":[],"playbillVersion":[{"channelId":"10000","date":"20211108","version":"20211107163253"},{"channelId":"10000","date":"20211107","version":"20211107163253"}]}'
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user