Skip to content

uiolee/iptv2m3u

Repository files navigation

iptv2m3u

convert getAllChannel.json to m3u format.

GitHub Tag GitHub Release GitHub commits since latest release GitHub top language CI Libraries.io dependency status for GitHub repo

npmjs

NPM Version NPM License NPM Downloads NPM Downloads Libraries.io dependency status for latest release

an examlple run in Node.JS

npm i iptv2m3u
// node example.mjs
import { readFile, writeFile } from "fs/promises";
import { IPTV2M3U } from "iptv2m3u";

readFile("./test/getAllChannel.json", { encoding: "utf-8" }).then((str) => {
  const iptv2m3u = new IPTV2M3U(str, { platform: "hw", sort: true });

  iptv2m3u.getM3uStringAsync().then(async (m3uStr) => {
    await writeFile(`./output/cmcc-iptv-${iptv2m3u.length} rtp.m3u`, m3uStr, {
      encoding: "utf-8",
    });
  });

  iptv2m3u
    .getM3uStringAsync({
      proxyPrefix: "https://127.0.0.1:4022/udp/",
    })
    .then(async (m3uStr) => {
      await writeFile(
        `./output/cmcc-iptv-${iptv2m3u.length} http.m3u`,
        m3uStr,
        { encoding: "utf-8" }
      );
    });
});

run in browser

Maybe it will works in the browser too, but I haven't tested it yet.