mirror of
https://github.com/ThaUnknown/miru.git
synced 2026-04-20 05:02:04 +00:00
search using magnet links
This commit is contained in:
parent
c9cbb1c295
commit
38c7b7ece3
2 changed files with 26 additions and 28 deletions
|
|
@ -18,11 +18,15 @@ var options = {
|
|||
variables: variables
|
||||
})
|
||||
}
|
||||
|
||||
const searchRx = /(magnet:)?([A-F\d]{8,40})?(.*\.torrent)?/i;
|
||||
function search() {
|
||||
searchAnime(document.querySelector("#search").value)
|
||||
let regexParse = searchRx.exec(document.querySelector("#search").value)
|
||||
if (regexParse[1] || regexParse[2] || regexParse[3]) {
|
||||
addTorrent(document.querySelector("#search").value)
|
||||
} else {
|
||||
searchAnime(document.querySelector("#search").value)
|
||||
}
|
||||
}
|
||||
|
||||
async function alRequest(a, b) {
|
||||
if (!a) {
|
||||
variables.sort = "TRENDING_DESC"
|
||||
|
|
@ -297,23 +301,9 @@ async function nyaaRss(url) {
|
|||
}
|
||||
|
||||
|
||||
const regex = /((?:\[[^\]]*\])*)?\s*((?:[^\d\[\.](?!S\d))*)?\s*((?:S\d+[^\w\[]*E?)?[\d\-]*)\s*(.*)?/;
|
||||
const regex = /((?:\[[^\]]*\])*)?\s*((?:[^\d\[\.](?!S\d))*)?\s*((?:S\d+[^\w\[]*E?)?[\d\-]*)\s*(.*)?/i;
|
||||
let store = {};
|
||||
async function regtest() {
|
||||
if ((m = regex.exec(str)) !== null) {
|
||||
if (m[2].endsWith(" - ")) {
|
||||
m[2] = m[2].slice(0, -3)
|
||||
}
|
||||
if (!store[m[2]] && !alResponse.data.Page.media.some(media => (Object.values(media.title).concat(media.synonyms).filter(name => name != null).includes(m[2]) && ((store[m[2]] = media) && true)))) {
|
||||
//shit not found, lookup
|
||||
store[m[2]] = await alRequest(m[2], 1)
|
||||
}
|
||||
|
||||
m.forEach((match, groupIndex) => {
|
||||
console.log(`Found match, group ${groupIndex}: ${match}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
async function hsRss(url) {
|
||||
let frag = document.createDocumentFragment()
|
||||
document.querySelector(".releases").innerHTML = ""
|
||||
|
|
@ -387,7 +377,7 @@ async function hsRss(url) {
|
|||
}
|
||||
frag.appendChild(template)
|
||||
}
|
||||
|
||||
|
||||
document.querySelector(".releases").appendChild(frag)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
const controls = document.getElementsByClassName('ctrl')
|
||||
const controls = document.getElementsByClassName('ctrl'),
|
||||
btnfull = document.querySelector('#bfull'),
|
||||
btnpp = document.querySelector('#bpp')
|
||||
// player = document.querySelector('#player'),
|
||||
// volume = document.querySelector('#vol'),
|
||||
// progress = document.querySelector('#prog'),
|
||||
|
|
@ -8,7 +10,6 @@ const controls = document.getElementsByClassName('ctrl')
|
|||
// playPause = document.querySelector('#ptoggle'),
|
||||
// btnpp = document.querySelector('#bpp'),
|
||||
// btnm = document.querySelector("#bmute"),
|
||||
// btnfull = document.querySelector('#bfull'),
|
||||
// btnpip = document.querySelector('#bpip'),
|
||||
// elapsed = document.querySelector("#elapsed"),
|
||||
// remaining = document.querySelector("#remaining"),
|
||||
|
|
@ -220,9 +221,9 @@ function toTS(sec) {
|
|||
async function playVideo() {
|
||||
try {
|
||||
await video.play();
|
||||
bpp.innerHTML = "pause";
|
||||
btnpp.innerHTML = "pause";
|
||||
} catch (err) {
|
||||
bpp.innerHTML = "play_arrow";
|
||||
btnpp.innerHTML = "play_arrow";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -230,7 +231,7 @@ function bpp() {
|
|||
if (video.paused) {
|
||||
playVideo();
|
||||
} else {
|
||||
bpp.innerHTML = "play_arrow";
|
||||
btnpp.innerHTML = "play_arrow";
|
||||
video.pause();
|
||||
}
|
||||
}
|
||||
|
|
@ -295,19 +296,26 @@ function btheatre() {
|
|||
function bfull() {
|
||||
if (!document.fullscreenElement) {
|
||||
player.requestFullscreen();
|
||||
bfull.innerHTML = "fullscreen_exit"
|
||||
btnfull.innerHTML = "fullscreen_exit"
|
||||
} else if (document.exitFullscreen) {
|
||||
document.exitFullscreen();
|
||||
bfull.innerHTML = "fullscreen"
|
||||
btnfull.innerHTML = "fullscreen"
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//seeking and skipping
|
||||
|
||||
function seek(a) {
|
||||
video.currentTime += a;
|
||||
if (a == 85 && video.currentTime < 10) {
|
||||
video.currentTime = 90
|
||||
} else if (a == 85 && (video.duration - video.currentTime) < 90) {
|
||||
video.currentTime = video.duration
|
||||
} else {
|
||||
video.currentTime += a;
|
||||
}
|
||||
updateDisplay()
|
||||
}
|
||||
|
||||
// subtitles, generates content every single time its opened because fuck knows when the parser will find new shit
|
||||
|
||||
let off
|
||||
|
|
|
|||
Loading…
Reference in a new issue