From 97e87c2dbab4fb0b8f1f12f5b8b7cf4c8d124aa9 Mon Sep 17 00:00:00 2001
From: Joe Ipson
Date: Sat, 21 Sep 2024 18:06:33 -0600
Subject: [PATCH] Standardized when cutoff is for events. Fix tagging of FOX
Sports NFL events
---
README.md | 2 +-
package-lock.json | 4 ++--
package.json | 2 +-
services/b1g-handler.ts | 5 +++--
services/espn-handler.ts | 3 ++-
services/flo-handler.ts | 5 +++--
services/fox-handler.ts | 14 +++++++++++---
services/mlb-handler.ts | 5 +++--
services/mw-handler.ts | 2 +-
services/nesn-handler.ts | 2 +-
services/nfl-handler.ts | 5 +++--
11 files changed, 31 insertions(+), 18 deletions(-)
diff --git a/README.md b/README.md
index 17457cf..1d6417d 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
-Current version: **3.2.0**
+Current version: **3.2.1**
# About
This takes ESPN/ESPN+, FOX Sports, Paramount+, MSG+, NFL+, B1G+, NESN, 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).
diff --git a/package-lock.json b/package-lock.json
index 6d47a9e..67200bb 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "eplustv",
- "version": "3.2.0",
+ "version": "3.2.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "eplustv",
- "version": "3.2.0",
+ "version": "3.2.1",
"license": "MIT",
"dependencies": {
"axios": "^1.2.2",
diff --git a/package.json b/package.json
index 72025ef..08a1339 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "eplustv",
- "version": "3.2.0",
+ "version": "3.2.1",
"description": "",
"scripts": {
"start": "ts-node index.ts",
diff --git a/services/b1g-handler.ts b/services/b1g-handler.ts
index f140659..34cf0c0 100644
--- a/services/b1g-handler.ts
+++ b/services/b1g-handler.ts
@@ -88,6 +88,7 @@ const getEventData = (event: IB1GEvent): IGameData => {
const parseAirings = async (events: IB1GEvent[]) => {
const now = moment();
+ const endDate = moment().add(2, 'days').endOf('day');
for (const event of events) {
if (!event || !event.id) {
@@ -103,7 +104,7 @@ const parseAirings = async (events: IB1GEvent[]) => {
const start = moment(event.startTime);
const end = moment(event.startTime).add(4, 'hours');
- if (end.isBefore(now) || content.enableDrmProtection) {
+ if (end.isBefore(now) || start.isAfter(endDate) || content.enableDrmProtection) {
continue;
}
@@ -176,7 +177,7 @@ class B1GHandler {
'&language=en',
`&metadata_id=${encodeURIComponent('159283,167702')}`,
`&date_time_from=${encodeURIComponent(moment().format())}`,
- `&date_time_to=${encodeURIComponent(moment().add(2, 'days').format())}`,
+ `&date_time_to=${encodeURIComponent(moment().add(2, 'days').endOf('day').format())}`,
page > 1 ? `&page=${page}` : '',
].join('');
diff --git a/services/espn-handler.ts b/services/espn-handler.ts
index 825879e..ee916ec 100644
--- a/services/espn-handler.ts
+++ b/services/espn-handler.ts
@@ -273,6 +273,7 @@ const parseCategories = event => {
const parseAirings = async events => {
const now = moment();
+ const endSchedule = moment().add(2, 'days').endOf('day');
for (const event of events) {
const entryExists = await db.entries.findOne({id: event.id});
@@ -287,7 +288,7 @@ const parseAirings = async events => {
end.add(1, 'hour');
}
- if (end.isBefore(now)) {
+ if (end.isBefore(now) || start.isAfter(endSchedule)) {
continue;
}
diff --git a/services/flo-handler.ts b/services/flo-handler.ts
index 2cb9f06..48efef1 100644
--- a/services/flo-handler.ts
+++ b/services/flo-handler.ts
@@ -48,6 +48,7 @@ interface IFloEvent {
const parseAirings = async (events: IFloEvent[]) => {
const now = moment();
+ const endSchedule = moment().add(2, 'days').endOf('day');
for (const event of events) {
for (const stream of event.live_event_metadata.streams) {
@@ -57,7 +58,7 @@ const parseAirings = async (events: IFloEvent[]) => {
const start = moment(event.label_1_parts.start_date_time);
const end = moment(event.label_1_parts.start_date_time).add(4, 'hours');
- if (end.isBefore(now)) {
+ if (end.isBefore(now) || start.isAfter(endSchedule)) {
continue;
}
@@ -130,7 +131,7 @@ class FloSportsHandler {
const events: IFloEvent[] = [];
const limit = 100;
- const endSchedule = moment().add(2, 'days');
+ const endSchedule = moment().add(2, 'days').endOf('day');
while (hasNextPage) {
const url = [
diff --git a/services/fox-handler.ts b/services/fox-handler.ts
index a201683..7a1bf6d 100644
--- a/services/fox-handler.ts
+++ b/services/fox-handler.ts
@@ -53,6 +53,7 @@ interface IFoxEvent {
name: string;
longDescription: string;
seriesType: string;
+ sportTag?: string;
startDate: string;
endDate: string;
network: string;
@@ -95,13 +96,17 @@ const getMaxRes = _.memoize(() => {
});
const parseCategories = (event: IFoxEvent) => {
- const categories = ['FOX Sports'];
+ const categories = ['FOX Sports', 'FOX'];
for (const classifier of [...(event.categoryTags || []), ...(event.genres || [])]) {
if (classifier !== null) {
categories.push(classifier);
}
}
+ if (event.sportTag) {
+ categories.push(event.sportTag);
+ }
+
if (event.streamTypes?.find(resolution => resolution === 'HDR' || resolution === 'SDR')) {
categories.push('4K');
}
@@ -135,7 +140,9 @@ const parseAirings = async (events: IFoxEvent[]) => {
continue;
}
- console.log('Adding event: ', event.name);
+ const eventName = `${event.sportTag === 'NFL' ? `${event.sportTag} - ` : ''}${event.name}`;
+
+ console.log('Adding event: ', eventName);
await db.entries.insert({
categories,
@@ -144,7 +151,7 @@ const parseAirings = async (events: IFoxEvent[]) => {
from: 'foxsports',
id: event.id,
image: event.images.logo?.FHD || event.images.seriesDetail?.FHD || event.images.seriesList?.FHD,
- name: event.name,
+ name: eventName,
network: event.callSign,
replay: event.airingType !== 'live',
start: start.valueOf(),
@@ -387,6 +394,7 @@ class FoxHandler {
console.log(e);
}
+ // console.log(events);
return events;
};
diff --git a/services/mlb-handler.ts b/services/mlb-handler.ts
index 587454c..0164d4b 100644
--- a/services/mlb-handler.ts
+++ b/services/mlb-handler.ts
@@ -123,6 +123,7 @@ const generateThumb = (home: ITeam, away: ITeam): string =>
const parseAirings = async (events: ICombinedGame) => {
const now = moment();
+ const endDate = moment().add(2, 'days').endOf('day');
for (const pk in events) {
if (!events[pk].feed || !events[pk].entry) {
@@ -144,7 +145,7 @@ const parseAirings = async (events: ICombinedGame) => {
const start = moment(event.gameDate);
const end = moment(event.gameDate).add(5, 'hours');
- if (end.isBefore(now)) {
+ if (end.isBefore(now) || start.isAfter(endDate)) {
continue;
}
@@ -172,7 +173,7 @@ const parseAirings = async (events: ICombinedGame) => {
const parseBigInnings = async (dates: Moment[][]) => {
const now = moment();
- const endDate = moment().add(2, 'days');
+ const endDate = moment().add(2, 'days').endOf('day');
for (const day of dates) {
const [start, end] = day;
diff --git a/services/mw-handler.ts b/services/mw-handler.ts
index bf7a5f2..f4ef044 100644
--- a/services/mw-handler.ts
+++ b/services/mw-handler.ts
@@ -21,7 +21,7 @@ interface IMWEvent {
const parseAirings = async (events: IMWEvent[]) => {
const now = moment();
- const endSchedule = moment().add(2, 'days');
+ const endSchedule = moment().add(2, 'days').endOf('day');
for (const event of events) {
if (!event || !event.id) {
diff --git a/services/nesn-handler.ts b/services/nesn-handler.ts
index d9be50d..45f5e32 100644
--- a/services/nesn-handler.ts
+++ b/services/nesn-handler.ts
@@ -323,7 +323,7 @@ class NesnHandler {
const entries: INesnEvent[] = [];
const now = moment();
- const end = moment().add(2, 'days');
+ const end = moment().add(2, 'days').endOf('day');
try {
for (const schedule of SCHEDULES) {
diff --git a/services/nfl-handler.ts b/services/nfl-handler.ts
index 079c3eb..7118f8b 100644
--- a/services/nfl-handler.ts
+++ b/services/nfl-handler.ts
@@ -94,6 +94,7 @@ const DEFAULT_CATEGORIES = ['NFL', 'NFL+', 'Football'];
const parseAirings = async (events: INFLEvent[]) => {
const now = moment();
+ const endDate = moment().add(2, 'days').endOf('day');
for (const event of events) {
const entryExists = await db.entries.findOne({id: event.externalId});
@@ -108,7 +109,7 @@ const parseAirings = async (events: INFLEvent[]) => {
end.add(1, 'hour');
}
- if (end.isBefore(now)) {
+ if (end.isBefore(now) || start.isAfter(endDate)) {
continue;
}
@@ -198,7 +199,7 @@ class NflHandler {
const events: INFLEvent[] = [];
try {
- const endSchedule = moment().add(2, 'days');
+ const endSchedule = moment().add(2, 'days').endOf('day');
const url = ['https://', 'api.nfl.com', '/experience/v1/livestreams'].join('');