mirror of
https://github.com/iptv-org/epg
synced 2026-05-03 07:56:58 -04:00
Replace LF line endings with CRLF
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,84 +1,84 @@
|
||||
const cheerio = require('cheerio')
|
||||
const iconv = require('iconv-lite')
|
||||
const { DateTime } = require('luxon')
|
||||
|
||||
module.exports = {
|
||||
site: 'm.tv.sms.cz',
|
||||
days: 2,
|
||||
url: function ({ date, channel }) {
|
||||
return `https://m.tv.sms.cz/index.php?stanice=${channel.site_id}&cas=0&den=${date.format(
|
||||
'YYYY-MM-DD'
|
||||
)}`
|
||||
},
|
||||
parser: function ({ buffer, date }) {
|
||||
const programs = []
|
||||
const items = parseItems(buffer)
|
||||
items.forEach(item => {
|
||||
const prev = programs[programs.length - 1]
|
||||
const $item = cheerio.load(item)
|
||||
let start = parseStart($item, date)
|
||||
if (prev) {
|
||||
if (start < prev.start) {
|
||||
start = start.plus({ days: 1 })
|
||||
date = date.add(1, 'd')
|
||||
}
|
||||
prev.stop = start
|
||||
}
|
||||
const stop = start.plus({ hours: 1 })
|
||||
programs.push({
|
||||
title: parseTitle($item),
|
||||
description: parseDescription($item),
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const axios = require('axios')
|
||||
const data = await axios
|
||||
.get('https://m.tv.sms.cz/?zmen_stanice=true')
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
|
||||
let channels = []
|
||||
const $ = cheerio.load(data)
|
||||
$('.stanice').each((i, el) => {
|
||||
const name = $(el).attr('title')
|
||||
const site_id = $(el).find('input').attr('value').replace(/\|/g, '')
|
||||
|
||||
if (!name) return
|
||||
|
||||
channels.push({
|
||||
lang: 'cs',
|
||||
site_id,
|
||||
name
|
||||
})
|
||||
})
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart($item, date) {
|
||||
const timeString = $item('div > span').text().trim()
|
||||
const dateString = `${date.format('MM/DD/YYYY')} ${timeString}`
|
||||
|
||||
return DateTime.fromFormat(dateString, 'MM/dd/yyyy HH.mm', { zone: 'Europe/Prague' }).toUTC()
|
||||
}
|
||||
|
||||
function parseDescription($item) {
|
||||
return $item('a.nazev > div.detail').text().trim()
|
||||
}
|
||||
|
||||
function parseTitle($item) {
|
||||
return $item('a.nazev > div:nth-child(1)').text().trim()
|
||||
}
|
||||
|
||||
function parseItems(buffer) {
|
||||
const string = iconv.decode(buffer, 'win1250')
|
||||
const $ = cheerio.load(string)
|
||||
|
||||
return $('#obsah > div > div.porady > div.porad').toArray()
|
||||
}
|
||||
const cheerio = require('cheerio')
|
||||
const iconv = require('iconv-lite')
|
||||
const { DateTime } = require('luxon')
|
||||
|
||||
module.exports = {
|
||||
site: 'm.tv.sms.cz',
|
||||
days: 2,
|
||||
url: function ({ date, channel }) {
|
||||
return `https://m.tv.sms.cz/index.php?stanice=${channel.site_id}&cas=0&den=${date.format(
|
||||
'YYYY-MM-DD'
|
||||
)}`
|
||||
},
|
||||
parser: function ({ buffer, date }) {
|
||||
const programs = []
|
||||
const items = parseItems(buffer)
|
||||
items.forEach(item => {
|
||||
const prev = programs[programs.length - 1]
|
||||
const $item = cheerio.load(item)
|
||||
let start = parseStart($item, date)
|
||||
if (prev) {
|
||||
if (start < prev.start) {
|
||||
start = start.plus({ days: 1 })
|
||||
date = date.add(1, 'd')
|
||||
}
|
||||
prev.stop = start
|
||||
}
|
||||
const stop = start.plus({ hours: 1 })
|
||||
programs.push({
|
||||
title: parseTitle($item),
|
||||
description: parseDescription($item),
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
},
|
||||
async channels() {
|
||||
const axios = require('axios')
|
||||
const data = await axios
|
||||
.get('https://m.tv.sms.cz/?zmen_stanice=true')
|
||||
.then(r => r.data)
|
||||
.catch(console.log)
|
||||
|
||||
let channels = []
|
||||
const $ = cheerio.load(data)
|
||||
$('.stanice').each((i, el) => {
|
||||
const name = $(el).attr('title')
|
||||
const site_id = $(el).find('input').attr('value').replace(/\|/g, '')
|
||||
|
||||
if (!name) return
|
||||
|
||||
channels.push({
|
||||
lang: 'cs',
|
||||
site_id,
|
||||
name
|
||||
})
|
||||
})
|
||||
|
||||
return channels
|
||||
}
|
||||
}
|
||||
|
||||
function parseStart($item, date) {
|
||||
const timeString = $item('div > span').text().trim()
|
||||
const dateString = `${date.format('MM/DD/YYYY')} ${timeString}`
|
||||
|
||||
return DateTime.fromFormat(dateString, 'MM/dd/yyyy HH.mm', { zone: 'Europe/Prague' }).toUTC()
|
||||
}
|
||||
|
||||
function parseDescription($item) {
|
||||
return $item('a.nazev > div.detail').text().trim()
|
||||
}
|
||||
|
||||
function parseTitle($item) {
|
||||
return $item('a.nazev > div:nth-child(1)').text().trim()
|
||||
}
|
||||
|
||||
function parseItems(buffer) {
|
||||
const string = iconv.decode(buffer, 'win1250')
|
||||
const $ = cheerio.load(string)
|
||||
|
||||
return $('#obsah > div > div.porady > div.porad').toArray()
|
||||
}
|
||||
|
||||
@@ -1,57 +1,57 @@
|
||||
const { parser, url } = require('./m.tv.sms.cz.config.js')
|
||||
const iconv = require('iconv-lite')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
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('2023-06-11', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: 'Cero',
|
||||
xmltv_id: '0.es'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://m.tv.sms.cz/index.php?stanice=Cero&cas=0&den=2023-06-11'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
|
||||
const buffer = iconv.encode(content, 'win1250')
|
||||
const results = parser({ buffer, date }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2023-06-11T03:21:00.000Z',
|
||||
stop: '2023-06-11T04:08:00.000Z',
|
||||
title: 'Conspiraciones al descubierto: La bomba atómica alemana y el hundimiento del Titanic',
|
||||
description: 'Documentales'
|
||||
})
|
||||
|
||||
expect(results[25]).toMatchObject({
|
||||
start: '2023-06-12T02:23:00.000Z',
|
||||
stop: '2023-06-12T03:23:00.000Z',
|
||||
title: 'Rapa I (6)',
|
||||
description: 'Series'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
buffer: iconv.encode(
|
||||
Buffer.from(
|
||||
'<!DOCTYPE html><html><head></head><body><textarea data-jtrt-table-id="508" id="jtrt_table_settings_508" cols="30" rows="10"></textarea></body></html>'
|
||||
),
|
||||
'win1250'
|
||||
)
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
const { parser, url } = require('./m.tv.sms.cz.config.js')
|
||||
const iconv = require('iconv-lite')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
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('2023-06-11', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: 'Cero',
|
||||
xmltv_id: '0.es'
|
||||
}
|
||||
|
||||
it('can generate valid url', () => {
|
||||
expect(url({ channel, date })).toBe(
|
||||
'https://m.tv.sms.cz/index.php?stanice=Cero&cas=0&den=2023-06-11'
|
||||
)
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
|
||||
const buffer = iconv.encode(content, 'win1250')
|
||||
const results = parser({ buffer, date }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2023-06-11T03:21:00.000Z',
|
||||
stop: '2023-06-11T04:08:00.000Z',
|
||||
title: 'Conspiraciones al descubierto: La bomba atómica alemana y el hundimiento del Titanic',
|
||||
description: 'Documentales'
|
||||
})
|
||||
|
||||
expect(results[25]).toMatchObject({
|
||||
start: '2023-06-12T02:23:00.000Z',
|
||||
stop: '2023-06-12T03:23:00.000Z',
|
||||
title: 'Rapa I (6)',
|
||||
description: 'Series'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const result = parser({
|
||||
buffer: iconv.encode(
|
||||
Buffer.from(
|
||||
'<!DOCTYPE html><html><head></head><body><textarea data-jtrt-table-id="508" id="jtrt_table_settings_508" cols="30" rows="10"></textarea></body></html>'
|
||||
),
|
||||
'win1250'
|
||||
)
|
||||
})
|
||||
expect(result).toMatchObject([])
|
||||
})
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
# m.tv.sms.cz
|
||||
|
||||
https://m.tv.sms.cz/
|
||||
|
||||
### Download the guide
|
||||
|
||||
Windows (Command Prompt):
|
||||
|
||||
```sh
|
||||
SET "NODE_OPTIONS=--tls-cipher-list=DEFAULT@SECLEVEL=0" && npm run grab --- --site=m.tv.sms.cz
|
||||
```
|
||||
|
||||
Windows (PowerShell):
|
||||
|
||||
```sh
|
||||
$env:NODE_OPTIONS="--tls-cipher-list=DEFAULT@SECLEVEL=0"; npm run grab --- --site=m.tv.sms.cz
|
||||
```
|
||||
|
||||
Linux and macOS:
|
||||
|
||||
```sh
|
||||
NODE_OPTIONS='--tls-cipher-list=DEFAULT@SECLEVEL=0' npm run grab --- --site=m.tv.sms.cz
|
||||
```
|
||||
|
||||
### Update channel list
|
||||
|
||||
Windows (Command Prompt):
|
||||
|
||||
```sh
|
||||
SET "NODE_OPTIONS=--tls-cipher-list=DEFAULT@SECLEVEL=0" && npm run channels:parse --- --config=./sites/m.tv.sms.cz/m.tv.sms.cz.config.js --output=./sites/m.tv.sms.cz/m.tv.sms.cz.channels.xml
|
||||
```
|
||||
|
||||
Windows (PowerShell):
|
||||
|
||||
```sh
|
||||
$env:NODE_OPTIONS="--tls-cipher-list=DEFAULT@SECLEVEL=0"; npm run channels:parse --- --config=./sites/m.tv.sms.cz/m.tv.sms.cz.config.js --output=./sites/m.tv.sms.cz/m.tv.sms.cz.channels.xml
|
||||
```
|
||||
|
||||
Linux and macOS:
|
||||
|
||||
```sh
|
||||
NODE_OPTIONS='--tls-cipher-list=DEFAULT@SECLEVEL=0' npm run channels:parse --- --config=./sites/m.tv.sms.cz/m.tv.sms.cz.config.js --output=./sites/m.tv.sms.cz/m.tv.sms.cz.channels.xml
|
||||
```
|
||||
|
||||
### Test
|
||||
|
||||
```sh
|
||||
npm test --- m.tv.sms.cz
|
||||
```
|
||||
# m.tv.sms.cz
|
||||
|
||||
https://m.tv.sms.cz/
|
||||
|
||||
### Download the guide
|
||||
|
||||
Windows (Command Prompt):
|
||||
|
||||
```sh
|
||||
SET "NODE_OPTIONS=--tls-cipher-list=DEFAULT@SECLEVEL=0" && npm run grab --- --site=m.tv.sms.cz
|
||||
```
|
||||
|
||||
Windows (PowerShell):
|
||||
|
||||
```sh
|
||||
$env:NODE_OPTIONS="--tls-cipher-list=DEFAULT@SECLEVEL=0"; npm run grab --- --site=m.tv.sms.cz
|
||||
```
|
||||
|
||||
Linux and macOS:
|
||||
|
||||
```sh
|
||||
NODE_OPTIONS='--tls-cipher-list=DEFAULT@SECLEVEL=0' npm run grab --- --site=m.tv.sms.cz
|
||||
```
|
||||
|
||||
### Update channel list
|
||||
|
||||
Windows (Command Prompt):
|
||||
|
||||
```sh
|
||||
SET "NODE_OPTIONS=--tls-cipher-list=DEFAULT@SECLEVEL=0" && npm run channels:parse --- --config=./sites/m.tv.sms.cz/m.tv.sms.cz.config.js --output=./sites/m.tv.sms.cz/m.tv.sms.cz.channels.xml
|
||||
```
|
||||
|
||||
Windows (PowerShell):
|
||||
|
||||
```sh
|
||||
$env:NODE_OPTIONS="--tls-cipher-list=DEFAULT@SECLEVEL=0"; npm run channels:parse --- --config=./sites/m.tv.sms.cz/m.tv.sms.cz.config.js --output=./sites/m.tv.sms.cz/m.tv.sms.cz.channels.xml
|
||||
```
|
||||
|
||||
Linux and macOS:
|
||||
|
||||
```sh
|
||||
NODE_OPTIONS='--tls-cipher-list=DEFAULT@SECLEVEL=0' npm run channels:parse --- --config=./sites/m.tv.sms.cz/m.tv.sms.cz.config.js --output=./sites/m.tv.sms.cz/m.tv.sms.cz.channels.xml
|
||||
```
|
||||
|
||||
### Test
|
||||
|
||||
```sh
|
||||
npm test --- m.tv.sms.cz
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user