Skip to content

Commit

Permalink
Added support for Mountain West
Browse files Browse the repository at this point in the history
  • Loading branch information
m0ngr31 committed Sep 10, 2024
1 parent 480e28e commit 2380326
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 5 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<img src="https://i.imgur.com/FIGZdR3.png">
</p>

Current version: **3.0.1**
Current version: **3.1.0**

# About
This takes ESPN/ESPN+, FOX Sports, Paramount+, MSG+, NFL+, B1G+, 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).
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).

## Notes
* This was not made for pirating streams. This is made for using your own credentials and have a different presentation than the streaming apps currently provide.
Expand Down Expand Up @@ -99,6 +99,12 @@ Use if you would like to login with FloSports
|---|---|---|---|
| FLOSPORTS | Set if you would like FloSports events | False | False |

#### Mountain West
Use if you would like to use Mountain West
| Environment Variable | Description | Required? | Default |
|---|---|---|---|
| MTNWEST | Set if you would like Mountain West events | False | False |

#### MLB.tv
Use if you would like to login with your MLB.tv account
| Environment Variable | Description | Default |
Expand Down
2 changes: 2 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {floSportsHandler} from './services/flo-handler';
import {paramountHandler} from './services/paramount-handler';
import {nflHandler} from './services/nfl-handler';
import {msgHandler} from './services/msg-handler';
import {mwHandler} from './services/mw-handler';
import {cleanEntries, removeChannelStatus} from './services/shared-helpers';
import {appStatus} from './services/app-status';
import {SERVER_PORT} from './services/port';
Expand All @@ -38,6 +39,7 @@ const schedule = async () => {
await mlbHandler.getSchedule();
await b1gHandler.getSchedule();
await floSportsHandler.getSchedule();
await mwHandler.getSchedule();
await nflHandler.getSchedule();
await paramountHandler.getSchedule();
await msgHandler.getSchedule();
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.0.1",
"version": "3.1.0",
"description": "",
"scripts": {
"start": "ts-node index.ts",
Expand Down
4 changes: 4 additions & 0 deletions services/launch-channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {b1gHandler} from './b1g-handler';
import {msgHandler} from './msg-handler';
import {floSportsHandler} from './flo-handler';
import {nflHandler} from './nfl-handler';
import {mwHandler} from './mw-handler';
import {IEntry, IHeaders} from './shared-interfaces';
import {PlaylistHandler} from './playlist-handler';
import {appStatus} from './app-status';
Expand Down Expand Up @@ -53,6 +54,9 @@ const startChannelStream = async (channelId: string, appUrl: string) => {
case 'nfl+':
[url, headers] = await nflHandler.getEventData(appStatus.channels[channelId].current);
break;
case 'mountain-west':
[url, headers] = await mwHandler.getEventData(appStatus.channels[channelId].current);
break;
default:
[url, headers] = await espnHandler.getEventData(appStatus.channels[channelId].current);
}
Expand Down
98 changes: 98 additions & 0 deletions services/mw-handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import axios from 'axios';
import moment from 'moment';

import {userAgent} from './user-agent';
import {useMountainWest} from './networks';
import {IEntry, IHeaders} from './shared-interfaces';
import {db} from './database';

interface IMWEvent {
image: string;
thumbnail: string;
title: string;
start_time: string;
end_time: string;
value: string;
description: string;
sport_category_title: string;
id: string;
format: string;
}

const parseAirings = async (events: IMWEvent[]) => {
const now = moment();
const endSchedule = moment().add(2, 'days');

for (const event of events) {
if (!event || !event.id) {
return;
}

const entryExists = await db.entries.findOne<IEntry>({id: `mw-${event.id}`});

if (!entryExists) {
const start = moment(event.start_time);
const end = moment(event.end_time).add(1, 'hours');

if (end.isBefore(now) || event.format !== 'video' || start.isAfter(endSchedule)) {
continue;
}

console.log('Adding event: ', event.title);

await db.entries.insert<IEntry>({
categories: [...new Set(['Mountain West', 'The MW', event.sport_category_title])],
duration: end.diff(start, 'seconds'),
end: end.valueOf(),
from: 'mountain-west',
id: `mw-${event.id}`,
image: event.image || event.thumbnail,
name: event.title,
network: 'MW',
sport: event.sport_category_title,
start: start.valueOf(),
url: event.value,
});
}
}
};

class MountainWestHandler {
public getSchedule = async (): Promise<void> => {
if (!useMountainWest) {
return;
}

console.log('Looking for Mountain West events...');

try {
const url = ['https://themw.com/wp-json/v1/videos?video_categories[]=102&page=1&order_by=start_date'].join('');

const {data} = await axios.get<{data: IMWEvent[]}>(url, {
headers: {
'user-agent': userAgent,
},
});

await parseAirings(data.data);
} catch (e) {
console.error(e);
console.log('Could not parse Mountain West events');
}
};

public getEventData = async (id: string): Promise<[string, IHeaders]> => {
try {
const event = await db.entries.findOne<IEntry>({id});

if (event) {
return [event.url, {}];
}
} catch (e) {
console.error(e);
console.log('Could not get event data');
}
};
}

export const mwHandler = new MountainWestHandler();
2 changes: 2 additions & 0 deletions services/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export const useNflPlus = process.env.NFLPLUS?.toLowerCase() === 'true' ? true :
export const useNflNetwork = process.env.NFLNETWORK?.toLowerCase() === 'true' ? true : false;
export const useNflRedZone = process.env.NFLREDZONE?.toLowerCase() === 'true' ? true : false;

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

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

Expand Down

0 comments on commit 2380326

Please sign in to comment.