Merge pull request #159 from iptv-org/add-ipko-com

Add guide from ipko.com
This commit is contained in:
Aleksandr Statciuk 2021-10-24 10:45:30 +03:00 committed by GitHub
commit f4e1ab073e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 5389 additions and 646 deletions

5892
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,11 +1,15 @@
{
"name": "epg",
"scripts": {
"update-codes": "node scripts/update-codes.js"
"update-codes": "node scripts/update-codes.js",
"test": "jest"
},
"private": true,
"author": "Arhey",
"license": "MIT",
"jest": {
"testRegex": "sites/(.*?/)?.*test.js$"
},
"dependencies": {
"axios": "^0.21.1",
"cheerio": "^1.0.0-rc.10",
@ -16,6 +20,7 @@
"form-data": "^4.0.0",
"glob": "^7.2.0",
"iconv-lite": "^0.4.24",
"jest": "^27.3.1",
"jsdom": "^16.5.0",
"lodash": "^4.17.21",
"markdown-include": "^0.4.3",

View file

@ -0,0 +1,55 @@
const axios = require('axios')
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
dayjs.extend(utc)
module.exports = {
site: 'ipko.com',
url: function ({ date }) {
return `https://www.ipko.com/epg/admin/programs.php?date=${date.format('YYYY-MM-DD')}`
},
async logo({ channel }) {
const data = await axios
.post('https://www.ipko.com/epg/admin/channels.php')
.then(r => r.data)
.catch(console.log)
const item = Object.values(data.element).find(c => c.channel_id == channel.site_id)
return item ? `https://www.ipko.com/epg/logo/${item.icon}` : null
},
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 : []
}

View file

@ -0,0 +1,40 @@
// npx epg-grabber --config=sites/ipko.com/ipko.com.config.js --channels=sites/ipko.com/ipko.com_al.channels.xml --days=2 --output=.gh-pages/guides/al/ipko.com.epg.xml
const { parser, url, logo } = require('./ipko.com.config.js')
const dayjs = require('dayjs')
const date = dayjs('10/24/2021')
const channel = { site_id: '406', xmltv_id: 'RTK1.rs' }
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 get logo url', done => {
logo({ channel })
.then(result => {
expect(result).toBe('https://www.ipko.com/epg/logo/stinet.png')
done()
})
.catch(error => done(error))
})
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([])
})

View file

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<site site="ipko.com">
<channels>
<channel lang="hr" xmltv_id="24KitchenSrbija.us" site_id="418">24 Kitchen Srbija</channel>
<channel lang="hr" xmltv_id="ABCNews.al" site_id="269">ABC News</channel>
<channel lang="hr" xmltv_id="AnimalPlanetEurope.us" site_id="403">Animal Planet Europe</channel>
<channel lang="hr" xmltv_id="Arta.rs" site_id="423">Arta</channel>
<channel lang="hr" xmltv_id="BabyTVEurope.uk" site_id="413">Baby TV Europe</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 Europe</channel>
<channel lang="hr" xmltv_id="BoomerangCentralEasternEurope.us" site_id="279">Boomerang Central &amp; Eastern Europe</channel>
<channel lang="hr" xmltv_id="CNNInternationalEurope.us" site_id="385">CNN International Europe</channel>
<channel lang="hr" xmltv_id="Cufo.al" site_id="275">Çufo</channel>
<channel lang="hr" xmltv_id="DiscoveryChannelBulgaria.us" site_id="417">Discovery Channel Bulgaria</channel>
<channel lang="hr" xmltv_id="DiscoveryScience.us" site_id="421">Discovery Science</channel>
<channel lang="hr" xmltv_id="DTXEastEurope.us" site_id="422">DTX East Europe</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.rs" site_id="312">Kohavision</channel>
<channel lang="hr" xmltv_id="MTVLive.us" 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.us" site_id="299">National Geographic UK</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.rs" site_id="402">RTK 1</channel>
<channel lang="hr" xmltv_id="RTV21.rs" site_id="255">RTV 21</channel>
<channel lang="hr" xmltv_id="Stinet.al" site_id="406">Stinët</channel>
</channels>
</site>