From 98065fa057fe4d33705538011a34f3a045b1b38e Mon Sep 17 00:00:00 2001 From: Christian Benincasa Date: Sat, 8 Jun 2024 07:46:43 -0400 Subject: [PATCH] Support tv-chno field --- .changeset/rotten-fans-tap.md | 5 +++++ src/types.ts | 1 + src/writer.ts | 1 + tests/__snapshots__/main.test.ts.snap | 2 +- tests/main.test.ts | 1 + 5 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/rotten-fans-tap.md diff --git a/.changeset/rotten-fans-tap.md b/.changeset/rotten-fans-tap.md new file mode 100644 index 0000000..1e7b405 --- /dev/null +++ b/.changeset/rotten-fans-tap.md @@ -0,0 +1,5 @@ +--- +"@iptv/playlist": minor +--- + +Adds support for the tv-chno field diff --git a/src/types.ts b/src/types.ts index 27817b5..8ce6abc 100644 --- a/src/types.ts +++ b/src/types.ts @@ -16,6 +16,7 @@ export type M3uChannel = { tvgLogo?: string; tvgUrl?: string; tvgRec?: string; + tvgChno?: string; groupTitle?: string; url?: string; name?: string; diff --git a/src/writer.ts b/src/writer.ts index 03bca58..0b28999 100644 --- a/src/writer.ts +++ b/src/writer.ts @@ -47,6 +47,7 @@ function writeM3U(playlist: M3uPlaylist) { if (channel.tvgLanguage) m3u += ` tvg-language="${channel.tvgLanguage}"`; if (channel.tvgLogo) m3u += ` tvg-logo="${channel.tvgLogo}"`; if (channel.tvgRec) m3u += ` tvg-rec="${channel.tvgRec}"`; + if (channel.tvgChno) m3u += ` tvg-chno="${channel.tvgChno}"`; if (channel.groupTitle) m3u += ` group-title="${channel.groupTitle}"`; if (channel.tvgUrl) m3u += ` tvg-url="${channel.tvgUrl}"`; if (channel.timeshift) m3u += ` timeshift="${channel.timeshift}"`; diff --git a/tests/__snapshots__/main.test.ts.snap b/tests/__snapshots__/main.test.ts.snap index 1e00048..a1c649e 100644 --- a/tests/__snapshots__/main.test.ts.snap +++ b/tests/__snapshots__/main.test.ts.snap @@ -485,7 +485,7 @@ http://server:port/channel2" exports[`Write a m3u file > Write a m3u file every attribute 1`] = ` "#EXTM3U x-tvg-url=\\"http://example.com\\" -#EXTINF:-1 tvg-id=\\"channel1.uk\\" tvg-name=\\"Channel 1\\" tvg-language=\\"English\\" tvg-logo=\\"http://example.com/logo.png\\" tvg-rec=\\"default\\" group-title=\\"News\\" tvg-url=\\"http://example.com\\" timeshift=\\"1\\" catchup=\\"default\\" catchup-days=\\"7\\" catchup-source=\\"http://example.com\\" some-other-key=\\"hello\\",Channel 1 +#EXTINF:-1 tvg-id=\\"channel1.uk\\" tvg-name=\\"Channel 1\\" tvg-language=\\"English\\" tvg-logo=\\"http://example.com/logo.png\\" tvg-rec=\\"default\\" tvg-chno=\\"1\\" group-title=\\"News\\" tvg-url=\\"http://example.com\\" timeshift=\\"1\\" catchup=\\"default\\" catchup-days=\\"7\\" catchup-source=\\"http://example.com\\" some-other-key=\\"hello\\",Channel 1 http://server:port/channel1" `; diff --git a/tests/main.test.ts b/tests/main.test.ts index 4828f1c..6a77ae3 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -72,6 +72,7 @@ describe("Write a m3u file", () => { tvgLogo: "http://example.com/logo.png", tvgUrl: "http://example.com", tvgRec: "default", + tvgChno: "1", groupTitle: "News", url: "http://server:port/channel1", name: "Channel 1",