From 2199fe9a0c318db29a61ddcd50289d9b0036c7f7 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Fri, 26 Jul 2024 10:10:25 +0000 Subject: feat: initial release --- src/app.d.ts | 13 ++++++ src/app.html | 17 +++++++ src/lib/m3u.ts | 36 +++++++++++++++ src/routes/+page.svelte | 116 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 182 insertions(+) create mode 100644 src/app.d.ts create mode 100644 src/app.html create mode 100644 src/lib/m3u.ts create mode 100644 src/routes/+page.svelte (limited to 'src') diff --git a/src/app.d.ts b/src/app.d.ts new file mode 100644 index 0000000..743f07b --- /dev/null +++ b/src/app.d.ts @@ -0,0 +1,13 @@ +// See https://kit.svelte.dev/docs/types#app +// for information about these interfaces +declare global { + namespace App { + // interface Error {} + // interface Locals {} + // interface PageData {} + // interface PageState {} + // interface Platform {} + } +} + +export {}; diff --git a/src/app.html b/src/app.html new file mode 100644 index 0000000..478a89a --- /dev/null +++ b/src/app.html @@ -0,0 +1,17 @@ + + + + + + + + + Japanese IPTV + + %sveltekit.head% + + + +
%sveltekit.body%
+ + diff --git a/src/lib/m3u.ts b/src/lib/m3u.ts new file mode 100644 index 0000000..e5138e0 --- /dev/null +++ b/src/lib/m3u.ts @@ -0,0 +1,36 @@ +export interface Channel { + groupTitle: string; + tvgId: string; + tvgLogo: string; + name: string; + url: string; +} + +export const parseM3U = (m3uContent: string): Channel[] => { + const lines = m3uContent.split('\n'); + const channels: Channel[] = []; + let currentChannel: Partial = {}; + + for (const line of lines) + if (line.startsWith('#EXTINF')) { + const groupTitleMatch = line.match(/group-title="([^"]*)"/); + const tvgIdMatch = line.match(/tvg-id="([^"]*)"/); + const tvgLogoMatch = line.match(/tvg-logo="([^"]*)"/); + const nameMatch = line.match(/,([^,]*)$/); + + currentChannel = { + groupTitle: groupTitleMatch ? groupTitleMatch[1].trim() : '', + tvgId: tvgIdMatch ? tvgIdMatch[1].trim() : '', + tvgLogo: tvgLogoMatch ? tvgLogoMatch[1].trim() : '', + name: nameMatch ? nameMatch[1].trim() : '' + }; + } else if (line && !line.startsWith('#')) { + currentChannel.url = line.trim(); + + channels.push(currentChannel as Channel); + + currentChannel = {}; + } + + return channels; +}; diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte new file mode 100644 index 0000000..5aeed62 --- /dev/null +++ b/src/routes/+page.svelte @@ -0,0 +1,116 @@ + + + + +
+ channel.tvgId.toLowerCase().includes(filter.toLowerCase()))} + minColWidth={(browser ? window.innerWidth < 768 : false) ? 150 : 200} + gap={15} + let:item + > + + +
+ + -- cgit v1.2.3