2024-12-30 09:38:09 +03:00
# EPG [](https://github.com/iptv-org/epg/actions/workflows/update.yml)
2022-10-22 06:12:11 +03:00
2023-10-02 06:35:58 +03:00
Tools for downloading the EPG (Electronic Program Guide) for thousands of TV channels from hundreds of sources.
2022-10-22 06:12:11 +03:00
2023-01-19 14:47:22 +03:00
## Table of contents
2023-10-02 06:35:58 +03:00
- ✨ [Installation ](#installation )
- 🚀 [Usage ](#usage )
2025-01-02 13:59:26 +03:00
- ⚙️ [Configuration ](#configuration )
2023-10-02 06:35:58 +03:00
- 💫 [Update ](#update )
2025-01-02 13:59:26 +03:00
- 🌎 [Serve ](#serve )
- 🐋 [Docker ](#docker )
2023-01-19 14:47:22 +03:00
- 📺 [Playlists ](#playlists )
- 🗄 [Database ](#database )
- 👨💻 [API ](#api )
- 📚 [Resources ](#resources )
- 💬 [Discussions ](#discussions )
- 🛠 [Contribution ](#contribution )
2023-10-02 06:35:58 +03:00
- 📄 [License ](#license )
2022-10-22 06:12:11 +03:00
2023-10-02 06:35:58 +03:00
## Installation
2022-10-22 06:12:11 +03:00
2023-10-02 06:35:58 +03:00
First, you need to install [Node.js ](https://nodejs.org/en ) on your computer. You will also need to install [Git ](https://git-scm.com/downloads ) to follow these instructions.
2023-01-14 12:17:06 +03:00
2023-10-02 06:35:58 +03:00
After that open the [Console ](https://en.wikipedia.org/wiki/Windows_Console ) (or [Terminal ](<https://en.wikipedia.org/wiki/Terminal_(macOS )>) if you have macOS) and type the following command:
2023-01-11 12:56:31 +03:00
2023-05-15 20:56:02 +03:00
```sh
git clone --depth 1 -b master https://github.com/iptv-org/epg.git
```
2023-01-11 12:56:31 +03:00
2023-10-02 06:35:58 +03:00
Then navigate to the downloaded `epg` folder:
2023-02-01 12:26:24 +03:00
2023-05-15 20:56:02 +03:00
```sh
cd epg
```
2023-02-01 12:26:24 +03:00
2023-10-02 06:35:58 +03:00
And install all the dependencies:
2023-01-11 12:56:31 +03:00
2023-05-15 20:56:02 +03:00
```sh
npm install
```
2023-01-11 12:56:31 +03:00
2023-10-02 06:35:58 +03:00
## Usage
2025-01-02 13:59:26 +03:00
To start the download of the guide, select one of the supported sites from [SITES.md ](SITES.md ) file and paste its name into the command below:
2023-02-01 12:26:24 +03:00
2023-05-15 20:56:02 +03:00
```sh
2024-12-15 17:32:49 +03:00
npm run grab --- --site=example.com
2023-07-19 04:17:05 +03:00
```
2025-01-02 13:59:26 +03:00
Then run it and wait for the guide to finish downloading. When finished, a new `guide.xml` file will appear in the current directory.
## Configuration
To customize `grab` behavior, you can add a few more options at the end of the command:
2023-07-19 04:17:05 +03:00
```sh
2024-12-15 17:32:49 +03:00
Usage: npm run grab --- [options]
2023-10-02 06:35:58 +03:00
Options:
-s, --site <name> Name of the site to parse
-c, --channels <path> Path to *.channels.xml file (required if the "--site" attribute is
not specified)
-o, --output <path> Path to output file (default: "guide.xml")
2025-01-02 13:59:26 +03:00
-l, --lang <code> Allows to limit the download to channels in the specified language only (ISO 639-2 code)
-t, --timeout <milliseconds> Timeout for each request in milliseconds (default: 0)
-d, --delay <milliseconds> Delay between request in milliseconds (default: 0)
--days <days> Number of days for which the program will be loaded (defaults to the value from the site config)
--maxConnections <number> Number of concurrent requests (default: 1)
--gzip Specifies whether or not to create a compressed version of the guide (default: false)
2023-07-19 22:38:48 +03:00
```
2023-10-02 06:35:58 +03:00
### Parallel downloading
By default, the guide for each channel is downloaded one by one, but you can change this behavior by increasing the number of simultaneous requests using the `--maxConnections` attribute:
2023-07-19 22:38:48 +03:00
```sh
2024-12-15 17:32:49 +03:00
npm run grab --- --site=example.com --maxConnections=10
2023-05-15 20:56:02 +03:00
```
2023-02-01 12:26:24 +03:00
2023-10-02 06:35:58 +03:00
But be aware that under heavy load, some sites may start return an error or completely block your access.
2023-02-01 12:26:24 +03:00
2023-10-02 06:35:58 +03:00
### Use custom channel list
Create an XML file and copy the descriptions of all the channels you need from the [/sites ](sites ) into it:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<channels>
<channel site="arirang.com" lang="en" xmltv_id="ArirangTV.kr" site_id="CH_K">Arirang TV</channel>
...
</channels>
2023-05-15 20:56:02 +03:00
```
2023-02-01 12:26:24 +03:00
2023-10-02 06:35:58 +03:00
And then specify the path to that file via the `--channels` attribute:
2023-02-01 12:26:24 +03:00
2023-10-02 06:35:58 +03:00
```sh
2024-12-15 17:32:49 +03:00
npm run grab --- --channels=path/to/custom.channels.xml
2023-05-15 20:56:02 +03:00
```
2023-10-02 06:35:58 +03:00
## Update
If you have downloaded the repository code according to the instructions above, then to update it will be enough to run the command:
2023-01-11 12:56:31 +03:00
2023-10-02 06:35:58 +03:00
```sh
git pull
2023-05-15 20:56:02 +03:00
```
2023-10-02 06:35:58 +03:00
And then update all the dependencies:
```sh
npm install
2023-05-15 20:56:02 +03:00
```
2023-01-19 14:47:22 +03:00
2025-01-02 13:59:26 +03:00
## Serve
You can make the guide available via URL by running your own server:
```sh
npm run serve
```
After that, the guide will be available at the link:
```
http://localhost:3000/guide.xml
```
In addition it will be available to other devices on the same local network at the address:
```
http://<your_local_ip_address>:3000/guide.xml
```
## Docker
### Build an image
```sh
docker build -t iptv-org/epg --no-cache .
```
### Create and run container
```sh
docker run -p 3000:3000 -v /path/to/channels.xml:/epg/channels.xml iptv-org/epg
```
By default, the guide will be downloaded every day at 00:00 UTC and saved to the `/epg/public/guide.xml` file inside the container.
From the outside, it will be available at this link:
```
http://localhost:3000/guide.xml
```
or
```
http://<your_local_ip_address>:3000/guide.xml
```
### Environment Variables
To fine-tune the execution, you can pass environment variables to the container as follows:
```sh
docker run \
-p 5000:3000 \
-v /path/to/channels.xml:/epg/channels.xml \
-e CRON_SCHEDULE="0 0,12 * * *" \
-e MAX_CONNECTIONS=10 \
-e GZIP=true \
-e DAYS=14 \
-e TIMEOUT=5 \
-e DELAY=2 \
iptv-org/epg
```
| Variable | Description |
| --------------- | ------------------------------------------------------------------------------------------------------------------ |
| CRON_SCHEDULE | A [cron expression ](https://crontab.guru/ ) describing the schedule of the guide loadings (default: "0 0 \* \* \*") |
| MAX_CONNECTIONS | Limit on the number of concurrent requests (default: 1) |
| GZIP | Boolean value indicating whether to create a compressed version of the guide (default: false) |
| DAYS | Number of days for which the guide will be loaded (defaults to the value from the site config) |
| TIMEOUT | Timeout for each request in milliseconds (default: 0) |
| DELAY | Delay between request in milliseconds (default: 0) |
2023-01-19 14:47:22 +03:00
## Playlists
Playlists with already linked guides can be found in the [iptv-org/iptv ](https://github.com/iptv-org/iptv ) repository.
## Database
All channel data is taken from the [iptv-org/database ](https://github.com/iptv-org/database ) repository. If you find any errors please open a new [issue ](https://github.com/iptv-org/database/issues ) there.
## API
The API documentation can be found in the [iptv-org/api ](https://github.com/iptv-org/api ) repository.
## Resources
Links to other useful IPTV-related resources can be found in the [iptv-org/awesome-iptv ](https://github.com/iptv-org/awesome-iptv ) repository.
## Discussions
2023-01-19 15:16:30 +03:00
If you have a question or an idea, you can post it in the [Discussions ](https://github.com/orgs/iptv-org/discussions ) tab.
2023-01-19 14:47:22 +03:00
2022-10-22 06:12:11 +03:00
## Contribution
2022-11-23 12:36:13 +03:00
Please make sure to read the [Contributing Guide ](https://github.com/iptv-org/epg/blob/master/CONTRIBUTING.md ) before sending [issue ](https://github.com/iptv-org/epg/issues ) or a [pull request ](https://github.com/iptv-org/epg/pulls ).
2023-01-19 14:47:22 +03:00
And thank you to everyone who has already contributed!
### Backers
<a href="https://opencollective.com/iptv-org"><img src="https://opencollective.com/iptv-org/backers.svg?width=890" /></a>
### Contributors
2023-01-19 15:36:16 +03:00
<a href="https://github.com/iptv-org/epg/graphs/contributors"><img src="https://opencollective.com/iptv-org/contributors.svg?width=890" /></a>
2023-01-19 14:47:22 +03:00
## License
[](LICENSE)