Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
0eedf53fc8 | |||
1e6316f2b3 | |||
da2c738c52 | |||
a190acd1d8 | |||
93547547f1 | |||
050cf89b45 | |||
487e15e429 | |||
cd5894429c | |||
108de113d1 | |||
57decd2fe2 | |||
e8d4f1f329 | |||
21c4c64cde |
@ -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
1
.gitignore
vendored
@ -11,4 +11,5 @@ android/.gradle/*
|
|||||||
android/gradle/*
|
android/gradle/*
|
||||||
chrome/*.png
|
chrome/*.png
|
||||||
*.crx
|
*.crx
|
||||||
|
*.xpi
|
||||||
sources.json
|
sources.json
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
"48": "icon-48.png",
|
"48": "icon-48.png",
|
||||||
"128": "icon-128.png"
|
"128": "icon-128.png"
|
||||||
},
|
},
|
||||||
"version": "104.0",
|
"version": "111.0",
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"host_permissions": ["http://127.0.0.1:8083/jsonrpc", "http://127.0.0.1:8080/jsonrpc"],
|
"host_permissions": ["http://127.0.0.1:4000/jsonrpc"],
|
||||||
"permissions": ["tabs"],
|
"permissions": ["tabs"],
|
||||||
"action": {
|
"action": {
|
||||||
"default_title": "Proxy Stream",
|
"default_title": "Proxy Stream",
|
||||||
|
@ -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>
|
||||||
|
173
chrome/script.js
173
chrome/script.js
@ -1,83 +1,122 @@
|
|||||||
let providers = new Map();
|
let providers = new Map()
|
||||||
providers.set("www.youtube.com", "youtube");
|
providers.set("www.youtube.com", "youtube")
|
||||||
providers.set("youtube.com", "youtube");
|
providers.set("youtube.com", "youtube")
|
||||||
providers.set("youtu.be", "youtube");
|
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);
|
|
||||||
let newurl = new URL("https://stream.purser.it");
|
async function handleProxyButton(ev) {
|
||||||
let search = new URLSearchParams();
|
const [tab] = chrome.tabs.query({currentWindow: true, active: true})
|
||||||
let hostname = oldurl.hostname.toLowerCase();
|
const oldurl = new URL(tab.url)
|
||||||
if(providers.has(hostname)) {
|
const search = new URLSearchParams()
|
||||||
if(hostname.includes("youtube.com")) {
|
const hostname = oldurl.hostname.toLowerCase()
|
||||||
let newpath = oldurl.searchParams.get("v");
|
let newurl = new URL("https://stream.purser.it")
|
||||||
if((newpath instanceof String) || ((typeof newpath) === "string")) {
|
|
||||||
newurl.pathname = "/" + newpath;
|
if(providers.has(hostname)) {
|
||||||
}
|
if(hostname.includes("youtube.com")) {
|
||||||
} else {
|
let newpath = oldurl.searchParams.get("v")
|
||||||
newurl.pathname = oldurl.pathname;
|
if(newpath) {
|
||||||
|
newurl.pathname = "/" + newpath
|
||||||
}
|
}
|
||||||
search.append("provider", providers.get(hostname));
|
} else {
|
||||||
|
newurl.pathname = oldurl.pathname
|
||||||
}
|
}
|
||||||
newurl.search = search.toString();
|
search.append("provider", providers.get(hostname))
|
||||||
let tab = {};
|
} else {
|
||||||
tab.url = newurl.href;
|
return
|
||||||
chrome.tabs.create(tab);
|
}
|
||||||
});
|
|
||||||
});
|
newurl.search = search.toString()
|
||||||
kodiButton.addEventListener("click", (ev) => {
|
const newtab = {}
|
||||||
chrome.tabs.query({currentWindow: true, active: true}, (tabs) => {
|
newtab.url = newurl.href
|
||||||
let oldurl = new URL(tabs[0].url);
|
chrome.tabs.create(newtab)
|
||||||
let newurl = new URL(tabs[0].url);
|
}
|
||||||
let search = new URLSearchParams();
|
|
||||||
let hostname = oldurl.hostname.toLowerCase();
|
async function handleKodiButton(ev, method, playlistid) {
|
||||||
|
const [tab] = await 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")
|
||||||
|
|
||||||
|
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)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
search.append("provider", providers.get(hostname))
|
||||||
|
search.append("raw", "true")
|
||||||
|
newurl.pathname = oldurl.pathname
|
||||||
}
|
}
|
||||||
newurl.search = search.toString();
|
} else if(hostname == "stream.purser.it") {
|
||||||
|
const provider = oldurl.searchParams.get("provider")
|
||||||
let req = {
|
if(provider) {
|
||||||
jsonrpc: "2.0",
|
if(provider == "youtube") {
|
||||||
method: "Player.Open",
|
newurl = new URL("plugin://plugin.video.youtube")
|
||||||
id: 12345,
|
search.append("action", "play_video")
|
||||||
params: {
|
const video_id = oldurl.pathname.replace("/", "")
|
||||||
item: {
|
if(video_id) {
|
||||||
file: newurl.href
|
search.append("videoid", video_id)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
newurl.pathname = oldurl.pathname
|
||||||
|
search.append("provider", provider)
|
||||||
|
search.append("raw", "true")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
} else {
|
||||||
fetch("http://127.0.0.1:8080/jsonrpc", {
|
return
|
||||||
method: "POST",
|
}
|
||||||
body: JSON.stringify(req),
|
|
||||||
headers: {
|
newurl.search = search.toString()
|
||||||
"Content-Type": "application/json; charset=utf-8"
|
|
||||||
}
|
const req = {
|
||||||
}).then(resp => console.log(resp))
|
jsonrpc: "2.0",
|
||||||
} catch(e) {
|
method: method,
|
||||||
console.log(e)
|
id: random(),
|
||||||
|
params: {
|
||||||
|
item: {
|
||||||
|
file: newurl.href
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
}
|
||||||
fetch("http://127.0.0.1:8083/jsonrpc", {
|
|
||||||
method: "POST",
|
if(playlistid) {
|
||||||
body: JSON.stringify(req),
|
req.params.playlistid = playlistid
|
||||||
headers: {
|
}
|
||||||
"Content-Type": "application/json; charset=utf-8"
|
|
||||||
}
|
const resp = await fetch("http://127.0.0.1:4000/jsonrpc", {
|
||||||
}).then(resp => console.log(resp))
|
method: "POST",
|
||||||
} catch(e) {
|
body: JSON.stringify(req),
|
||||||
console.log(e)
|
headers: {
|
||||||
|
"Content-Type": "application/json; charset=utf-8"
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
});
|
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)
|
||||||
|
})
|
||||||
|
@ -4,6 +4,14 @@ temp_name=$(head -c 20 /dev/random | xxd -p | tr -dc a-f0-9)
|
|||||||
temp_dir="/tmp/${temp_name}"
|
temp_dir="/tmp/${temp_name}"
|
||||||
chrome_dir="${temp_dir}/chrome"
|
chrome_dir="${temp_dir}/chrome"
|
||||||
|
|
||||||
|
if [[ ! -n "${DRONE_TAG}" ]]
|
||||||
|
then
|
||||||
|
export DRONE_TAG=$(git describe --abbrev=0 | tr -dc v0-9)
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "${dir}/out"
|
||||||
|
rm -rf "${dir}/out"
|
||||||
|
|
||||||
mkdir -p "${temp_dir}/out"
|
mkdir -p "${temp_dir}/out"
|
||||||
mkdir -p "${chrome_dir}"
|
mkdir -p "${chrome_dir}"
|
||||||
|
|
||||||
@ -22,12 +30,15 @@ then
|
|||||||
dbus-daemon --session --address="${DBUS_SESSION_BUS_ADDRESS}" &
|
dbus-daemon --session --address="${DBUS_SESSION_BUS_ADDRESS}" &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${DISPLAY}test" == "test" ]]
|
if [[ ! -n "${DISPLAY}" ]]
|
||||||
then
|
then
|
||||||
export DISPLAY=:8819
|
export DISPLAY=:8819
|
||||||
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)
|
||||||
@ -39,7 +50,14 @@ 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}"
|
||||||
|
|
||||||
${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"
|
(cd "${release_folder}" && zip -r "${temp_dir}/out/proxy-stream-${DRONE_TAG}.xpi" .)
|
||||||
|
|
||||||
|
if grep "/proc/1/cgroup" -q -F -e docker
|
||||||
|
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"
|
||||||
|
else
|
||||||
|
${browser} --user-data-dir=${chrome_dir} --pack-extension="${temp_dir}/out/proxy-stream-${DRONE_TAG}" --pack-extension-key="${temp_dir}/privkey.pem"
|
||||||
|
fi
|
||||||
|
|
||||||
rm -rf "${release_folder}"
|
rm -rf "${release_folder}"
|
||||||
mv "${temp_dir}/out" "${dir}/out"
|
mv "${temp_dir}/out" "${dir}/out"
|
Loading…
Reference in New Issue
Block a user