stod2 -> syn.is

This commit is contained in:
theofficialomega
2026-02-19 17:55:39 +01:00
parent f8ca034375
commit c49e276b33
6 changed files with 150 additions and 150 deletions
-21
View File
@@ -1,21 +0,0 @@
# stod2.is
https://stod2.is/dagskra/
### Download the guide
```sh
npm run grab --- --site=stod2.is
```
### Update channel list
```sh
npm run channels:parse --- --config=./sites/stod2.is/stod2.is.config.js --output=./sites/stod2.is/stod2.is.channels.xml
```
### Test
```sh
npm test --- stod2.is
```
+21
View 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
```
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<channels>
<channel site="syn.is" site_id="beint" lang="is" xmltv_id=""></channel>
<channel site="syn.is" site_id="bio" lang="is" xmltv_id=""></channel>
<channel site="syn.is" site_id="syn" lang="is" xmltv_id=""></channel>
<channel site="syn.is" site_id="synsport" lang="is" xmltv_id="Stod2Sport.is@SD">Stöð 2 Sport</channel>
<channel site="syn.is" site_id="synsport2" lang="is" xmltv_id="Stod2Sport2.is@SD">Stöð 2 Sport 2</channel>
<channel site="syn.is" site_id="synsport3" lang="is" xmltv_id="Stod2Sport3.is@SD">Stöð 2 Sport 3</channel>
<channel site="syn.is" site_id="synsport4" lang="is" xmltv_id="Stod2Sport4.is@SD">Stöð 2 Sport 4</channel>
<channel site="syn.is" site_id="synsport5" lang="is" xmltv_id="Stod2Sport5.is@SD">Stöð 2 Sport 5</channel>
<channel site="syn.is" site_id="synsport6" lang="is" xmltv_id="Stod2Sport6.is@SD">Stöð 2 Sport 6</channel>
<channel site="syn.is" site_id="synsportisland" lang="is" xmltv_id=""></channel>
<channel site="syn.is" site_id="synsportisland2" lang="is" xmltv_id=""></channel>
<channel site="syn.is" site_id="synsportisland3" lang="is" xmltv_id=""></channel>
<channel site="syn.is" site_id="synsportviaplay" lang="is" xmltv_id=""></channel>
</channels>
<?xml version="1.0" encoding="UTF-8"?>
<channels>
<channel site="syn.is" site_id="beint" lang="is" xmltv_id=""></channel>
<channel site="syn.is" site_id="bio" lang="is" xmltv_id=""></channel>
<channel site="syn.is" site_id="syn" lang="is" xmltv_id=""></channel>
<channel site="syn.is" site_id="synsport" lang="is" xmltv_id="Stod2Sport.is@SD">Stöð 2 Sport</channel>
<channel site="syn.is" site_id="synsport2" lang="is" xmltv_id="Stod2Sport2.is@SD">Stöð 2 Sport 2</channel>
<channel site="syn.is" site_id="synsport3" lang="is" xmltv_id="Stod2Sport3.is@SD">Stöð 2 Sport 3</channel>
<channel site="syn.is" site_id="synsport4" lang="is" xmltv_id="Stod2Sport4.is@SD">Stöð 2 Sport 4</channel>
<channel site="syn.is" site_id="synsport5" lang="is" xmltv_id="Stod2Sport5.is@SD">Stöð 2 Sport 5</channel>
<channel site="syn.is" site_id="synsport6" lang="is" xmltv_id="Stod2Sport6.is@SD">Stöð 2 Sport 6</channel>
<channel site="syn.is" site_id="synsportisland" lang="is" xmltv_id=""></channel>
<channel site="syn.is" site_id="synsportisland2" lang="is" xmltv_id=""></channel>
<channel site="syn.is" site_id="synsportisland3" lang="is" xmltv_id=""></channel>
<channel site="syn.is" site_id="synsportviaplay" lang="is" xmltv_id=""></channel>
</channels>
@@ -1,67 +1,67 @@
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 }) {
let data
try {
data = JSON.parse(content)
} catch (error) {
console.error('Error parsing JSON:', error)
return []
}
const programs = []
if (data && Array.isArray(data)) {
data.forEach(item => {
if (!item) return
const start = dayjs.utc(item.upphaf)
const stop = start.add(item.slott, 'm')
programs.push({
title: item.isltitill,
sub_title: item.undirtitill,
description: item.lysing,
actors: item.adalhlutverk,
directors: item.leikstjori,
start,
stop
})
})
}
return programs
},
async channels() {
try {
const response = await axios.get('https://www.syn.is/api/epg/')
if (!response.data || !Array.isArray(response.data)) {
console.error('Error: No channels data found')
return []
}
return response.data.map(item => {
return {
lang: 'is',
site_id: item
}
})
} catch (error) {
console.error('Error fetching channels:', error)
return []
}
}
}
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 }) {
let data
try {
data = JSON.parse(content)
} catch (error) {
console.error('Error parsing JSON:', error)
return []
}
const programs = []
if (data && Array.isArray(data)) {
data.forEach(item => {
if (!item) return
const start = dayjs.utc(item.upphaf)
const stop = start.add(item.slott, 'm')
programs.push({
title: item.isltitill,
sub_title: item.undirtitill,
description: item.lysing,
actors: item.adalhlutverk,
directors: item.leikstjori,
start,
stop
})
})
}
return programs
},
async channels() {
try {
const response = await axios.get('https://www.syn.is/api/epg/')
if (!response.data || !Array.isArray(response.data)) {
console.error('Error: No channels data found')
return []
}
return response.data.map(item => {
return {
lang: 'is',
site_id: item
}
})
} catch (error) {
console.error('Error fetching channels:', error)
return []
}
}
}
@@ -1,46 +1,46 @@
const { parser, url } = require('./stod2.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: 'stod2', xmltv_id: 'Stod2.is' }
it('can generate valid url', () => {
const generatedUrl = url({ date, channel })
expect(generatedUrl).toBe('https://www.syn.is/api/epg/stod2/2025-01-03')
})
it('can parse response', () => {
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
const result = parser({ content }).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: '[]' })
expect(result).toMatchObject([])
})
const { parser, url } = require('./stod2.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: 'stod2', xmltv_id: 'Stod2.is' }
it('can generate valid url', () => {
const generatedUrl = url({ date, channel })
expect(generatedUrl).toBe('https://www.syn.is/api/epg/stod2/2025-01-03')
})
it('can parse response', () => {
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'))
const result = parser({ content }).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: '[]' })
expect(result).toMatchObject([])
})