From 2e8d449a1273e3c3923cdb3ba0e6c12e8203bcdc Mon Sep 17 00:00:00 2001 From: Bethuel Date: Fri, 5 Jan 2024 15:09:17 +0000 Subject: [PATCH 1/2] added piped --- repo/piped.video.js | 113 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 repo/piped.video.js diff --git a/repo/piped.video.js b/repo/piped.video.js new file mode 100644 index 0000000..0b95b5c --- /dev/null +++ b/repo/piped.video.js @@ -0,0 +1,113 @@ +// ==MiruExtension== +// @name Piped +// @version v0.0.1 +// @author bethro +// @lang all +// @license MIT +// @icon https://piped.video/img/icons/android-chrome-192x192.png +// @package piped.video +// @type bangumi +// @webSite https://piped.video +// ==/MiruExtension== + +export default class extends Extension { + async req(url) { + return this.request(url, { + headers: { + "Miru-Url": await this.getSetting("piped"), + }, + }); + } + + async load() { + this.registerSetting({ + title: "PIPED INSTANCE", + key: "piped", + type: "input", + description: "url piped instance api", + defaultValue: "https://pipedapi.kavin.rocks", + }); + + this.registerSetting({ + title: "DEFAULT QUALITY", + key: "quality", + type: "input", + description: "default video quality", + defaultValue: "480p", + }); + } + + async latest(page) { + const res = await this.req(`/trending?region=US`); + return res.map((item) => ({ + url: item.url, + title: item.title, + cover: item.thumbnail, + })); + } + + async search(kw, page) { + const res = await this.req(`/search?q=${kw}&filter=all`); + let streams = res.items.filter((item) => item.type == "stream"); + + return streams.map((item) => { + return { + url: item.url, + title: item.title || item.name, + cover: item.thumbnail, + }; + }); + } + async detail(url) { + const videoID = url.split("v=").pop(); + const res = await this.req(`/streams/${videoID}`); + + let preferredQuality = await this.getSetting("quality"); + const sortEpisodes = (episodes) => + episodes.sort((a, b) => { + const qualityA = a.title.toLowerCase(); + const qualityB = b.title.toLowerCase(); + + if (qualityA === preferredQuality) return -1; + if (qualityB === preferredQuality) return 1; + return qualityA.localeCompare(qualityB); + }); + + let episodes = sortEpisodes( + res.videoStreams.map((item, index) => { + const audioStream = res.audioStreams[index] || res.audioStreams[0]; + const combinedURL = `${item.url}|${audioStream ? audioStream.url : ''}|${videoID}`; + return { + title: item.quality, + urls: [{ name: res.title, url: combinedURL }], + }; + }) + ); + + + return { + title: res.title, + cover: res.thumbnailUrl, + desc: res.description, + episodes, + }; + } + + async watch(url) { + const [videoUrl, audioUrl, videoID] = url.split("|"); + const sub = await this.req(`/streams/${videoID}`); + + const subtitles = sub.subtitles.map((item) => ({ + title: item.name, + url: item.url, + language: item.code, + })); + + return { + type: "hls", + url: videoUrl, + audioTrack: audioUrl, + subtitles: subtitles, + }; + } +} From 3a77b84b34cabada0756a3737da1c4afb11731f0 Mon Sep 17 00:00:00 2001 From: Automated Publisher Date: Fri, 5 Jan 2024 15:09:48 +0000 Subject: [PATCH 2/2] Automated publish: Fri Jan 5 15:09:48 UTC 2024 2e8d449a1273e3c3923cdb3ba0e6c12e8203bcdc --- README.md | 1 + index.json | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index 1bfb62e..afdc171 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ Miru extensions repository | [Miru App Download](https://github.com/miru-project | Mtlnation | mtlnation.com | v0.0.2 | OshekharO | en | fikushon | [Source Code](https://github.com/miru-project/repo/blob/main/repo/mtlnation.com.js) | | YTS.mx | mx.yts | v0.0.6 | MiaoMint | all | bangumi | [Source Code](https://github.com/miru-project/repo/blob/main/repo/mx.yts.js) | | Nyaa | nyaa.si | v0.0.1 | appdevelpo | en | bangumi | [Source Code](https://github.com/miru-project/repo/blob/main/repo/nyaa.si.js) | +| Piped | piped.video | v0.0.1 | bethro | all | bangumi | [Source Code](https://github.com/miru-project/repo/blob/main/repo/piped.video.js) | | rawkuma | rawkuma.com | v0.0.2 | appdevelpo | jp | manga | [Source Code](https://github.com/miru-project/repo/blob/main/repo/rawkuma.com.js) | | ReadLN | readlightnovels | v0.0.2 | OshekharO | en | fikushon | [Source Code](https://github.com/miru-project/repo/blob/main/repo/readlightnovels.js) | | ACG.RIP | rip.acg | v0.0.1 | MiaoMint | zh-cn | bangumi | [Source Code](https://github.com/miru-project/repo/blob/main/repo/rip.acg.js) | diff --git a/index.json b/index.json index 1b99777..aa1226b 100644 --- a/index.json +++ b/index.json @@ -745,6 +745,18 @@ "version": "v0.0.1", "webSite": "https://www.haha888.xyz" }, + { + "author": "bethro", + "icon": "https://piped.video/img/icons/android-chrome-192x192.png", + "lang": "all", + "license": "MIT", + "name": "Piped", + "package": "piped.video", + "type": "bangumi", + "url": "piped.video.js", + "version": "v0.0.1", + "webSite": "https://piped.video" + }, { "author": "bachig26", "icon": "https://pornenix.com/templates/pornenix/images/logo.png",