Compare commits

..

9 Commits
v106 ... master

Author SHA1 Message Date
0eedf53fc8
use extension packer 2022-10-16 22:34:25 +02:00
1e6316f2b3
add firefox extension
All checks were successful
continuous-integration/drone Build is passing
2022-10-16 21:17:23 +02:00
da2c738c52
set playlistid
Some checks reported errors
continuous-integration/drone Build was killed
2022-03-06 09:31:36 +01:00
a190acd1d8
set pathname for kodi 2022-03-06 09:28:44 +01:00
93547547f1
add kodi support for stream.purser.it 2022-03-06 09:26:03 +01:00
050cf89b45
add kodi queue 2022-03-06 08:54:23 +01:00
487e15e429
fix content type 2022-03-05 23:51:03 +01:00
cd5894429c
random id 2022-03-05 20:33:15 +01:00
108de113d1
add print 2022-03-05 20:07:41 +01:00
6 changed files with 112 additions and 63 deletions

View File

@ -1,13 +1,13 @@
kind: pipeline kind: pipeline
name: default name: default
steps: steps:
- name: compile-chrome - name: compile-extensions
image: roypur/chrome-packer:latest image: roypur/extension-packer:latest
environment: environment:
CHROME_PRIVKEY: CHROME_PRIVKEY:
from_secret: chrome_privkey from_secret: chrome_privkey
commands: commands:
- ./pack-chrome.sh - ./pack-browsers.sh
- name: gitea_release - name: gitea_release
image: plugins/gitea-release image: plugins/gitea-release
settings: settings:
@ -15,6 +15,6 @@ steps:
from_secret: gitea_token from_secret: gitea_token
base_url: https://git.purser.it base_url: https://git.purser.it
title: ${DRONE_TAG} title: ${DRONE_TAG}
files: out/proxy-stream-${DRONE_TAG}.crx files: out/proxy-stream-${DRONE_TAG}.crx out/proxy-stream-${DRONE_TAG}.xpi
when: when:
event: tag event: tag

1
.gitignore vendored
View File

