Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/xmltv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const mockData: GridApiResponse = {
endTime: "2025-07-18T20:00:00Z",
thumbnail: "p30687311_b_v13_aa",
channelNo: "4.1",
filter: ["filter-news"],
filter: ["filter-news", "filter-sports"],
seriesId: "SH05918266",
rating: "TV-PG",
flag: ["New"],
Expand Down Expand Up @@ -85,6 +85,12 @@ describe("buildXmltv", () => {
);
});

it("should include category information", () => {
const result = buildXmltv(mockData);
expect(result).toContain('<category lang="en">news</category>');
expect(result).toContain('<category lang="en">sports</category>');
});

it("should include rating information", () => {
const result = buildXmltv(mockData);
expect(result).toContain(
Expand Down Expand Up @@ -173,7 +179,7 @@ describe("buildXmltv", () => {
expect(result).not.toContain("<sub-title>");
expect(result).not.toContain("<desc>");
expect(result).not.toContain("<rating>");
expect(result).not.toContain("<category>");
expect(result).not.toContain('<category lang="en">');
expect(result).not.toContain("<episode-num");
expect(result).not.toContain("<icon");
});
Expand Down Expand Up @@ -269,6 +275,8 @@ describe("buildProgramsXml", () => {
expect(result).toContain(
"<desc>BIA performs; comic Zarna Garg; lifestyle contributor Lori Bergamotto; ABC News chief medical correspondent Dr. Tara Narula.</desc>",
);
expect(result).toContain('<category lang="en">news</category>');
expect(result).toContain('<category lang="en">sports</category>');
expect(result).toContain(
'<rating system="MPAA"><value>TV-PG</value></rating>',
);
Expand Down Expand Up @@ -336,7 +344,7 @@ describe("buildProgramsXml", () => {
expect(result).not.toContain("<sub-title>");
expect(result).not.toContain("<desc>");
expect(result).not.toContain("<rating>");
expect(result).not.toContain("<category>");
expect(result).not.toContain('<category lange="en">');
expect(result).not.toContain("<episode-num");
expect(result).not.toContain("<icon");
});
Expand Down
9 changes: 9 additions & 0 deletions src/xmltv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@
xml += ` <desc>${escapeXml(event.program.shortDesc)}</desc>\n`;
}

if (event.filter && event.filter.length > 0) {
for (let i = 0; i < event.filter.length; i++) {
const category = event.filter[i].match(/^(filter)-(.*?)$/);

Check failure on line 83 in src/xmltv.ts

View workflow job for this annotation

GitHub Actions / Build, Lint, and Test

Object is possibly 'undefined'.
if (category) {
xml += ` <category lang="en">${category[2]}</category>`;
}
}
}

if (event.rating) {
xml += ` <rating system="MPAA"><value>${escapeXml(
event.rating,
Expand Down
Loading