Skip to content

Commit 4ab9605

Browse files
committed
Fix issue with Peacock links
1 parent 041b34f commit 4ab9605

File tree

5 files changed

+36
-29
lines changed

5 files changed

+36
-29
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Current version: **0.1.2**
1+
Current version: **0.1.3**
22

33
# About
44
This allows you to fetch EPG data for linear streaming services such as Peacock and ABC, and transforms them so you can use them with [chrome-capture-for-channels](https://github.com/fancybits/chrome-capture-for-channels).

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cc-epg",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"description": "",
55
"scripts": {
66
"start": "ts-node index.tsx",

services/generate-m3u.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const generateM3u = async (): Promise<string> => {
2020
channel.gracenoteId ? `tvc-guide-stationid="${channel.gracenoteId}"` : ''
2121
} tvg-id="${channel.number}.ccEPG" channel-number="${channel.number}" tvg-chno="${channel.number}" tvg-name="${
2222
channel.name
23-
}" group-title="ccEPG", ccEPG ${channel.number}`;
23+
}" group-title="ccEPG", ${channel.name}`;
2424
m3uFile = `${m3uFile}\n${prefix}/stream?url=${channel.url}\n`;
2525
}
2626

services/peacock-handler.ts

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ import {db} from './database';
77
import {miscDbHandler} from './misc-db';
88

99
interface IPeacockChannel {
10-
id: string;
11-
gracenoteId: string;
12-
scheduleItems: IPeacockEvent[];
13-
serviceKey: string;
14-
logo: {
15-
Default: string;
16-
};
17-
name: string;
18-
type: string;
19-
epgNumber: number;
10+
id: string;
11+
gracenoteId: string;
12+
scheduleItems: IPeacockEvent[];
13+
serviceKey: string;
14+
logo: {
15+
Default: string;
16+
};
17+
name: string;
18+
type: string;
19+
epgNumber: number;
2020
}
2121

2222
interface IPeacockRes {
@@ -48,30 +48,37 @@ const parseChannels = async (channels: IPeacockChannel[]): Promise<void> => {
4848
for (const channel of channels) {
4949
const channelExists = await db.channels.findOne<IChannel>({id: channel.id});
5050

51+
const channelData: Partial<IChannel> = {
52+
epgNumber: channel.epgNumber,
53+
from: 'Peacock',
54+
gracenoteId: channel.gracenoteId,
55+
id: channel.id,
56+
image: channel.logo.Default.replace('{width}', '360').replace('{height}', '270'),
57+
name: channel.name,
58+
type: channel.type.indexOf('linear') > -1 ? 'linear' : 'vod',
59+
url: `https://www.peacocktv.com/watch/playback/live/${channel.serviceKey}`,
60+
};
61+
5162
if (!channelExists) {
5263
console.log('Adding channel: ', channel.name);
5364

5465
const numChannels = await db.channels.count({});
5566

56-
if (channel.gracenoteId) {
57-
console.log('eyy lmao', channel.name, channel.gracenoteId);
58-
}
59-
6067
await db.channels.insert<IChannel>({
68+
...channelData,
6169
enabled: true,
62-
epgNumber: channel.epgNumber,
63-
from: 'Peacock',
64-
gracenoteId: channel.gracenoteId,
65-
id: channel.id,
66-
image: channel.logo.Default.replace('{width}', '360').replace('{height}', '270'),
67-
name: channel.name,
6870
number: numChannels + 1,
69-
type: channel.type.indexOf('linear') > -1 ? 'linear' : 'vod',
70-
url: `https://www.peacocktv.com/watch/playback/live/${channel.id}`,
71-
});
71+
} as IChannel);
72+
} else {
73+
await db.channels.update<IChannel>(
74+
{id: channel.id},
75+
{
76+
$set: channelData,
77+
},
78+
);
7279
}
7380
}
74-
}
81+
};
7582

7683
const parseAirings = async (events: IPeacockAirings): Promise<void> => {
7784
const now = moment();

0 commit comments

Comments
 (0)