Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/freearhey/epg-parser
Node.js CLI tool to parse EPG files
https://github.com/freearhey/epg-parser
Last synced: 16 days ago
JSON representation
Node.js CLI tool to parse EPG files
- Host: GitHub
- URL: https://github.com/freearhey/epg-parser
- Owner: freearhey
- License: mit
- Created: 2019-10-29T16:26:18.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-24T07:02:50.000Z (11 months ago)
- Last Synced: 2024-10-12T06:33:13.254Z (about 1 month ago)
- Language: JavaScript
- Size: 2.34 MB
- Stars: 12
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# epg-parser [![Build Status](https://app.travis-ci.com/freearhey/epg-parser.svg?branch=master)](https://app.travis-ci.com/freearhey/epg-parser)
It parses EPG XMLTV files and converts it to a regular JavaScript object.
## Installation
```sh
npm install epg-parser
```## Usage
```js
import fs from 'fs'
import parser from 'epg-parser'const epg = fs.readFileSync('./epg.xml', { encoding: 'utf-8' })
const result = parser.parse(epg)console.log(result)
```## Example
Input:
```xml
13 KERA
13
https://example.com/channel_one
https://example.com/channel_one_alternate
36
NOW on PBS
Pilot
Jordan's Queen Rania has made job creation a priority to help curb the staggering unemployment rates among youths in the Middle East.
20080711
Newsmagazine
Interview
physical-comedy
romantic
English
French
60
https://example.com/programme_one
https://example.com/programme_one_2
US
EP01006886.0028
427
yes
no
16:9
HDTV
yes
Dolby Digital
First time on British TV
Last time on this channel
English
Spanish
15
NC-17
4/5
8/10
This is a fantastic show!
I love this show!
https://example.com/programme_one_review
https://tvdb.com/programme_one_poster_1.jpg
https://tmdb.com/programme_one_poster_2.jpg
https://tvdb.com/programme_one_backdrop_3.jpg
https://tmdb.com/programme_one_backdrop_3.jpg
David Thompson
Ryan Lee
https://example.com/xxx.jpg
https://example.com/person/204
Bart Eskander
Roger Dobkowitz
Drew Carey
```
Output:
```js
{
channels: [
{
id: 'I10436.labs.zap2it.com',
displayName: [
{
lang: 'fr',
value: '13 KERA'
},
{
lang: 'ar',
value: '13'
}
],
icon: [{ src: 'https://example.com/channel_one_icon.jpg', width: '100', height: '100' }],
url: [
{ system: 'example', value: 'https://example.com/channel_one' },
{ system: 'other_system', value: 'https://example.com/channel_one_alternate' }
],
lcn: [{ value: '36' }]
}
],
programs: [
{
start: '2008-07-15T06:30:00.000Z',
stop: '2008-07-15T07:00:00.000Z',
channel: 'I10436.labs.zap2it.com',
title: [{ lang: 'en', value: 'NOW on PBS' }],
subTitle: [{ lang: 'en', value: 'Pilot' }],
desc: [
{
lang: 'en',
value:
"Jordan's Queen Rania has made job creation a priority to help curb the staggering unemployment rates among youths in the Middle East."
}
],
date: '20080711',
category: [
{ lang: 'en', value: 'Newsmagazine' },
{ lang: 'en', value: 'Interview' }
],
keyword: [
{ lang: 'en', value: 'physical-comedy' },
{ lang: 'en', value: 'romantic' }
],
language: [{ value: 'English' }],
origLanguage: [{ lang: 'en', value: 'French' }],
length: [{ units: 'minutes', value: '60' }],
url: [
{ system: 'imdb', value: 'https://example.com/programme_one' },
{ value: 'https://example.com/programme_one_2' }
],
country: [{ value: 'US' }],
video: {
present: 'yes',
colour: 'no',
aspect: '16:9',
quality: 'HDTV'
},
audio: {
present: 'yes',
stereo: 'Dolby Digital'
},
episodeNum: [
{ system: 'dd_progid', value: 'EP01006886.0028' },
{ system: 'onscreen', value: '427' }
],
previouslyShown: [{ start: '20080711000000', channel: 'channel-two.tv' }],
premiere: [{ value: 'First time on British TV' }],
lastChance: [{ lang: 'en', value: 'Last time on this channel' }],
new: true,
subtitles: [
{ type: 'teletext', language: [{ value: 'English' }] },
{ type: 'onscreen', language: [{ lang: 'en', value: 'Spanish' }] }
],
rating: [
{
system: 'BBFC',
value: '15'
},
{
system: 'MPAA',
value: 'NC-17',
icon: [{ src: 'NC-17_symbol.png' }]
}
],
starRating: [
{
system: 'TV Guide',
value: '4/5',
icon: [{ src: 'stars.png' }]
},
{
system: 'IMDB',
value: '8/10'
}
],
review: [
{
type: 'text',
source: 'Rotten Tomatoes',
reviewer: 'Joe Bloggs',
lang: 'en',
value: 'This is a fantastic show!'
},
{
type: 'text',
source: 'IDMB',
reviewer: 'Jane Doe',
lang: 'en',
value: 'I love this show!'
},
{
type: 'url',
source: 'Rotten Tomatoes',
reviewer: 'Joe Bloggs',
lang: 'en',
value: 'https://example.com/programme_one_review'
}
],
image: [
{
type: 'poster',
size: '1',
orient: 'P',
system: 'tvdb',
value: 'https://tvdb.com/programme_one_poster_1.jpg'
},
{
type: 'poster',
size: '2',
orient: 'P',
system: 'tmdb',
value: 'https://tmdb.com/programme_one_poster_2.jpg'
},
{
type: 'backdrop',
size: '3',
orient: 'L',
system: 'tvdb',
value: 'https://tvdb.com/programme_one_backdrop_3.jpg'
},
{
type: 'backdrop',
size: '3',
orient: 'L',
system: 'tmdb',
value: 'https://tmdb.com/programme_one_backdrop_3.jpg'
}
],
credits: {
actor: [
{},
{
role: 'Walter Johnson',
value: 'David Thompson'
},
{
role: 'Karl James',
guest: 'yes',
value: 'Ryan Lee',
image: [{ type: 'person', value: 'https://example.com/xxx.jpg' }],
url: [{ system: 'moviedb', value: 'https://example.com/person/204' }]
}
],
director: [
{
value: 'Bart Eskander'
}
],
producer: [
{
value: 'Roger Dobkowitz'
}
],
presenter: [{ value: 'Drew Carey' }]
},
icon: [
{
width: '100',
height: '100',
src: 'http://imageswoapi.whatsonindia.com/WhatsOnTV/images/ProgramImages/xlarge/38B4DE4E9A7132257749051B6C8B4F699DB264F4V.jpg'
}
]
}
]
}
```## Upgrading to v0.3.0 from v0.2.\*
To get the same result as in previous versions you need to modify some queries:
- `channel.name` => `channel.displayName`
- `channel.icon[0]` => `channel.icon[0].src`
- `channel.url[0]` => `channel.url[0].value`
- `program.icon[0]` => `program.icon[0].src`
- `program.date[0]` => `program.date`
- `program.credits[0].name` => `program.credits.actor[0].name`## Testing
```sh
npm test
```## Contribution
If you find a bug or want to contribute to the code or documentation, you can help by submitting an [issue](https://github.com/freearhey/epg-parser/issues) or a [pull request](https://github.com/freearhey/epg-parser/pulls).
## License
[MIT](LICENSE)