Skip to content

Commit

Permalink
Standardized when cutoff is for events. Fix tagging of FOX Sports NFL…
Browse files Browse the repository at this point in the history
… events
  • Loading branch information
m0ngr31 committed Sep 22, 2024
1 parent fdf59a8 commit 97e87c2
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 18 deletions.
2 changes: 1 addition & 1 deletion 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.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).
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.2.0",
"version": "3.2.1",
"description": "",
"scripts": {
"start": "ts-node index.ts",
Expand Down
5 changes: 3 additions & 2 deletions services/b1g-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}

Expand Down Expand Up @@ -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('');

Expand Down
3 changes: 2 additions & 1 deletion services/espn-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<IEntry>({id: event.id});
Expand All @@ -287,7 +288,7 @@ const parseAirings = async events => {
end.add(1, 'hour');
}

if (end.isBefore(now)) {
if (end.isBefore(now) || start.isAfter(endSchedule)) {
continue;
}

Expand Down
5 changes: 3 additions & 2 deletions services/flo-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}

Expand Down Expand Up @@ -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 = [
Expand Down
14 changes: 11 additions & 3 deletions services/fox-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ interface IFoxEvent {
name: string;
longDescription: string;
seriesType: string;
sportTag?: string;
startDate: string;
endDate: string;
network: string;
Expand Down Expand Up @@ -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');
}
Expand Down Expand Up @@ -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<IEntry>({
categories,
Expand All @@ -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(),
Expand Down Expand Up @@ -387,6 +394,7 @@ class FoxHandler {
console.log(e);
}

// console.log(events);
return events;
};

Expand Down
5 changes: 3 additions & 2 deletions services/mlb-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion services/mw-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion services/nesn-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions services/nfl-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<IEntry>({id: event.externalId});
Expand All @@ -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;
}

Expand Down Expand Up @@ -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('');

Expand Down

0 comments on commit 97e87c2

Please sign in to comment.