/japanterebi-xmltv

Easily create XMLTV files

Primary LanguagePythonMIT LicenseMIT

japanterebi-xmltv

Sakayanagi

Easily create XMLTV files.

Plan your watching journey!



EPG Update GitHub — License GitHub top language Code Size Repo Size Issues

Usage

API

You can use the https://animenosekai.github.io/japanterebi-xmltv/guide.xml URL as an XMLTV source in any compatible software.

This pre-built XMLTV file contains EPG data for channels from Japan or with Japanese audio.

run: python scripts/filter.py --input database/data/channels.csv --language="jpn" --country="JP" --minify channels.json

This file is updated every hour using GitHub Actions.

But you can also build your own XMLTV file using the different scripts provided in this repository.

Pre-requisites

The different programs located in the scripts directory require Python 3.7 to run correctly.

The dependencies are listed in the requirements.txt file. You can install them by running:

python -m pip install -r requirements.txt --upgrade

Scripts

Filter

The filter.py script filters the different channels from the iptv-org/database repository.

To download the repository, you can run the following command:

git clone --depth 1 -b main https://github.com/iptv-org/database.git
CLI

You can run the script with the following command:

python scripts/filter.py --input <database/data/channels.csv> <output_path.json>

database/data/channels.csv is the path to the channels CSV file from the iptv-org/database repository.

You can specify :

  • --language to filter the channels by language
  • --country to filter the channels by country
  • --category to filter the channels by category

You can use those options multiple times to filter the channels by multiple criteria.

The different filters add up, and a union is made between the different filters.

You can also directly use the --add or --remove options to add or remove channels IDs from the list.

Here is an example output :

[
    {
        "id": "ABEMAAnime.jp",
        "name": "ABEMA Anime",
        "alt_names": [
            "ABEMAアニメ"
        ],
        "network": null,
        "owners": [],
        "country": "JP",
        "subdivision": null,
        "city": "Shibuya-ku",
        "broadcast_area": "c/JP",
        "languages": [
            "jpn"
        ],
        "categories": [
            "animation",
            "kids"
        ],
        "is_nsfw": false,
        "launched": 1522540800.0,
        "closed": null,
        "replaced_by": null,
        "website": "https://abema.tv/now-on-air/abema-anime?lang=en",
        "logo": "https://i.imgur.com/OfqTpK6.png"
    }
]

Here is the command used in the workflow:

- name: Getting the channels ID
run: python scripts/filter.py --input database/data/channels.csv --language="jpn" --country="JP" --minify channels.json

Python

You can also use the script as a Python module. It provides a way to convert the CSV file to a list of Channel objects, which can easily be manipulated.

Fetcher

The fetcher.py gathers the different EPG sites which can be used to create the final EPG.

You need to download the iptv-org/epg repository to get the different EPG sites first.

git clone --depth 1 -b master https://github.com/iptv-org/epg.git

Then you can run the script with the following command:

python scripts/fetcher.py --input <input_path.json> --sites epg/sites <output_path.xml>

The input_path.json file should contain the list of channels you want to fetch. It should be generated by the filter.py script.

Here is the command used in the workflow:

- name: Filtering the channels
run: python scripts/fetcher.py --input channels.json --sites epg/sites japanterebi.channels.xml

The output is an XML file which can be used with the grab command from the iptv-org/epg repository.

npm run grab -- --channels=<output_path.xml>

Fixer

Because sometimes the EPG sites return non-escaped & characters, the fix.py script fixes the XML file by correctly escaping those characters.

You can run the script with the following command:

python scripts/fix.py --input <input_path.xml> <output_path.xml>

Here is the command used in the workflow:

- name: Fixing the document
run: python scripts/fix.py --input guide.xml guide.xml

Merger

Because the grab command gathers information from different EPG sites, the final EPG has multiple redundant entries.

The merger.py script merges the different EPG entries into a single one.

You can run the script with the following command:

python scripts/merger.py --input <input_path.xml> <output_path.xml>

The input_path.xml file should be the output of the grab command, or an equivalent XMLTV-formatted file.

Here is the command used in the workflow:

- name: Merging redundant programs
run: python scripts/merger.py --input guide.xml guide.xml

Minifier

The minify.py script simply minfies the XMLTV file.

You can run the script with the following command:

python scripts/minify.py --input <input_path.xml> <output_path.xml>

Note

Note that it just removes empty lines for now.

Here is the command used in the workflow:

- name: Minify XML
run: python scripts/minify.py --input guide.xml guide.xml