Skip to content

Commit

Permalink
Finish up gotham integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Oct 27, 2024
1 parent aaae708 commit b62bb60
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 784 deletions.
32 changes: 8 additions & 24 deletions services/gotham-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ const parseAirings = async (events: any[]) => {
const start = moment(event.start);
const end = moment(event.end);

if (!useLinear) {
start.subtract(30, 'minutes'); // For Pre-game
}

if (end.isBefore(now) || start.isAfter(inTwoDays)) {
continue;
}
Expand Down Expand Up @@ -270,7 +274,6 @@ class GothamHandler {
return;
}

await this.getNewTokens();
await this.authenticateRegCode();

if (moment().add(20, 'hours').isAfter(this.expiresIn)) {
Expand Down Expand Up @@ -391,7 +394,7 @@ class GothamHandler {
categories: ['Gotham', 'HD', 'Sports', airing.net || 'MSG', airing.aw_tm, airing.hm_tm, airing.spt_lg],
contentId: `${airing.id}----${airing.cid}`,
end: airing.ev_ed_dt,
network: airing.net,
network: `${airing.pn}`.toUpperCase(),
sport: airing.spt_lg,
start: airing.ev_st_dt,
title: eventName,
Expand All @@ -408,7 +411,7 @@ class GothamHandler {

public getEventData = async (eventId: string): Promise<[string, IHeaders]> => {
try {
const [contentId, channelId] = eventId.split('----');
const [, channelId] = eventId.split('----');

const event = await db.entries.findOne<IEntry>({id: eventId});

Expand All @@ -425,8 +428,8 @@ class GothamHandler {
const {data} = await axios.post(
`${authUrl}`,
{
catalogType: useLinear ? 'channel' : 'liveevent',
contentId: useLinear ? channelId : contentId,
catalogType: 'channel',
contentId: channelId,
contentTypeId: 'live',
delivery: 'streaming',
deviceId: this.device_id,
Expand Down Expand Up @@ -859,8 +862,6 @@ class GothamHandler {

this.save();

// await this.refreshProviderToken();

const adobeId = await this.getAdobeId();
const adobeUserMeta = await this.getUserMetadata();

Expand Down Expand Up @@ -971,23 +972,6 @@ class GothamHandler {
}
};

private refreshProviderToken = async (): Promise<void> => {
if (!this.adobe_token) {
return;
}

// const renewUrl = [`${BASE_ADOBE_URL}/tokens/authn`, `?deviceId=${this.device_id}`, '&requestor=Gotham'].join('');

// try {
// await axios.get(renewUrl, {
// headers: {
// Authorization: `Bearer ${this.adobe_token}`,
// 'User-Agent': okHttpUserAgent,
// },
// });
// } catch (e) {}
};

private save = async () => {
await db.providers.update(
{name: 'gotham'},
Expand Down
Loading

0 comments on commit b62bb60

Please sign in to comment.