Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,41 @@
name: Continuous Integration

on:
pull_request:
branches:
- main

jobs:
build:
name: Build
build-docker:
name: Build Docker
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Build service
run: docker build .

build-lint-test:
name: Build, Lint, and Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: package.json

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Lint
run: npm run lint

- name: Test
run: npm run test:run
8 changes: 8 additions & 0 deletions .github/workflows/release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"packages": {
".": {
"release-type": "simple",
"package-name": "zap2xml"
}
}
}
7 changes: 2 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@ jobs:
uses: actions/checkout@v4

- name: Setup release please
uses: google-github-actions/release-please-action@v2
uses: googleapis/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: simple
changelog-path: CHANGELOG.md
package-name: zap2xml
config-file: .github/workflows/release-please-config.json

- name: Login into GitHub Container Registry
if: ${{ steps.release.outputs.release_created }}
Expand Down
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.zap2xmlrc
build/
node_modules/

config/
xmltv/
compose.yaml

xmltv.xml
57 changes: 0 additions & 57 deletions .zap2xmlrc-example

This file was deleted.

25 changes: 12 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
FROM alpine:3.13.5
FROM node:22.17.1-alpine3.22

ENV SLEEPTIME=43200
WORKDIR /app

RUN apk add --no-cache \
perl \
perl-http-cookies \
perl-lwp-useragent-determined \
perl-json \
perl-json-xs \
perl-lwp-protocol-https \
perl-gd
COPY package.json package.json
COPY package-lock.json package-lock.json

WORKDIR /opt
RUN npm ci

COPY zap2xml.pl zap2xml.pl
COPY tsconfig.json tsconfig.json
COPY entrypoint.sh entrypoint.sh
COPY src/ src/

ENTRYPOINT ["./entrypoint.sh"]
RUN npm run build

RUN ls -l /app

ENTRYPOINT ["/bin/sh", "-c", "/app/entrypoint.sh"]
114 changes: 46 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,90 +1,68 @@
# zap2xml

