feat: add country for customization

Based on #37
This commit is contained in:
Jef LeCompte
2025-07-18 22:25:01 -07:00
parent 6fa9aee5ee
commit 801b3cf725
4 changed files with 10 additions and 3 deletions

View File

@@ -49,6 +49,7 @@ See [Environment variables](#environment-variables) for configuration options.
| `LINEUP_ID` | Lineup ID; You can find this at https://tvlistings.gracenote.com/grid-affiliates.html?aid=orbebb | String | `USA-lineupId-DEFAULT` (Attenna) | | `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 | | `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) | | `PREF` | User Preferences, comma separated list. `m` for showing music, `p` for showing pay-per-view, `h` for showing HD | String | (empty) |
| `COUNTRY` | Country code (default: `US`) | String | US |
| `POSTAL_CODE` | Postal code of where shows are available. | Integer | 30309 | | `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 | | `USER_AGENT` | Custom user agent string for HTTP requests. | String | Uses random if not specified |
| `TZ` | Timezone | String | System default | | `TZ` | Timezone | String | System default |
@@ -62,6 +63,7 @@ See [Environment variables](#environment-variables) for configuration options.
| `--lineupId` | Lineup ID; You can find this at https://tvlistings.gracenote.com/grid-affiliates.html?aid=orbebb | String | `USA-lineupId-DEFAULT` (Attenna) | | `--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 | | `--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) | | `--pref` | User Preferences, comma separated list. `m` for showing music, `p` for showing pay-per-view, `h` for showing HD | String | (empty) |
| `--country` | Country code (default: `US`) | String | US |
| `--postalCode` | Postal code of where shows are available. | Integer | 30309 | | `--postalCode` | Postal code of where shows are available. | Integer | 30309 |
| `--userAgent` | Custom user agent string for HTTP requests. | String | Uses random if not specified | | `--userAgent` | Custom user agent string for HTTP requests. | String | Uses random if not specified |
| `--timezone` | Timezone | String | System default | | `--timezone` | Timezone | String | System default |

View File

@@ -10,6 +10,10 @@ export const config = {
process.env.TIMESPAN || process.env.TIMESPAN ||
process.argv.find((arg) => arg.startsWith("--timespan="))?.split("=")[1] || process.argv.find((arg) => arg.startsWith("--timespan="))?.split("=")[1] ||
"3", "3",
country:
process.env.COUNTRY ||
process.argv.find((arg) => arg.startsWith("--country="))?.split("=")[1] ||
"USA",
postalCode: postalCode:
process.env.POSTAL_CODE || process.env.POSTAL_CODE ||
process.argv process.argv

View File

@@ -12,7 +12,8 @@ Options:
--help Show this help message --help Show this help message
--lineupId=ID Lineup ID (default: USA-lineupId-DEFAULT) --lineupId=ID Lineup ID (default: USA-lineupId-DEFAULT)
--timespan=NUM Timespan in hours (default: 3) --timespan=NUM Timespan in hours (default: 3)
--pref=LIST User preferences, comma separated. Can be m, p, and h (default: empty) --pref=LIST User preferences, comma separated. Can be m, p, and h (default: empty)'
--country=CON Country code (default: USA)
--postalCode=ZIP Postal code (default: 30309) --postalCode=ZIP Postal code (default: 30309)
--userAgent=UA Custom user agent string (default: Uses random if not specified) --userAgent=UA Custom user agent string (default: Uses random if not specified)
--timezone=TZ Timezone (default: America/New_York) --timezone=TZ Timezone (default: America/New_York)

View File

@@ -83,7 +83,7 @@ function buildUrl() {
lineupId: config.lineupId, lineupId: config.lineupId,
timespan: config.timespan, timespan: config.timespan,
headendId: "lineupId", headendId: "lineupId",
country: "USA", country: config.country,
timezone: config.timezone, timezone: config.timezone,
postalCode: config.postalCode, postalCode: config.postalCode,
isOverride: "true", isOverride: "true",
@@ -109,7 +109,7 @@ export async function getTVListings(): Promise<GridApiResponse> {
if (!response.ok) { if (!response.ok) {
throw new Error( throw new Error(
`Failed to fetch: ${response.status} ${response.statusText}`, `Failed to fetch: ${response.status} ${response.statusText}`
); );
} }