Skip to content

Commit

Permalink
Attempting to fix issue with HDR FOX streams for local channels
Browse files Browse the repository at this point in the history
  • Loading branch information
m0ngr31 committed Nov 24, 2023
1 parent ce91552 commit 9e6c669
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 25 deletions.
4 changes: 2 additions & 2 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: **2.0.21**
Current version: **2.0.22**

# About
This takes ESPN/ESPN+, FOX Sports, and 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), [Channels](https://getchannels.com), or [xTeVe](https://github.com/xteve-project/xTeVe).
Expand Down Expand Up @@ -60,7 +60,7 @@ Use if you would like to login with a TV provider and access various FOX Sports
|---|---|---|---|
| FOXSPORTS | Set if your TV provider supports it | No | False |
| FOXSPORTS_ALLOW_REPLAYS | If you would like to schedule events that aren't live | No | False |
| MAX_RESOLUTION | Max resolution to use. Valid options are `UHD/HDR`, `UHD/SDR`, `1080p`, `720p`, and `540p` (Some events don't offer 4K or 1080p and will attempt to play the highest framerate available for selected resolution). | No | UHD/SDR |
| MAX_RESOLUTION | Max resolution to use. Valid options are `UHD/HDR`, `UHD/SDR`, and `720p` (Some events don't offer 4K and will attempt to play the highest framerate available for selected resolution). | No | UHD/SDR |
| FOX_ONLY_4K | Only grab 4K events | No | False |

#### MLB.tv
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": "2.0.21",
"version": "2.0.22",
"description": "",
"scripts": {
"start": "ts-node index.ts",
Expand Down
73 changes: 53 additions & 20 deletions services/fox-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,29 +241,11 @@ class FoxHandler {
await this.getAppConfig();
}

const {data} = await axios.post(
this.appConfig.api.content.watch,
{
deviceHeight: 2160,
deviceWidth: 3840,
maxRes,
os: 'Android',
osv: '11.0.0',
streamId: eventId,
streamType: 'live',
},
{
headers: {
'User-Agent': androidFoxUserAgent,
authorization: this.adobe_auth.accessToken,
'x-api-key': this.appConfig.api.key,
},
},
);
const data = await this.getSteamData(eventId);

// console.log('CDN: ', data.trackingData.properties.CDN);

if (!data.url) {
if (!data || !data?.url) {
throw new Error('Could not get stream data. Event might be upcoming, ended, or in blackout...');
}

Expand All @@ -290,6 +272,57 @@ class FoxHandler {
}
};

private getSteamData = async (eventId: string): Promise<any> => {
const streamOrder = ['UHD/HDR', 'UHD/SDR', '720p'];

let resIndex = streamOrder.findIndex(i => i === maxRes);

if (resIndex < 0) {
resIndex = 1;
}

if (!this.appConfig) {
await this.getAppConfig();
}

let watchData;

for (let a = resIndex; a < streamOrder.length; a++) {
try {
const {data} = await axios.post(
this.appConfig.api.content.watch,
{
deviceHeight: 2160,
deviceWidth: 3840,
maxRes: streamOrder[resIndex],
os: 'Android',
osv: '11.0.0',
streamId: eventId,
streamType: 'live',
},
{
headers: {
'User-Agent': androidFoxUserAgent,
authorization: this.adobe_auth.accessToken,
'x-api-key': this.appConfig.api.key,
},
},
);

watchData = data;
break;
} catch (e) {
console.log(
`Could not get stream data for ${streamOrder[resIndex]}.${
streamOrder[resIndex + 1] && `Trying to get ${streamOrder[resIndex + 1]} next...`
}`,
);
}
}

return watchData;
};

private getEvents = async (): Promise<IFoxEvent[]> => {
if (!this.appConfig) {
await this.getAppConfig();
Expand Down

0 comments on commit 9e6c669

Please sign in to comment.