Initial Commit
This commit is contained in:
40
sites/ipko.com/ipko.com.channels.xml
Normal file
40
sites/ipko.com/ipko.com.channels.xml
Normal file
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site site="ipko.com">
|
||||
<channels>
|
||||
<channel lang="hr" xmltv_id="24KitchenSerbia.rs" site_id="418">24 Kitchen</channel>
|
||||
<channel lang="hr" xmltv_id="ABCNewsAlbania.al" site_id="269">ABC News</channel>
|
||||
<channel lang="hr" xmltv_id="BabyTV.uk" site_id="413">Baby TV</channel>
|
||||
<channel lang="hr" xmltv_id="BangBang.al" site_id="274">Bang Bang</channel>
|
||||
<channel lang="hr" xmltv_id="BBCWorldNewsEurope.uk" site_id="386">BBC World News</channel>
|
||||
<channel lang="hr" xmltv_id="BoomerangCEE.us" site_id="279">Boomerang</channel>
|
||||
<channel lang="hr" xmltv_id="CNNInternationalEurope.us" site_id="385">CNN</channel>
|
||||
<channel lang="hr" xmltv_id="Cufo.al" site_id="275">Çufo</channel>
|
||||
<channel lang="hr" xmltv_id="DiscoveryChannelBulgaria.bg" site_id="417">Discovery Channel</channel>
|
||||
<channel lang="hr" xmltv_id="DiscoveryScience.us" site_id="421">Discovery Science</channel>
|
||||
<!-- <channel lang="hr" xmltv_id="" site_id="422">DTX</channel> -->
|
||||
<channel lang="hr" xmltv_id="Eurosport1.fr" site_id="351">Eurosport 1</channel>
|
||||
<channel lang="hr" xmltv_id="ExplorerHistori.al" site_id="296">Explorer Histori</channel>
|
||||
<channel lang="hr" xmltv_id="ExplorerNatyra.al" site_id="298">Explorer Natyra</channel>
|
||||
<channel lang="hr" xmltv_id="ExplorerShkence.al" site_id="295">Explorer Shkencë</channel>
|
||||
<channel lang="hr" xmltv_id="FilmAksion.al" site_id="291">Film Aksion</channel>
|
||||
<channel lang="hr" xmltv_id="FilmDrame.al" site_id="290">Film Dramë</channel>
|
||||
<channel lang="hr" xmltv_id="FilmHits.al" site_id="415">Film Hits</channel>
|
||||
<channel lang="hr" xmltv_id="FilmKomedi.al" site_id="285">Film Komedi</channel>
|
||||
<channel lang="hr" xmltv_id="FilmThriller.al" site_id="289">Film Thriller</channel>
|
||||
<channel lang="hr" xmltv_id="Hayat.ba" site_id="352">Hayat</channel>
|
||||
<channel lang="hr" xmltv_id="JuniorTV.al" site_id="276">Junior TV</channel>
|
||||
<channel lang="hr" xmltv_id="Kohavision.xk" site_id="312">Kohavision</channel>
|
||||
<channel lang="hr" xmltv_id="MTVLive.uk" site_id="303">MTV Live</channel>
|
||||
<channel lang="hr" xmltv_id="MyMusic.al" site_id="273">My Music</channel>
|
||||
<channel lang="hr" xmltv_id="NationalGeographicUK.uk" site_id="299">National Geographic</channel>
|
||||
<channel lang="hr" xmltv_id="News24.al" site_id="316">News 24</channel>
|
||||
<channel lang="hr" xmltv_id="PeaceTVEnglish.ae" site_id="383">Peace TV English</channel>
|
||||
<channel lang="hr" xmltv_id="Rai1.it" site_id="378">Rai 1</channel>
|
||||
<channel lang="hr" xmltv_id="Rai2.it" site_id="379">Rai 2</channel>
|
||||
<channel lang="hr" xmltv_id="Rai3.it" site_id="380">Rai 3</channel>
|
||||
<channel lang="hr" xmltv_id="RTK1.xk" site_id="402">RTK 1</channel>
|
||||
<channel lang="hr" xmltv_id="RTV21.xk" site_id="255">RTV 21 Sat</channel>
|
||||
<channel lang="hr" xmltv_id="Stinet.al" site_id="406">Stinët</channel>
|
||||
<channel lang="hr" xmltv_id="TVArta.xk" site_id="423">Arta</channel>
|
||||
</channels>
|
||||
</site>
|
||||
46
sites/ipko.com/ipko.com.config.js
Normal file
46
sites/ipko.com/ipko.com.config.js
Normal file
@@ -0,0 +1,46 @@
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
|
||||
dayjs.extend(utc)
|
||||
|
||||
module.exports = {
|
||||
site: 'ipko.com',
|
||||
days: 2,
|
||||
url: function ({ date }) {
|
||||
return `https://www.ipko.com/epg/admin/programs.php?date=${date.format('YYYY-MM-DD')}`
|
||||
},
|
||||
parser: function ({ content, channel, date }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel)
|
||||
items.forEach(item => {
|
||||
const start = parseStart(item, date)
|
||||
const stop = start.add(item.duration / 3, 'm')
|
||||
|
||||
programs.push({
|
||||
title: item.program_name,
|
||||
description: item.description,
|
||||
category: item.category,
|
||||
start: start.toString(),
|
||||
stop: stop.toString()
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart(item, date) {
|
||||
const time = `${date.format('YYYY-MM-DD')} ${item.date}`
|
||||
|
||||
return dayjs.utc(time, 'YYYY-MM-DD HH:mm:ss')
|
||||
}
|
||||
|
||||
function parseItems(content, channel) {
|
||||
const data = JSON.parse(content)
|
||||
const arr = Object.values(data.element)
|
||||
const items = arr.find(el => {
|
||||
return el[0] && el[0].channel_id == channel.site_id
|
||||
})
|
||||
|
||||
return Array.isArray(items) ? items : []
|
||||
}
|
||||
38
sites/ipko.com/ipko.com.test.js
Normal file
38
sites/ipko.com/ipko.com.test.js
Normal file
@@ -0,0 +1,38 @@
|
||||
// npx epg-grabber --config=sites/ipko.com/ipko.com.config.js --channels=sites/ipko.com/ipko.com.channels.xml --days=2 --output=guide.xml
|
||||
|
||||
const { parser, url } = require('./ipko.com.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-10-24', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '406',
|
||||
xmltv_id: 'RTK1.xk'
|
||||
}
|
||||
const content = `{"element":{"1":[{"id":6367,"channel_id":406,"program_name":"Beautiful People 13","name_short":"","description":"Lin largohet nga Nju Meksiko për t'u vendosur në Nju Jork e për t'ia nisur nga fillimi: një punë të re, shtëpi të re dhe njohje të reja. Bashkë me të janë vajzat e saj, Sofia, një 16 vjeçare që shkëlqen në shkollë, dhe Kareni, 20 vjeçare, që do të bë","category":"Sezoni I","duration":150,"day":"Sun","left_distanc":165,"date":"00:55:00"}]}}`
|
||||
|
||||
it('can generate valid url', () => {
|
||||
const result = url({ date })
|
||||
expect(result).toBe('https://www.ipko.com/epg/admin/programs.php?date=2021-10-24')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const result = parser({ date, channel, content })
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
start: 'Sun, 24 Oct 2021 00:55:00 GMT',
|
||||
stop: 'Sun, 24 Oct 2021 01:45:00 GMT',
|
||||
title: 'Beautiful People 13',
|
||||
description: `Lin largohet nga Nju Meksiko për t'u vendosur në Nju Jork e për t'ia nisur nga fillimi: një punë të re, shtëpi të re dhe njohje të reja. Bashkë me të janë vajzat e saj, Sofia, një 16 vjeçare që shkëlqen në shkollë, dhe Kareni, 20 vjeçare, që do të bë`,
|
||||
category: 'Sezoni I'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({ date, channel, content: `{"element":{"1":[{"no":"no"}]}}` })
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
Reference in New Issue
Block a user