Skip to content

Commit 20f6a6b

Browse files
authored
feat: add country for customization
Based on #37
1 parent d6923b0 commit 20f6a6b

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ See [Environment variables](#environment-variables) for configuration options.
4949
| `LINEUP_ID` | Lineup ID; You can find this at https://tvlistings.gracenote.com/grid-affiliates.html?aid=orbebb | String | `USA-lineupId-DEFAULT` (Attenna) |
5050
| `TIMESPAN` | Either 3 or 6 hours of shows | Integer | 3 |
5151
| `PREF` | User Preferences, comma separated list. `m` for showing music, `p` for showing pay-per-view, `h` for showing HD | String | (empty) |
52+
| `COUNTRY` | Country code (default: `US`) | String | US |
5253
| `POSTAL_CODE` | Postal code of where shows are available. | Integer | 30309 |
5354
| `USER_AGENT` | Custom user agent string for HTTP requests. | String | Uses random if not specified |
5455
| `TZ` | Timezone | String | System default |
@@ -62,6 +63,7 @@ See [Environment variables](#environment-variables) for configuration options.
6263
| `--lineupId` | Lineup ID; You can find this at https://tvlistings.gracenote.com/grid-affiliates.html?aid=orbebb | String | `USA-lineupId-DEFAULT` (Attenna) |
6364
| `--timespan` | Either 3 or 6 hours of shows | Integer | 3 |
6465
| `--pref` | User Preferences, comma separated list. `m` for showing music, `p` for showing pay-per-view, `h` for showing HD | String | (empty) |
66+
| `--country` | Country code (default: `US`) | String | US |
6567
| `--postalCode` | Postal code of where shows are available. | Integer | 30309 |
6668
| `--userAgent` | Custom user agent string for HTTP requests. | String | Uses random if not specified |
6769
| `--timezone` | Timezone | String | System default |

src/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ export const config = {
1010
process.env.TIMESPAN ||
1111
process.argv.find((arg) => arg.startsWith("--timespan="))?.split("=")[1] ||
1212
"3",
13+
country:
14+
process.env.COUNTRY ||
15+
process.argv.find((arg) => arg.startsWith("--country="))?.split("=")[1] ||
16+
"USA",
1317
postalCode:
1418
process.env.POSTAL_CODE ||
1519
process.argv

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ Options:
1212
--help Show this help message
1313
--lineupId=ID Lineup ID (default: USA-lineupId-DEFAULT)
1414
--timespan=NUM Timespan in hours (default: 3)
15-
--pref=LIST User preferences, comma separated. Can be m, p, and h (default: empty)
15+
--pref=LIST User preferences, comma separated. Can be m, p, and h (default: empty)'
16+
--country=CON Country code (default: USA)
1617
--postalCode=ZIP Postal code (default: 30309)
1718
--userAgent=UA Custom user agent string (default: Uses random if not specified)
1819
--timezone=TZ Timezone (default: America/New_York)

src/tvlistings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function buildUrl() {
8383
lineupId: config.lineupId,
8484
timespan: config.timespan,
8585
headendId: "lineupId",
86-
country: "USA",
86+
country: config.country,
8787
timezone: config.timezone,
8888
postalCode: config.postalCode,
8989
isOverride: "true",
@@ -109,7 +109,7 @@ export async function getTVListings(): Promise<GridApiResponse> {
109109

110110
if (!response.ok) {
111111
throw new Error(
112-
`Failed to fetch: ${response.status} ${response.statusText}`,
112+
`Failed to fetch: ${response.status} ${response.statusText}`
113113
);
114114
}
115115

0 commit comments

Comments
 (0)