mirror of
https://github.com/iptv-org/epg
synced 2026-05-09 19:07:03 -04:00
Add files via upload
This commit is contained in:
34
sites/syn.is/__data__/content.json
Normal file
34
sites/syn.is/__data__/content.json
Normal file
@@ -0,0 +1,34 @@
|
||||
[
|
||||
{
|
||||
"midill": "STOD2",
|
||||
"midill_heiti": "Stöð 2",
|
||||
"dagsetning": "2025-01-03T00:00:00Z",
|
||||
"upphaf": "2025-01-03T08:00:00Z",
|
||||
"titill": "Telma Borgþórsdóttir",
|
||||
"isltitill": "Heimsókn",
|
||||
"undirtitill": "Telma Borgþórsdóttir",
|
||||
"seria": 8,
|
||||
"thattur": 5,
|
||||
"thattafjoldi": 10,
|
||||
"birta_thatt": 1,
|
||||
"opin": 0,
|
||||
"beint": 0,
|
||||
"frumsyning": 0,
|
||||
"framundan_i_beinni": 0,
|
||||
"tegund": "SER",
|
||||
"flokkur": "Icelandic",
|
||||
"adalhlutverk": "",
|
||||
"leikstjori": "",
|
||||
"ar": "2019",
|
||||
"bannad": "Green",
|
||||
"recidefni": 592645105,
|
||||
"recidlidur": 592645184,
|
||||
"recidsyning": null,
|
||||
"refno": null,
|
||||
"frelsi": 0,
|
||||
"netdagar": 0,
|
||||
"lysing": "Frábærir þættir með Sindra Sindrasyni sem lítur inn hjá íslenskum fagurkerum. Heimilin eru jafn ólík og þau eru mörg en eiga það þó eitt sameiginlegt að vera sett saman af alúð og smekklegheitum. Sindri hefur líka einstakt lag á að ná fram því besta í viðmælendum sínum.",
|
||||
"slott": 15,
|
||||
"slotlengd": "00:15"
|
||||
}
|
||||
]
|
||||
21
sites/syn.is/readme.md
Normal file
21
sites/syn.is/readme.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# syn.is
|
||||
|
||||
https://www.syn.is/sjonvarp/dagskra
|
||||
|
||||
### Download the guide
|
||||
|
||||
```sh
|
||||
npm run grab --- --site=syn.is
|
||||
```
|
||||
|
||||
### Update channel list
|
||||
|
||||
```sh
|
||||
npm run channels:parse --- --config=./sites/syn.is/syn.is.config.js --output=./sites/syn.is/syn.is.channels.xml
|
||||
```
|
||||
|
||||
### Test
|
||||
|
||||
```sh
|
||||
npm test --- syn.is
|
||||
```
|
||||
12
sites/syn.is/syn.is.channels.xml
Normal file
12
sites/syn.is/syn.is.channels.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<channels>
|
||||
<channel site="syn.is" site_id="syn" lang="is" xmltv_id="">Sýn</channel>
|
||||
<channel site="syn.is" site_id="synsport" lang="is" xmltv_id="">Sýn Sport</channel>
|
||||
<channel site="syn.is" site_id="synsport2" lang="is" xmltv_id="">Sýn Sport2</channel>
|
||||
<channel site="syn.is" site_id="synsport3" lang="is" xmltv_id="">Sýn Sport3</channel>
|
||||
<channel site="syn.is" site_id="synsport4" lang="is" xmltv_id="">Sýn Sport4</channel>
|
||||
<channel site="syn.is" site_id="synsportisland" lang="is" xmltv_id="">Sýn Sport Ísland</channel>
|
||||
<channel site="syn.is" site_id="synsportisland2" lang="is" xmltv_id="">Sýn Sport Ísland 2</channel>
|
||||
<channel site="syn.is" site_id="synsportisland3" lang="is" xmltv_id="">Sýn Sport Ísland 3</channel>
|
||||
<channel site="syn.is" site_id="synsportviaplay" lang="is" xmltv_id="">Sýn Sport Viaplay</channel>
|
||||
</channels>
|
||||
88
sites/syn.is/syn.is.config.js
Normal file
88
sites/syn.is/syn.is.config.js
Normal file
@@ -0,0 +1,88 @@
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const axios = require('axios')
|
||||
|
||||
dayjs.extend(utc)
|
||||
|
||||
module.exports = {
|
||||
site: 'syn.is',
|
||||
days: 7,
|
||||
request: {
|
||||
cache: {
|
||||
ttl: 60 * 60 * 1000 // 1 hour
|
||||
}
|
||||
},
|
||||
url({ channel, date }) {
|
||||
return `https://www.syn.is/api/epg/${channel.site_id}/${date.format('YYYY-MM-DD')}`
|
||||
},
|
||||
parser: function ({ content, date }) {
|
||||
let data
|
||||
try {
|
||||
data = JSON.parse(content)
|
||||
} catch (error) {
|
||||
console.error('Error parsing JSON:', error)
|
||||
return []
|
||||
}
|
||||
|
||||
if (!Array.isArray(data)) return []
|
||||
|
||||
const programs = []
|
||||
|
||||
data
|
||||
.filter(item => item?.upphaf)
|
||||
.forEach(item => {
|
||||
const start = dayjs.utc(item.upphaf)
|
||||
|
||||
if (start.format('YYYY-MM-DD') === date.format('YYYY-MM-DD')) {
|
||||
programs.push({
|
||||
title: item.isltitill,
|
||||
sub_title: item.undirtitill,
|
||||
description: item.lysing,
|
||||
category: item.flokkur,
|
||||
season: item.seria,
|
||||
episode: item.thattur,
|
||||
actors: item.adalhlutverk,
|
||||
directors: item.leikstjori,
|
||||
start,
|
||||
stop: start.add(item.slott, 'm')
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
try {
|
||||
const response = await axios.get('https://www.syn.is/api/epg?type=schedule')
|
||||
if (!response.data || !Array.isArray(response.data)) {
|
||||
console.error('Error: No channels data found')
|
||||
return []
|
||||
}
|
||||
|
||||
const channels = await Promise.all(
|
||||
response.data.map(async item => {
|
||||
try {
|
||||
const { data: channelData } = await axios.get(`https://www.syn.is/api/epg/${item}`)
|
||||
if (!channelData?.[0]?.midill_heiti) {
|
||||
console.error(`Error: No name found for channel ${item}`)
|
||||
return null
|
||||
}
|
||||
return {
|
||||
lang: 'is',
|
||||
site_id: item,
|
||||
name: channelData[0].midill_heiti
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error fetching channel name for ${item}:`, error)
|
||||
return null
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
return channels.filter(Boolean)
|
||||
} catch (error) {
|
||||
console.error('Error fetching channels:', error)
|
||||
return []
|
||||
}
|
||||
}
|
||||
}
|
||||
46
sites/syn.is/syn.is.test.js
Normal file
46
sites/syn.is/syn.is.test.js
Normal file
@@ -0,0 +1,46 @@
|
||||
const { parser, url } = require('./syn.is.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')
|
||||
const timezone = require('dayjs/plugin/timezone')
|
||||
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(customParseFormat)
|
||||
dayjs.extend(timezone)
|
||||
|
||||
const date = dayjs.utc('2025-01-03', 'YYYY-MM-DD').startOf('day')
|
||||
const channel = { site_id: 'syn', xmltv_id: 'Syn.is' }
|
||||
|
||||
it('can generate valid url', () => {
|
||||
const generatedUrl = url({ date, channel })
|
||||
expect(generatedUrl).toBe('https://www.syn.is/api/epg/syn/2025-01-03')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
|
||||
const result = parser({ content, date }).map(p => {
|
||||
p.start = p.start.toISOString()
|
||||
p.stop = p.stop.toISOString()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(result).toMatchObject([
|
||||
{
|
||||
title: 'Heimsókn',
|
||||
sub_title: 'Telma Borgþórsdóttir',
|
||||
description:
|
||||
'Frábærir þættir með Sindra Sindrasyni sem lítur inn hjá íslenskum fagurkerum. Heimilin eru jafn ólík og þau eru mörg en eiga það þó eitt sameiginlegt að vera sett saman af alúð og smekklegheitum. Sindri hefur líka einstakt lag á að ná fram því besta í viðmælendum sínum.',
|
||||
actors: '',
|
||||
directors: '',
|
||||
start: '2025-01-03T08:00:00.000Z',
|
||||
stop: '2025-01-03T08:15:00.000Z'
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({ content: '[]', date })
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
Reference in New Issue
Block a user