mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Add stod2.is
Add stod2.is guide
This commit is contained in:
parent
af932a972c
commit
f501229b65
4 changed files with 127 additions and 0 deletions
21
sites/stod2.is/readme.md
Normal file
21
sites/stod2.is/readme.md
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# stod2.is
|
||||||
|
|
||||||
|
https://stod2.is/framundan-i-beinni/
|
||||||
|
|
||||||
|
### 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
|
||||||
|
```
|
14
sites/stod2.is/stod2.is.channels.xml
Normal file
14
sites/stod2.is/stod2.is.channels.xml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<channels>
|
||||||
|
<channel site="stod2.is" lang="is" xmltv_id="" site_id="stod2">Stöð 2</channel>
|
||||||
|
<channel site="stod2.is" lang="is" xmltv_id="" site_id="stod3">Stöð 2 Fjölskylda</channel>
|
||||||
|
<channel site="stod2.is" lang="is" xmltv_id="" site_id="sport">Stöð 2 Sport</channel>
|
||||||
|
<channel site="stod2.is" lang="is" xmltv_id="" site_id="sport2">Stöð 2 Sport 2</channel>
|
||||||
|
<channel site="stod2.is" lang="is" xmltv_id="" site_id="sport3">Stöð 2 Sport 3</channel>
|
||||||
|
<channel site="stod2.is" lang="is" xmltv_id="" site_id="sport4">Stöð 2 Sport 4</channel>
|
||||||
|
<channel site="stod2.is" lang="is" xmltv_id="" site_id="golfstodin">Stöð 2 Sport 5</channel>
|
||||||
|
<channel site="stod2.is" lang="is" xmltv_id="" site_id="sport6">Stöð 2 Sport 6</channel>
|
||||||
|
<channel site="stod2.is" lang="is" xmltv_id="" site_id="besta01">Besta01</channel>
|
||||||
|
<channel site="stod2.is" lang="is" xmltv_id="" site_id="besta02">Besta02</channel>
|
||||||
|
<channel site="stod2.is" lang="is" xmltv_id="" site_id="besta03">Besta03</channel>
|
||||||
|
</channels>
|
62
sites/stod2.is/stod2.is.config.js
Normal file
62
sites/stod2.is/stod2.is.config.js
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
const dayjs = require('dayjs')
|
||||||
|
const utc = require('dayjs/plugin/utc')
|
||||||
|
|
||||||
|
dayjs.extend(utc)
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
site: 'stod2.is',
|
||||||
|
channels: 'stod2.is.channels.xml',
|
||||||
|
days: 7,
|
||||||
|
request: {
|
||||||
|
cache: {
|
||||||
|
ttl: 60 * 60 * 1000 // 1 hour
|
||||||
|
}
|
||||||
|
},
|
||||||
|
url({ channel, date }) {
|
||||||
|
return `https://api.stod2.is/dagskra/api/${channel.site_id}/${date.format('YYYY-MM-DD')}`
|
||||||
|
},
|
||||||
|
parser({ content }) {
|
||||||
|
let programs = []
|
||||||
|
const items = parseItems(content)
|
||||||
|
|
||||||
|
items.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() {
|
||||||
|
const axios = require('axios')
|
||||||
|
try {
|
||||||
|
const response = await axios.get(`https://api.stod2.is/dagskra/api`)
|
||||||
|
return response.data.channels.map(item => {
|
||||||
|
return {
|
||||||
|
lang: 'is',
|
||||||
|
name: item.nafn, // Assuming 'nafn' is the name of the channel
|
||||||
|
site_id: item.id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching channels:', error)
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function parseItems(content) {
|
||||||
|
const data = JSON.parse(content)
|
||||||
|
if (!data || !Array.isArray(data)) return []
|
||||||
|
return data
|
||||||
|
}
|
30
sites/stod2.is/stod2.is.test.js
Normal file
30
sites/stod2.is/stod2.is.test.js
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
const { url, parser } = require('./stod2.is.config.js')
|
||||||
|
const dayjs = require('dayjs')
|
||||||
|
const utc = require('dayjs/plugin/utc')
|
||||||
|
dayjs.extend(utc)
|
||||||
|
|
||||||
|
const date = dayjs.utc('2024-12-19', 'YYYY-MM-DD').startOf('d')
|
||||||
|
const channel = { site_id: 'stod2', xmltv_id: 'Stod2.is', lang: 'is' }
|
||||||
|
|
||||||
|
it('can generate valid url', () => {
|
||||||
|
expect(url({ channel, date })).toBe('https://api.stod2.is/dagskra/api/stod2/2024-12-19')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can parse response', () => {
|
||||||
|
const content = `[{"start":"2024-12-19T08:00:00Z","stop":"2024-12-19T08:15:00Z","title":"Heimsókn"}]`
|
||||||
|
const results = parser({ content })
|
||||||
|
|
||||||
|
expect(results).toMatchObject([
|
||||||
|
{
|
||||||
|
start: '2024-12-19T08:00:00Z',
|
||||||
|
stop: '2024-12-19T08:15:00Z',
|
||||||
|
title: 'Heimsókn'
|
||||||
|
}
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can handle empty guide', () => {
|
||||||
|
const results = parser({ content: '' })
|
||||||
|
|
||||||
|
expect(results).toMatchObject([])
|
||||||
|
})
|
Loading…
Add table
Add a link
Reference in a new issue