add kodi queue
This commit is contained in:
parent
487e15e429
commit
050cf89b45
@ -7,7 +7,7 @@
|
|||||||
"48": "icon-48.png",
|
"48": "icon-48.png",
|
||||||
"128": "icon-128.png"
|
"128": "icon-128.png"
|
||||||
},
|
},
|
||||||
"version": "108.0",
|
"version": "109.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"],
|
||||||
|
@ -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>
|
||||||
|
137
chrome/script.js
137
chrome/script.js
@ -12,75 +12,90 @@ const random = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 instanceof String) || ((typeof newpath) === "string")) {
|
||||||
|
newurl.pathname = "/" + newpath
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
newurl.pathname = oldurl.pathname
|
||||||
|
}
|
||||||
|
search.append("provider", providers.get(hostname))
|
||||||
|
}
|
||||||
|
newurl.search = search.toString()
|
||||||
|
const newtab = {}
|
||||||
|
newtab.url = newurl.href
|
||||||
|
chrome.tabs.create(newtab)
|
||||||
|
}
|
||||||
|
|
||||||
|
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")) {
|
||||||
|
newurl = new URL("plugin://plugin.video.youtube")
|
||||||
|
search.append("action", "play_video")
|
||||||
|
let video_id = oldurl.searchParams.get("v")
|
||||||
|
if(video_id) {
|
||||||
|
search.append("videoid", video_id)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
search.append("provider", providers.get(hostname))
|
search.append("provider", providers.get(hostname))
|
||||||
|
search.append("raw", "true")
|
||||||
|
newurl.pathname = oldurl.pathname
|
||||||
}
|
}
|
||||||
newurl.search = search.toString()
|
}
|
||||||
let tab = {}
|
|
||||||
tab.url = newurl.href
|
newurl.search = search.toString()
|
||||||
chrome.tabs.create(tab)
|
|
||||||
})
|
const req = {
|
||||||
})
|
jsonrpc: "2.0",
|
||||||
kodiButton.addEventListener("click", (ev) => {
|
method: method,
|
||||||
chrome.tabs.query({currentWindow: true, active: true}, (tabs) => {
|
id: random(),
|
||||||
let oldurl = new URL(tabs[0].url)
|
params: {
|
||||||
let newurl = new URL("https://stream.purser.it")
|
item: {
|
||||||
let search = new URLSearchParams()
|
file: newurl.href
|
||||||
let hostname = oldurl.hostname.toLowerCase()
|
|
||||||
if(providers.has(hostname)) {
|
|
||||||
if(hostname.includes("youtube.com")) {
|
|
||||||
newurl = new URL("plugin://plugin.video.youtube")
|
|
||||||
search.append("action", "play_video")
|
|
||||||
let video_id = oldurl.searchParams.get("v")
|
|
||||||
if(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()
|
if(playlistid) {
|
||||||
|
req.params.playlistid = 1
|
||||||
|
}
|
||||||
|
|
||||||
let req = {
|
const resp = await fetch("http://127.0.0.1:4000/jsonrpc", {
|
||||||
jsonrpc: "2.0",
|
method: "POST",
|
||||||
method: "Player.Open",
|
body: JSON.stringify(req),
|
||||||
id: random(),
|
headers: {
|
||||||
params: {
|
"Content-Type": "application/json; charset=utf-8"
|
||||||
item: {
|
|
||||||
file: newurl.href
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
fetch("http://127.0.0.1:4000/jsonrpc", {
|
|
||||||
method: "POST",
|
|
||||||
body: JSON.stringify(req),
|
|
||||||
headers: {
|
|
||||||
"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)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user