diff --git a/README.md b/README.md index 95106ac..03a6bb5 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@

-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). @@ -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 diff --git a/package-lock.json b/package-lock.json index 0f8d9fb..85cd13d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "eplustv", - "version": "2.0.21", + "version": "2.0.22", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "eplustv", - "version": "2.0.21", + "version": "2.0.22", "license": "MIT", "dependencies": { "axios": "^1.2.2", diff --git a/package.json b/package.json index 6acc923..83a8010 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eplustv", - "version": "2.0.21", + "version": "2.0.22", "description": "", "scripts": { "start": "ts-node index.ts", diff --git a/services/fox-handler.ts b/services/fox-handler.ts index 2dab764..99ef7c3 100644 --- a/services/fox-handler.ts +++ b/services/fox-handler.ts @@ -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...'); } @@ -290,6 +272,57 @@ class FoxHandler { } }; + private getSteamData = async (eventId: string): Promise => { + 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 => { if (!this.appConfig) { await this.getAppConfig();