Skip to content

Instantly share code, notes, and snippets.

@Inclushe
Created October 26, 2024 02:21
Show Gist options
  • Save Inclushe/b5ed85c085cfd37f8151db94124bee9c to your computer and use it in GitHub Desktop.
Save Inclushe/b5ed85c085cfd37f8151db94124bee9c to your computer and use it in GitHub Desktop.
import { $ } from "bun";
const tverRequest = await fetch(
"https://platform-api.tver.jp/service/api/v1/callCategoryHome/variety?platform_uid=0340db4241d7405185135f690f3f91b33545&platform_token=d1bimyh4666s1wu03p077i8jly8w0o6as6sm0nms&require_data=mylist%2Cresume%2Clater",
{
credentials: "omit",
headers: {
"User-Agent":
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:131.0) Gecko/20100101 Firefox/131.0",
Accept: "*/*",
"Accept-Language": "en-US,en;q=0.5",
"x-tver-platform-type": "web",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-site",
Pragma: "no-cache",
"Cache-Control": "no-cache",
},
referrer: "https://tver.jp/",
method: "GET",
mode: "cors",
},
);
const tverJSON = await tverRequest.json();
let fileString = `#EXTM3U\n`;
for (const component of tverJSON.result.components) {
for (const contents of component.contents) {
if (contents.type !== "episode") continue;
fileString += `#EXTINF:-1 group-title="${component.label}",${component.label} - ${contents.content.title}\n`;
fileString += `https://tver.jp/episodes/${contents.content.id}\n`;
}
}
const response = new Response(fileString);
await $`cat < ${response} | mpv --no-border --ontop --playlist=-`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment