Skip to content

Commit

Permalink
Changed a little bit how linear channels are decided upon
Browse files Browse the repository at this point in the history
  • Loading branch information
m0ngr31 committed Sep 13, 2024
1 parent 52b6506 commit 08ab0fb
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 43 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<img src="https://i.imgur.com/FIGZdR3.png">
</p>

Current version: **3.1.3**
Current version: **3.1.4**

# About
This takes ESPN/ESPN+, FOX Sports, Paramount+, MSG+, NFL+, B1G+, Mountain West, FloSports, or MLB.tv programming and transforms it into a "live TV" experience with virtual linear channels. It will discover what is on, and generate a schedule of channels that will give you M3U and XMLTV files that you can import into something like [Jellyfin](https://jellyfin.org) or [Channels](https://getchannels.com).
Expand Down Expand Up @@ -71,11 +71,13 @@ Use if you would like to login with Paramount+

#### NFL+
Use if you would like to login with NFL+

*** If you have access to NFL RedZone (NFL+ Premium), it will be scheduled. If `LINEAR_CHANNELS` is set, it will be on its own channel

| Environment Variable | Description | Required? | Default |
|---|---|---|---|
| NFLPLUS | Set if you would like NFL+ events | False | False |
| NFLNETWORK* | Set if you would like the NFL Network channel (only available with `LINEAR_CHANNELS`) | False | False |
| NFLREDZONE*** | Set if you would like NFL RedZone (have to have NFL+ Premium) | False | False |

#### B1G+
Use if you would like to login with your B1G+ account
Expand Down Expand Up @@ -107,11 +109,13 @@ Use if you would like to use Mountain West

#### MLB.tv
Use if you would like to login with your MLB.tv account

*** If `LINEAR_CHANNELS` is set, Big Inning will be on its own channel

| Environment Variable | Description | Default |
|---|---|---|
| MLBTV | Set if you would like to use MLB.tv | False |
| MLBTV_ONLY_FREE | Only schedule free games | False |
| BIGINNING*** | Schedule Big Inning? | False |


### Notes
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eplustv",
"version": "3.1.3",
"version": "3.1.4",
"description": "",
"scripts": {
"start": "ts-node index.ts",
Expand Down
17 changes: 7 additions & 10 deletions services/channels.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import _ from 'lodash';
import {
useAccN,
useBigInning,
useCbsSportsHq,
useEspn1,
useEspn2,
useEspnews,
useEspnU,
useFoxSports,
useGolazo,
useNflNetwork,
useNflRedZone,
useNfl,
useParamount,
useSec,
} from './networks';

Expand Down Expand Up @@ -129,39 +126,39 @@ export const CHANNEL_MAP = {
tvgName: 'FSCPLHD',
},
20: {
canUse: useCbsSportsHq,
canUse: useParamount.cbsSportsHq,
id: 'cbssportshq',
logo: 'https://tmsimg.fancybits.co/assets/s108919_ll_h15_aa.png?w=360&h=270',
name: 'CBS Sports HQ',
stationId: '108919',
tvgName: 'CBSSPHQ',
},
21: {
canUse: useGolazo,
canUse: useParamount.golazo,
id: 'golazo',
logo: 'https://tmsimg.fancybits.co/assets/s133691_ll_h15_aa.png?w=360&h=270',
name: 'GOLAZO Network',
stationId: '133691',
tvgName: 'GOLAZO',
},
30: {
canUse: useNflNetwork,
canUse: useNfl.network,
id: 'NFLNETWORK',
logo: 'https://tmsimg.fancybits.co/assets/s45399_ll_h15_aa.png?w=360&h=270',
name: 'NFL Network',
stationId: '45399',
tvgName: 'NFLHD',
},
31: {
canUse: useNflRedZone,
canUse: useNfl.redZone,
id: 'NFLNRZ',
logo: 'https://tmsimg.fancybits.co/assets/s65025_ll_h9_aa.png?w=360&h=270',
name: 'NFL RedZone',
stationId: '65025',
tvgName: 'NFLNRZD',
},
40: {
canUse: useBigInning,
canUse: true,
id: 'MLBTVBI',
logo: 'https://i.imgur.com/8JHoeFA.png',
name: 'MLB Big Inning',
Expand Down
8 changes: 3 additions & 5 deletions services/mlb-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import moment, {Moment} from 'moment-timezone';

import {okHttpUserAgent, userAgent, androidMlbUserAgent} from './user-agent';
import {configPath} from './config';
import {useBigInning, useMLBtv} from './networks';
import {useMLBtv} from './networks';
import {IEntry, IHeaders} from './shared-interfaces';
import {db} from './database';
import {useLinear} from './channels';
Expand Down Expand Up @@ -286,12 +286,10 @@ class MLBHandler {
};
}

if (useBigInning) {
const bigInnings = await this.getBigInnings();
await parseBigInnings(bigInnings);
}
const bigInnings = await this.getBigInnings();

await parseAirings(combinedEntries);
await parseBigInnings(bigInnings);
} catch (e) {
console.error(e);
console.log('Could not parse MLB.tv events');
Expand Down
34 changes: 26 additions & 8 deletions services/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,46 @@ export const useFoxSports = process.env.FOXSPORTS?.toLowerCase() === 'true' ? tr
export const useFoxOnly4k = process.env.FOX_ONLY_4K?.toLowerCase() === 'true' ? true : false;

export const useMLBtv = process.env.MLBTV?.toLowerCase() === 'true' ? true : false;
export const useBigInning = process.env.BIGINNING?.toLowerCase() === 'true' ? true : false;

export const useB1GPlus = process.env.B1GPLUS?.toLowerCase() === 'true' ? true : false;

export const useFloSports = process.env.FLOSPORTS?.toLowerCase() === 'true' ? true : false;

export const useParamountPlus = process.env.PARAMOUNTPLUS?.toLowerCase() === 'true' ? true : false;
export const useCbsSportsHq = process.env.CBSSPORTSHQ?.toLowerCase() === 'true' ? true : false;
export const useGolazo = process.env.GOLAZO?.toLowerCase() === 'true' ? true : false;
export const useParamount = {
_cbsSportsHq: process.env.CBSSPORTSHQ?.toLowerCase() === 'true' ? true : false,
_golazo: process.env.GOLAZO?.toLowerCase() === 'true' ? true : false,
get cbsSportsHq(): boolean {
return this._cbsSportsHq && this.plus;
},
get golazo(): boolean {
return this._golazo && this.plus;
},
plus: process.env.PARAMOUNTPLUS?.toLowerCase() === 'true' ? true : false,
};

export const useMsgPlus = process.env.MSGPLUS?.toLowerCase() === 'true' ? true : false;

export const useNflPlus = process.env.NFLPLUS?.toLowerCase() === 'true' ? true : false;
export const useNflNetwork = process.env.NFLNETWORK?.toLowerCase() === 'true' ? true : false;
export const useNflRedZone = process.env.NFLREDZONE?.toLowerCase() === 'true' ? true : false;
export const useNfl = {
_network: process.env.NFLNETWORK?.toLowerCase() === 'true' ? true : false,
_redZone: true,
get network(): boolean {
return this._network && this.plus;
},
plus: process.env.NFLPLUS?.toLowerCase() === 'true' ? true : false,
get redZone(): boolean {
return this._redZone && this.plus;
},
set redZone(value: boolean) {
this._redZone = value;
},
};

export const useMountainWest = process.env.MTNWEST?.toLowerCase() === 'true' ? true : false;

export const requiresEspnProvider =
useEspn1 || useEspn2 || useEspn3 || useEspnU || useSec || useSecPlus || useAccN || useAccNx || useEspnews;

export const usesMultiple =
((useFoxSports || useMLBtv || useParamountPlus || useB1GPlus || useFloSports || useMsgPlus || useNflPlus) &&
((useFoxSports || useMLBtv || useParamount.plus || useB1GPlus || useFloSports || useMsgPlus || useNfl.plus) &&
(requiresEspnProvider || useEspnPlus)) ||
(requiresEspnProvider && useEspnPlus);
30 changes: 22 additions & 8 deletions services/nfl-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import jwt_decode from 'jwt-decode';

import {okHttpUserAgent} from './user-agent';
import {configPath} from './config';
import {useNflNetwork, useNflPlus, useNflRedZone} from './networks';
import {useNfl} from './networks';
import {IEntry, IHeaders} from './shared-interfaces';
import {db} from './database';
import {getRandomUUID} from './shared-helpers';
Expand Down Expand Up @@ -152,7 +152,7 @@ class NflHandler {
public uid?: string;

public initialize = async () => {
if (!useNflPlus) {
if (!useNfl.plus) {
return;
}

Expand All @@ -170,7 +170,7 @@ class NflHandler {
};

public refreshTokens = async () => {
if (!useNflPlus) {
if (!useNfl.plus) {
return;
}

Expand All @@ -180,15 +180,14 @@ class NflHandler {
};

public getSchedule = async (): Promise<void> => {
if (!useNflPlus) {
if (!useNfl.plus) {
return;
}

const {dmaCode, plans}: {dmaCode: string; plans: {plan: string; status: string}[]} = jwt_decode(this.access_token);
const {dmaCode}: {dmaCode: string; plans: {plan: string; status: string}[]} = jwt_decode(this.access_token);

const redZoneAccess =
plans.findIndex(p => p.plan === 'NFL_PLUS_PREMIUM' && p.status === 'ACTIVE') > -1 && useNflRedZone;
const nflNetworkAccess = useLinear && useNflNetwork;
const redZoneAccess = this.checkRedZoneAccess();
const nflNetworkAccess = useLinear && useNfl.network;

if (!dmaCode) {
console.log('DMA Code not found for NFL+. Not searching for events');
Expand Down Expand Up @@ -261,6 +260,19 @@ class NflHandler {
}
};

private checkRedZoneAccess = (): boolean => {
try {
const {plans}: {dmaCode: string; plans: {plan: string; status: string}[]} = jwt_decode(this.access_token);

if (plans) {
useNfl.redZone =
plans.findIndex(p => p.plan === 'NFL_PLUS_PREMIUM' && p.status === 'ACTIVE') > -1 ? true : false;
}
} catch (e) {}

return useNfl.redZone;
};

private extendToken = async (uidSignature?: string, signatureTimestamp?: string): Promise<void> => {
try {
const url = ['https://', 'api.nfl.com', '/identity/v3/token/refresh'].join('');
Expand Down Expand Up @@ -291,6 +303,8 @@ class NflHandler {
this.refresh_token = data.refreshToken;
this.expires_at = data.expiresIn;
this.save();

this.checkRedZoneAccess();
} catch (e) {
console.error(e);
console.log('Could not refresh token for NFL+');
Expand Down
12 changes: 6 additions & 6 deletions services/paramount-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import moment from 'moment';
import crypto from 'crypto';

import {configPath} from './config';
import {useCbsSportsHq, useGolazo, useParamountPlus} from './networks';
import {useParamount} from './networks';
import {getRandomHex} from './shared-helpers';
import {db} from './database';
import {IEntry, IHeaders} from './shared-interfaces';
Expand Down Expand Up @@ -188,7 +188,7 @@ class ParamountHandler {
private dma: IDma;

public initialize = async () => {
if (!useParamountPlus || isParamountDisabled) {
if (!useParamount.plus || isParamountDisabled) {
return;
}

Expand Down Expand Up @@ -221,7 +221,7 @@ class ParamountHandler {
};

public refreshTokens = async () => {
if (!useParamountPlus || isParamountDisabled) {
if (!useParamount.plus || isParamountDisabled) {
return;
}

Expand All @@ -231,7 +231,7 @@ class ParamountHandler {
};

public getSchedule = async () => {
if (!useParamountPlus || isParamountDisabled) {
if (!useParamount.plus || isParamountDisabled) {
return;
}

Expand Down Expand Up @@ -412,11 +412,11 @@ class ParamountHandler {
}

if (useLinear) {
if (useCbsSportsHq && c.channelName === 'CBS Sports HQ') {
if (useParamount.cbsSportsHq && c.channelName === 'CBS Sports HQ') {
channels.push(c);
}

if (useGolazo && c.channelName === 'CBS Sports Golazo Network') {
if (useParamount.golazo && c.channelName === 'CBS Sports Golazo Network') {
channels.push(c);
}
}
Expand Down

0 comments on commit 08ab0fb

Please sign in to comment.