convert getAllChannel.json to m3u format.
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" }
);
});
});
Maybe it will works in the browser too, but I haven't tested it yet.