From b1839a405ba8fef49e805a9daad64826fece16ba Mon Sep 17 00:00:00 2001 From: Saksham Shekher <95137948+OshekharO@users.noreply.github.com> Date: Sun, 24 Sep 2023 10:29:59 -0700 Subject: [PATCH] Create invidious.io (#18) * Create invidious.io * Add: Audio Tracks * Fix: audio Still getting some tcp error and buffer issue after audio track addition * Now fixed everything Api changed so no more buffer --- repo/invidious.io.js | 80 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 repo/invidious.io.js diff --git a/repo/invidious.io.js b/repo/invidious.io.js new file mode 100644 index 0000000..f67efff --- /dev/null +++ b/repo/invidious.io.js @@ -0,0 +1,80 @@ +// ==MiruExtension== +// @name Invidious +// @version v0.0.1 +// @author OshekharO +// @lang all +// @license MIT +// @icon https://invidious.io/apple-touch-icon.png +// @package invidious.io +// @type bangumi +// @webSite https://invidious.slipfox.xyz/api/v1 +// ==/MiruExtension== + +export default class extends Extension { + async latest() { + const res = await this.request(`/trending`); + + if (!Array.isArray(res)) { + // Handle the case when the response is not an array + return []; + } + + return res.map((item) => ({ + title: item.title || "", + url: item.videoId || "", + cover: item.videoThumbnails?.[0]?.url || "", // Use the first thumbnail's URL if available + })); + } + + async search(kw) { + const res = await this.request(`/search?q=${kw}`); + + return res.map((item) => ({ + title: item.title || "", + url: item.videoId || "", + cover: item.videoThumbnails?.[0]?.url || "", + })); + } + + async detail(url) { + const res = await this.request(`/videos/${url}`); + return { + title: res.title, + cover: res.videoThumbnails?.[0]?.url, + desc: res.description, + episodes: [ + { + title: "Watch", + urls: [ + { + name: res.title, + url: res.videoId, + }, + ], + }, + ], + }; + } + + async watch(url) { + const res = await this.request(`/videos/${url}`); + + const sub = await this.request(`/streams/${url}`, { + headers: { + "Miru-Url": "https://pipedapi.kavin.rocks", + }, + }); + + const subtitles = sub.subtitles.map((item) => ({ + title: item.name, + url: item.url, + language: item.code, + })); + + return { + type: "hls", + url: res.formatStreams?.[2]?.url, + subtitles: subtitles, + }; +} +}