@ -11,4 +11,5 @@ android/.gradle/*
android/gradle/* android/gradle/*
chrome/*.png chrome/*.png
*.crx *.crx
*.xpi
sources.json sources.json

View File

@ -7,7 +7,7 @@
"48": "icon-48.png", "48": "icon-48.png",
"128": "icon-128.png" "128": "icon-128.png"
}, },
"version": "106.0", "version": "111.0",
"manifest_version": 3, "manifest_version": 3,
"host_permissions": ["http://127.0.0.1:4000/jsonrpc"], "host_permissions": ["http://127.0.0.1:4000/jsonrpc"],
"permissions": ["tabs"], "permissions": ["tabs"],

View File

@ -4,7 +4,8 @@
<title>Proxy Stream</title> <title>Proxy Stream</title>
</head> </head>
<body> <body>
<button>Proxy Stream</button> <button id="proxy-button">Proxy Stream</button>
<button>Play on kodi</button> <button id="kodi-play-button">Play on kodi</button>
<button id="kodi-queue-button">Queue on kodi</button>
</body> </body>
</html> </html>

View File

@ -5,42 +5,56 @@ providers.set("youtu.be", "youtube")
providers.set("tv.nrk.no", "nrk") providers.set("tv.nrk.no", "nrk")
providers.set("seafile.purser.it", "seafile") providers.set("seafile.purser.it", "seafile")
const random = () => {
const arr = new Uint8Array(32)
window.crypto.getRandomValues(arr)
return [...arr].map(x => x.toString(16).padStart(2, "0")).join("")
}
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
let [proxyButton, kodiButton] = document.getElementsByTagName("button") const proxyButton = document.getElementById("proxy-button")
proxyButton.addEventListener("click", (ev) => { const kodiPlayButton = document.getElementById("kodi-play-button")
chrome.tabs.query({currentWindow: true, active: true}, (tabs) => { const kodiQueueButton = document.getElementById("kodi-queue-button")
let oldurl = new URL(tabs[0].url)
async function handleProxyButton(ev) {
const [tab] = chrome.tabs.query({currentWindow: true, active: true})
const oldurl = new URL(tab.url)
const search = new URLSearchParams()
const hostname = oldurl.hostname.toLowerCase()
let newurl = new URL("https://stream.purser.it") let newurl = new URL("https://stream.purser.it")
let search = new URLSearchParams()
let hostname = oldurl.hostname.toLowerCase()
if(providers.has(hostname)) { if(providers.has(hostname)) {
if(hostname.includes("youtube.com")) { if(hostname.includes("youtube.com")) {
let newpath = oldurl.searchParams.get("v") let newpath = oldurl.searchParams.get("v")
if((newpath instanceof String) || ((typeof newpath) === "string")) { if(newpath) {
newurl.pathname = "/" + newpath newurl.pathname = "/" + newpath
} }
} else { } else {
newurl.pathname = oldurl.pathname newurl.pathname = oldurl.pathname
} }
search.append("provider", providers.get(hostname)) search.append("provider", providers.get(hostname))
} else {
return
} }
newurl.search = search.toString() newurl.search = search.toString()
let tab = {} const newtab = {}
tab.url = newurl.href newtab.url = newurl.href
chrome.tabs.create(tab) chrome.tabs.create(newtab)
}) }
})
kodiButton.addEventListener("click", (ev) => { async function handleKodiButton(ev, method, playlistid) {
chrome.tabs.query({currentWindow: true, active: true}, (tabs) => { const [tab] = await chrome.tabs.query({currentWindow: true, active: true})
let oldurl = new URL(tabs[0].url) const oldurl = new URL(tab.url)
const search = new URLSearchParams()
const hostname = oldurl.hostname.toLowerCase()
let newurl = new URL("https://stream.purser.it") let newurl = new URL("https://stream.purser.it")
let search = new URLSearchParams()
let hostname = oldurl.hostname.toLowerCase()
if(providers.has(hostname)) { if(providers.has(hostname)) {
if(hostname.includes("youtube.com")) { if(hostname.includes("youtube.com")) {
newurl = new URL("plugin://plugin.video.youtube") newurl = new URL("plugin://plugin.video.youtube")
search.append("action", "play_video") search.append("action", "play_video")
let video_id = oldurl.searchParams.get("v") const video_id = oldurl.searchParams.get("v")
if(video_id) { if(video_id) {
search.append("videoid", video_id) search.append("videoid", video_id)
} }
@ -49,14 +63,32 @@ document.addEventListener("DOMContentLoaded", () => {
search.append("raw", "true") search.append("raw", "true")
newurl.pathname = oldurl.pathname newurl.pathname = oldurl.pathname
} }
} else if(hostname == "stream.purser.it") {
const provider = oldurl.searchParams.get("provider")
if(provider) {
if(provider == "youtube") {
newurl = new URL("plugin://plugin.video.youtube")
search.append("action", "play_video")
const video_id = oldurl.pathname.replace("/", "")
if(video_id) {
search.append("videoid", video_id)
}
} else {
newurl.pathname = oldurl.pathname
search.append("provider", provider)
search.append("raw", "true")
}
}
} else {
return
} }
newurl.search = search.toString() newurl.search = search.toString()
let req = { const req = {
jsonrpc: "2.0", jsonrpc: "2.0",
method: "Player.Open", method: method,
id: 12345, id: random(),
params: { params: {
item: { item: {
file: newurl.href file: newurl.href
@ -64,17 +96,27 @@ document.addEventListener("DOMContentLoaded", () => {
} }
} }
try { if(playlistid) {
fetch("http://127.0.0.1:4000/jsonrpc", { req.params.playlistid = playlistid
}
const resp = await fetch("http://127.0.0.1:4000/jsonrpc", {
method: "POST", method: "POST",
body: JSON.stringify(req), body: JSON.stringify(req),
headers: { headers: {
"Content-Type": "application/json charset=utf-8" "Content-Type": "application/json; charset=utf-8"
}
}).then(resp => console.log(resp))
} catch(e) {
console.log(e)
} }
}) })
console.log(resp)
}
kodiPlayButton.addEventListener("click", async ev => {
await handleKodiButton(ev, "Player.Open")
}) })
kodiQueueButton.addEventListener("click", async ev => {
await handleKodiButton(ev, "Playlist.Add", 1)
})
proxyButton.addEventListener("click", handleProxyButton)
}) })

View File

@ -36,6 +36,9 @@ then
Xvfb "${DISPLAY}" & Xvfb "${DISPLAY}" &
fi fi
echo "DRONE_TAG=${DRONE_TAG}"
echo "DISPLAY=${DISPLAY}"
${dir}/icons.sh ${dir}/icons.sh
browser=$(which chromium-browser 2> /dev/null) browser=$(which chromium-browser 2> /dev/null)
@ -47,6 +50,8 @@ fi
release_folder="${temp_dir}/out/proxy-stream-${DRONE_TAG}" release_folder="${temp_dir}/out/proxy-stream-${DRONE_TAG}"
cp -r "${dir}/chrome" "${release_folder}" cp -r "${dir}/chrome" "${release_folder}"
(cd "${release_folder}" && zip -r "${temp_dir}/out/proxy-stream-${DRONE_TAG}.xpi" .)
if grep "/proc/1/cgroup" -q -F -e docker if grep "/proc/1/cgroup" -q -F -e docker
then then
${browser} --disable-gpu --no-sandbox --user-data-dir=${chrome_dir} --pack-extension="${temp_dir}/out/proxy-stream-${DRONE_TAG}" --pack-extension-key="${temp_dir}/privkey.pem" ${browser} --disable-gpu --no-sandbox --user-data-dir=${chrome_dir} --pack-extension="${temp_dir}/out/proxy-stream-${DRONE_TAG}" --pack-extension-key="${temp_dir}/privkey.pem"