See [zap2xml](https://web.archive.org/web/20200426004001/zap2xml.awardspace.info/) for original Perl script and guidance for the configuration file.
See [zap2xml](https://web.archive.org/web/20200426004001/zap2xml.awardspace.info/) for original Perl script and guidance
for the configuration file.

## Docker
## How to use

### Retrieving your Lineup ID

Visit the [Retrieving Lineup ID](https://github.com/jef/zap2xml/wiki/Retrieving-Lineup-ID) in the Wiki.

### Node.js

```bash
npm i && npm run dev
```

See [Command line arguments](#command-line-arguments) for configuration options.

### Docker

| Tag | Description |
| ------- | ----------------------- |
| latest | Stable zap2xml releases |
| nightly | HEAD zap2xml release |

### docker-compose (recommended)
#### docker-compose

```yaml
services:
zap2xml:
container_name: zap2xml
image: ghcr.io/jef/zap2xml:latest
environment:
OPT_ARGS: >-
-I -D -C /config/.zap2xmlrc -o /xmltv/xmltv.xml
TZ: America/New_York # Consider using your timezone
OUTPUT_FILE: /xmltv/xmltv.xml
volumes:
- /path/to/zap2xml/config:/config
- /path/to/xmltv:/xmltv # nice for mapping other drives to this that may use xmltv.xml
- ./xmltv:/xmltv
restart: unless-stopped
```

See [Environment variables](#environment-variables) for configuration options.

## Configuration

### Optional environment variables

| Variable | Description | Type | Default |
| ------------ | ---------------------------------------------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------- |
| `USER_AGENT` | Custom user agent string for HTTP requests. | String | `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36` |
| `SLEEPTIME` | Number of seconds to sleep between runs (useful for scheduling in Docker or cron). | Integer | `43200` |
| `TZ` | Timezone for program times (affects output XML and Perl's time calculations). | String | System default |

### Optional run configurations

| Option | Type | Default | Description | Config File | Command Line |
| ---------------- | --------- | ----------- | ------------------------------------------------------ | ----------------------------- | ------------ |
| `start` | Integer | `0` | Number of days to offset from today for the start date | `start=1` | `-s` |
| `days` | Integer | `7` | Number of days of program data to fetch | `days=14` | `-d` |
| `retries` | Integer | `3` | Number of connection retries before failure (max 20) | `retries=5` | `-r` |
| `user` | String | (empty) | Username/email for Zap2it account | `[email protected]` | `-u` |
| `pass` | String | (empty) | Password for Zap2it account | `pass=mypassword` | `-p` |
| `cache` | Directory | `cache` | Directory to store cached data files | `cache=/config/cache` | `-c` |
| `ncdays` | Integer | `0` | Number of days from the end to not cache | `ncdays=2` | `-n` |
| `ncsdays` | Integer | `0` | Number of days from the start to not cache | `ncsdays=1` | `-N` |
| `ncmday` | Integer | `-1` | Specific day number to not cache (1-based) | `ncmday=3` | `-B` |
| `outfile` | File path | `xmltv.xml` | Output XML file path | `outfile=/xmltv/xmltv.xml` | `-o` |
| `outformat` | String | `xmltv` | Output format (xmltv/xtvd) | `outformat=xtvd` | `-x` |
| `lang` | String | `en` | Language code for program data | `lang=es` | `-l` |
| `icon` | Directory | (disabled) | Directory to store channel icons | `icon=/config/icons` | `-i` |
| `trailer` | Directory | (disabled) | Directory to store movie trailers | `trailer=/config/trailers` | `-t` |
| `proxy` | URL | (none) | HTTP proxy server URL | `proxy=http://localhost:8080` | `-P` |
| `lineuptype` | String | (none) | Type of lineup (XTVD only) | `lineuptype=Cable` | - |
| `lineupname` | String | (none) | Name of the lineup (XTVD only) | `lineupname=My Provider` | - |
| `lineuplocation` | String | (none) | Location of the lineup (XTVD only) | `lineuplocation=New York, NY` | - |
| `lineupid` | String | (none) | Lineup ID for TV Guide | `lineupid=X:80000` | `-Y` |
| `postalcode` | String | (none) | Postal code for TV Guide | `postalcode=01010` | `-Z` |
| `shiftMinutes` | Integer | `0` | Offset program times by minutes | - | `-m` |
| `sleeptime` | Integer | `0` | Sleep between requests (seconds) | - | `-S` |
| `allChan` | Boolean | `false` | Output all channels (not just favorites) | - | `-a` |
| `outputXTVD` | Boolean | `false` | Force XTVD output format | - | `-x` |
| `includeDetails` | Boolean | `false` | Include program details (extra requests) | - | `-D` |
| `includeIcons` | Boolean | `false` | Include program icons (extra requests) | - | `-I` |
| `retainOrder` | Boolean | `false` | Retain website channel order | - | `-b` |
| `quiet` | Boolean | `false` | Quiet mode (no status output) | - | `-q` |
| `wait` | Boolean | `false` | Wait on exit (require keypress) | - | `-w` |
| `hexEncode` | Boolean | `false` | Hex encode HTML entities | - | `-e` |
| `utf8` | Boolean | `false` | UTF-8 encoding (default: ISO-8859-1) | - | `-U` |
| `liveTag` | Boolean | `false` | Output `<live />` tag | - | `-L` |
| `noTBA` | Boolean | `false` | Don't cache files with "TBA" titles | - | `-T` |
| `channelFirst` | Boolean | `false` | Output channel names first | - | `-F` |
| `oldStyle` | Boolean | `false` | Use old tv_grab_na style channel IDs | - | `-O` |
| `appendFlags` | String | (none) | Append flags to program titles | - | `-A` |
| `copyYear` | Boolean | `false` | Copy movie_year to sub-title tags | - | `-M` |
| `addSeries` | Boolean | `false` | Add "series" category to non-movies | - | `-j` |
| `includeXMLTV` | File | (none) | Include XMLTV file in output | - | `-J` |
| `useTVGuide` | Boolean | `false` | Use tvguide.com instead of gracenote.com | - | `-z` |

### Notes

- Configuration file values can be overridden by command line options
- The configuration file supports comments (lines starting with `#`)
- Empty lines are ignored
- Values are trimmed of leading/trailing whitespace
- Boolean options (like `outformat=xtvd`) are case-insensitive
### Environment variables

| Variable | Description | Type | Default |
| ------------- | --------------------------------------------------------------------------------------------------------------- | ------- | -------------------------------- |
| `LINEUP_ID` | Lineup ID; You can find this at https://tvlistings.gracenote.com/grid-affiliates.html?aid=orbebb | String | `USA-lineupId-DEFAULT` (Attenna) |
| `TIMESPAN` | Either 3 or 6 hours of shows | Integer | 3 |
| `PREF` | User Preferences, comma separated list. `m` for showing music, `p` for showing pay-per-view, `h` for showing HD | String | (empty) |
| `POSTAL_CODE` | Postal code of where shows are available. | Integer | 30309 |
| `USER_AGENT` | Custom user agent string for HTTP requests. | String | Uses random if not specified |
| `TZ` | Timezone | String | System default |
| `SLEEP_TIME` | Sleep time before next run in seconds (default: 10800, Only used with Docker.) | Integer | 10800 |
| `OUTPUT_FILE` | Output file name (default: xmltv.xml) | String | xmltv.xml |

### Command line arguments

| Argument | Description | Type | Default |
| -------------- | --------------------------------------------------------------------------------------------------------------- | ------- | -------------------------------- |
| `--lineupId` | Lineup ID; You can find this at https://tvlistings.gracenote.com/grid-affiliates.html?aid=orbebb | String | `USA-lineupId-DEFAULT` (Attenna) |
| `--timespan` | Either 3 or 6 hours of shows | Integer | 3 |
| `--pref` | User Preferences, comma separated list. `m` for showing music, `p` for showing pay-per-view, `h` for showing HD | String | (empty) |
| `--postalCode` | Postal code of where shows are available. | Integer | 30309 |
| `--userAgent` | Custom user agent string for HTTP requests. | String | Uses random if not specified |
| `--timezone` | Timezone | String | System default |
| `--outputFile` | Output file name (default: xmltv.xml) | String | xmltv.xml |
12 changes: 7 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/sh

SLEEP_TIME=${SLEEP_TIME:-10800}

while true; do
DATE=$(date)
eval /opt/zap2xml.pl "$OPT_ARGS"
echo "Last run time: $DATE"
echo "Will run in $SLEEPTIME seconds"
sleep "$SLEEPTIME"
DATE=$(date)
node build/src/index.js
echo "Last run time: $DATE"
echo "Will run in $((SLEEP_TIME / 60)) minutes"
sleep "$SLEEP_TIME"
done
15 changes: 15 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// @ts-check

import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import prettierConfig from "eslint-plugin-prettier/recommended";

export default tseslint.config(
eslint.configs.recommended,
tseslint.configs.strict,
tseslint.configs.stylistic,
prettierConfig,
{
ignores: ["build"],
},
);
Loading