mirror of
https://github.com/ThaUnknown/miru.git
synced 2026-04-21 09:31:57 +00:00
minor fixes, WAIT lookup progress
This commit is contained in:
parent
d072f8d590
commit
ba81e5a26e
3 changed files with 390 additions and 287 deletions
|
|
@ -85,6 +85,9 @@ async function alRequest(searchName, method) {
|
||||||
media (type: $type, search: $search, sort: $sort, status: $status) {
|
media (type: $type, search: $search, sort: $sort, status: $status) {
|
||||||
id
|
id
|
||||||
title {
|
title {
|
||||||
|
romaji
|
||||||
|
english
|
||||||
|
native
|
||||||
userPreferred
|
userPreferred
|
||||||
}
|
}
|
||||||
description(
|
description(
|
||||||
|
|
@ -96,12 +99,23 @@ async function alRequest(searchName, method) {
|
||||||
status
|
status
|
||||||
episodes
|
episodes
|
||||||
duration
|
duration
|
||||||
|
averageScore
|
||||||
genres
|
genres
|
||||||
coverImage {
|
coverImage {
|
||||||
extraLarge
|
extraLarge
|
||||||
medium
|
medium
|
||||||
color
|
color
|
||||||
}
|
}
|
||||||
|
bannerImage
|
||||||
|
synonyms
|
||||||
|
nextAiringEpisode {
|
||||||
|
timeUntilAiring
|
||||||
|
episode
|
||||||
|
}
|
||||||
|
trailer {
|
||||||
|
id
|
||||||
|
site
|
||||||
|
}
|
||||||
streamingEpisodes {
|
streamingEpisodes {
|
||||||
title
|
title
|
||||||
thumbnail
|
thumbnail
|
||||||
|
|
@ -166,6 +180,9 @@ async function alRequest(searchName, method) {
|
||||||
media (type: $type, search: $search, sort: $sort) {
|
media (type: $type, search: $search, sort: $sort) {
|
||||||
id
|
id
|
||||||
title {
|
title {
|
||||||
|
romaji
|
||||||
|
english
|
||||||
|
native
|
||||||
userPreferred
|
userPreferred
|
||||||
}
|
}
|
||||||
description(
|
description(
|
||||||
|
|
@ -177,12 +194,23 @@ async function alRequest(searchName, method) {
|
||||||
status
|
status
|
||||||
episodes
|
episodes
|
||||||
duration
|
duration
|
||||||
|
averageScore
|
||||||
genres
|
genres
|
||||||
coverImage {
|
coverImage {
|
||||||
extraLarge
|
extraLarge
|
||||||
medium
|
medium
|
||||||
color
|
color
|
||||||
}
|
}
|
||||||
|
bannerImage
|
||||||
|
synonyms
|
||||||
|
nextAiringEpisode {
|
||||||
|
timeUntilAiring
|
||||||
|
episode
|
||||||
|
}
|
||||||
|
trailer {
|
||||||
|
id
|
||||||
|
site
|
||||||
|
}
|
||||||
streamingEpisodes {
|
streamingEpisodes {
|
||||||
title
|
title
|
||||||
thumbnail
|
thumbnail
|
||||||
|
|
@ -190,19 +218,63 @@ async function alRequest(searchName, method) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
|
} else if (method == "SearchIDSingle") {
|
||||||
|
variables.id = searchName
|
||||||
|
query = `
|
||||||
|
query ($id: Int, $type: MediaType) {
|
||||||
|
Media (id: $id, type: $type){
|
||||||
|
id
|
||||||
|
title {
|
||||||
|
romaji
|
||||||
|
english
|
||||||
|
native
|
||||||
|
userPreferred
|
||||||
|
}
|
||||||
|
description(
|
||||||
|
asHtml: true
|
||||||
|
)
|
||||||
|
season
|
||||||
|
seasonYear
|
||||||
|
format
|
||||||
|
status
|
||||||
|
episodes
|
||||||
|
duration
|
||||||
|
averageScore
|
||||||
|
genres
|
||||||
|
coverImage {
|
||||||
|
extraLarge
|
||||||
|
medium
|
||||||
|
color
|
||||||
|
}
|
||||||
|
bannerImage
|
||||||
|
synonyms
|
||||||
|
nextAiringEpisode {
|
||||||
|
timeUntilAiring
|
||||||
|
episode
|
||||||
|
}
|
||||||
|
trailer {
|
||||||
|
id
|
||||||
|
site
|
||||||
|
}
|
||||||
|
streamingEpisodes {
|
||||||
|
title
|
||||||
|
thumbnail
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`
|
||||||
}
|
}
|
||||||
options.body = JSON.stringify({
|
options.body = JSON.stringify({
|
||||||
query: query,
|
query: query,
|
||||||
variables: variables
|
variables: variables
|
||||||
})
|
})
|
||||||
|
|
||||||
let res = await fetch('https://graphql.anilist.co', options).catch((error) => console.error(error)),
|
let res = await fetch('https://graphql.anilist.co', options).catch((error) => console.error(error)),
|
||||||
json = await res.json();
|
json = await res.json();
|
||||||
return json
|
return json
|
||||||
}
|
}
|
||||||
function alEntry() {
|
function alEntry() {
|
||||||
if (playerData.nowPlaying && playerData.nowPlaying[0] && localStorage.getItem("ALtoken")) {
|
if (playerData.nowPlaying && playerData.nowPlaying[0] && localStorage.getItem("ALtoken")) {
|
||||||
let query = `
|
let query = `
|
||||||
mutation ($id: Int, $status: MediaListStatus, $episode: Int) {
|
mutation ($id: Int, $status: MediaListStatus, $episode: Int) {
|
||||||
SaveMediaListEntry (mediaId: $id, status: $status, progress: $episode) {
|
SaveMediaListEntry (mediaId: $id, status: $status, progress: $episode) {
|
||||||
id
|
id
|
||||||
|
|
@ -210,160 +282,160 @@ mutation ($id: Int, $status: MediaListStatus, $episode: Int) {
|
||||||
progress
|
progress
|
||||||
}
|
}
|
||||||
}`,
|
}`,
|
||||||
variables = {
|
variables = {
|
||||||
id: playerData.nowPlaying[0].id,
|
id: playerData.nowPlaying[0].id,
|
||||||
status: "CURRENT",
|
status: "CURRENT",
|
||||||
episode: parseInt(playerData.nowPlaying[1])
|
episode: parseInt(playerData.nowPlaying[1])
|
||||||
},
|
|
||||||
options = {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Authorization': 'Bearer ' + localStorage.getItem("ALtoken"),
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'Accept': 'application/json'
|
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
options = {
|
||||||
query: query,
|
method: 'POST',
|
||||||
variables: variables
|
headers: {
|
||||||
})
|
'Authorization': 'Bearer ' + localStorage.getItem("ALtoken"),
|
||||||
}
|
'Content-Type': 'application/json',
|
||||||
fetch("https://graphql.anilist.co", options)
|
'Accept': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
query: query,
|
||||||
|
variables: variables
|
||||||
|
})
|
||||||
|
}
|
||||||
|
fetch("https://graphql.anilist.co", options)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
let alResponse
|
||||||
let alResponse
|
async function searchAnime(a) {
|
||||||
async function searchAnime(a) {
|
let frag = document.createDocumentFragment(),
|
||||||
let frag = document.createDocumentFragment(),
|
browse = document.querySelector(".browse")
|
||||||
browse = document.querySelector(".browse")
|
browse.textContent = '';
|
||||||
browse.textContent = '';
|
browse.appendChild(skeletonCard)
|
||||||
browse.appendChild(skeletonCard)
|
a ? alResponse = await alRequest(a, "SearchName") : alResponse = await alRequest(a, "Trending")
|
||||||
a ? alResponse = await alRequest(a, "SearchName") : alResponse = await alRequest(a, "Trending")
|
try {
|
||||||
try {
|
alResponse.data.Page.media.forEach(media => {
|
||||||
alResponse.data.Page.media.forEach(media => {
|
let template = cardCreator(media)
|
||||||
let template = cardCreator(media)
|
template.onclick = () => {
|
||||||
template.onclick = () => {
|
viewAnime(media)
|
||||||
viewAnime(media)
|
}
|
||||||
}
|
frag.appendChild(template)
|
||||||
frag.appendChild(template)
|
})
|
||||||
})
|
} catch (e) {
|
||||||
} catch (e) {
|
console.error(e)
|
||||||
console.error(e)
|
}
|
||||||
|
browse.textContent = '';
|
||||||
|
browse.appendChild(frag)
|
||||||
}
|
}
|
||||||
browse.textContent = '';
|
|
||||||
browse.appendChild(frag)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
let detailsfrag = document.createDocumentFragment()
|
let detailsfrag = document.createDocumentFragment()
|
||||||
let details = {
|
let details = {
|
||||||
averageScore: "Average Score",
|
averageScore: "Average Score",
|
||||||
// duration: "Episode Duration",
|
// duration: "Episode Duration",
|
||||||
// episodes: "Episodes",
|
// episodes: "Episodes",
|
||||||
// format: "Format",
|
// format: "Format",
|
||||||
genres: "Genres",
|
genres: "Genres",
|
||||||
// season: "Season",
|
// season: "Season",
|
||||||
// seasonYear: "Year",
|
// seasonYear: "Year",
|
||||||
status: "Status",
|
status: "Status",
|
||||||
english: "English",
|
english: "English",
|
||||||
romaji: "Romaji",
|
romaji: "Romaji",
|
||||||
native: "Native",
|
native: "Native",
|
||||||
synonyms: "Synonyms"
|
synonyms: "Synonyms"
|
||||||
}
|
}
|
||||||
const episodeRx = /Episode (\d+) - (.*)/;
|
const episodeRx = /Episode (\d+) - (.*)/;
|
||||||
function viewAnime(media) {
|
function viewAnime(media) {
|
||||||
halfmoon.toggleModal("view")
|
halfmoon.toggleModal("view")
|
||||||
view.setAttribute("style", `background-image: url(${media.bannerImage}) !important`)
|
view.setAttribute("style", `background-image: url(${media.bannerImage}) !important`)
|
||||||
viewImg.src = media.coverImage.extraLarge
|
viewImg.src = media.coverImage.extraLarge
|
||||||
viewTitle.textContent = media.title.userPreferred
|
viewTitle.textContent = media.title.userPreferred
|
||||||
viewDesc.innerHTML = media.description || ""
|
viewDesc.innerHTML = media.description || ""
|
||||||
|
|
||||||
viewDetails.innerHTML = ""
|
viewDetails.innerHTML = ""
|
||||||
detailsCreator(media)
|
detailsCreator(media)
|
||||||
viewDetails.appendChild(detailsfrag)
|
viewDetails.appendChild(detailsfrag)
|
||||||
if (media.nextAiringEpisode) {
|
if (media.nextAiringEpisode) {
|
||||||
let temp = document.createElement("p")
|
let temp = document.createElement("p")
|
||||||
temp.innerHTML = `<span class="font-weight-bold">Airing</span><br><span class="text-muted"> Episode ${media.nextAiringEpisode.episode}: ${toTS(media.nextAiringEpisode.timeUntilAiring)}</span>`
|
temp.innerHTML = `<span class="font-weight-bold">Airing</span><br><span class="text-muted"> Episode ${media.nextAiringEpisode.episode}: ${toTS(media.nextAiringEpisode.timeUntilAiring)}</span>`
|
||||||
viewDetails.prepend(temp)
|
viewDetails.prepend(temp)
|
||||||
}
|
}
|
||||||
viewSeason.innerHTML = `${(media.season ? media.season.toLowerCase() + " " : "") + (media.seasonYear ? media.seasonYear : "")}`
|
viewSeason.innerHTML = `${(media.season ? media.season.toLowerCase() + " " : "") + (media.seasonYear ? media.seasonYear : "")}`
|
||||||
viewMediaInfo.innerHTML = `${media.format ? "<span>" + media.format + "</span>" : ""}${media.episodes ? "<span>" + media.episodes + " Episodes</span>" : ""}${media.duration ? "<span>" + media.duration + " Minutes</span>" : ""}`
|
viewMediaInfo.innerHTML = `${media.format ? "<span>" + media.format + "</span>" : ""}${media.episodes ? "<span>" + media.episodes + " Episodes</span>" : ""}${media.duration ? "<span>" + media.duration + " Minutes</span>" : ""}`
|
||||||
viewPlay.onclick = () => { nyaaSearch(media, 1); halfmoon.toggleModal("view") }
|
viewPlay.onclick = () => { nyaaSearch(media, 1); halfmoon.toggleModal("view") }
|
||||||
if (media.trailer) {
|
if (media.trailer) {
|
||||||
viewTrailer.removeAttribute("disabled", "")
|
viewTrailer.removeAttribute("disabled", "")
|
||||||
viewTrailer.onclick = () =>
|
viewTrailer.onclick = () =>
|
||||||
trailerPopup(media.trailer)
|
trailerPopup(media.trailer)
|
||||||
} else {
|
} else {
|
||||||
viewTrailer.setAttribute("disabled", "")
|
viewTrailer.setAttribute("disabled", "")
|
||||||
}
|
}
|
||||||
if (media.status == "NOT_YET_RELEASED") {
|
if (media.status == "NOT_YET_RELEASED") {
|
||||||
viewPlay.setAttribute("disabled", "")
|
viewPlay.setAttribute("disabled", "")
|
||||||
} else {
|
} else {
|
||||||
viewPlay.removeAttribute("disabled", "")
|
viewPlay.removeAttribute("disabled", "")
|
||||||
}
|
}
|
||||||
viewEpisodes.onclick = () => {
|
viewEpisodes.onclick = () => {
|
||||||
viewEpisodesWrapper.classList.toggle("hidden")
|
viewEpisodesWrapper.classList.toggle("hidden")
|
||||||
}
|
}
|
||||||
viewSynonym.onclick = () => {
|
viewSynonym.onclick = () => {
|
||||||
store[viewSynonymText.value] = media
|
store[viewSynonymText.value] = media
|
||||||
viewSynonymText.value = ""
|
viewSynonymText.value = ""
|
||||||
localStorage.setItem("store", JSON.stringify(store))
|
localStorage.setItem("store", JSON.stringify(store))
|
||||||
}
|
}
|
||||||
episodes.innerHTML = ""
|
episodes.innerHTML = ""
|
||||||
if (media.streamingEpisodes.length) {
|
if (media.streamingEpisodes.length) {
|
||||||
viewEpisodesWrapper.classList.add("hidden")
|
viewEpisodesWrapper.classList.add("hidden")
|
||||||
viewEpisodes.removeAttribute("disabled", "")
|
viewEpisodes.removeAttribute("disabled", "")
|
||||||
let frag = document.createDocumentFragment()
|
let frag = document.createDocumentFragment()
|
||||||
media.streamingEpisodes.forEach(episode => {
|
media.streamingEpisodes.forEach(episode => {
|
||||||
let temp = document.createElement("div")
|
let temp = document.createElement("div")
|
||||||
temp.classList.add("position-relative", "w-250", "rounded", "mr-10", "overflow-hidden", "pointer")
|
temp.classList.add("position-relative", "w-250", "rounded", "mr-10", "overflow-hidden", "pointer")
|
||||||
temp.innerHTML = `
|
temp.innerHTML = `
|
||||||
<img src="${episode.thumbnail}" class="w-full h-full">
|
<img src="${episode.thumbnail}" class="w-full h-full">
|
||||||
<div class="position-absolute ep-title w-full p-10 text-truncate bottom-0">${episode.title}</div>`
|
<div class="position-absolute ep-title w-full p-10 text-truncate bottom-0">${episode.title}</div>`
|
||||||
temp.onclick = () => { nyaaSearch(media, episodeRx.exec(episode.title)[1]); halfmoon.toggleModal("view") }
|
temp.onclick = () => { nyaaSearch(media, episodeRx.exec(episode.title)[1]); halfmoon.toggleModal("view") }
|
||||||
frag.appendChild(temp)
|
frag.appendChild(temp)
|
||||||
})
|
})
|
||||||
episodes.appendChild(frag)
|
episodes.appendChild(frag)
|
||||||
} else {
|
} else {
|
||||||
viewEpisodesWrapper.classList.add("hidden")
|
viewEpisodesWrapper.classList.add("hidden")
|
||||||
viewEpisodes.setAttribute("disabled", "")
|
viewEpisodes.setAttribute("disabled", "")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
function trailerPopup(trailer) {
|
|
||||||
trailerVideo.src = ""
|
|
||||||
halfmoon.toggleModal("trailer")
|
|
||||||
switch (trailer.site) { // should support the other possible sites too, but i cant find any examples
|
|
||||||
case "youtube":
|
|
||||||
trailerVideo.src = "https://www.youtube.com/embed/" + trailer.id
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
function trailerPopup(trailer) {
|
||||||
|
trailerVideo.src = ""
|
||||||
|
halfmoon.toggleModal("trailer")
|
||||||
|
switch (trailer.site) { // should support the other possible sites too, but i cant find any examples
|
||||||
|
case "youtube":
|
||||||
|
trailerVideo.src = "https://www.youtube.com/embed/" + trailer.id
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
function detailsCreator(entry) {
|
function detailsCreator(entry) {
|
||||||
if (entry) {
|
if (entry) {
|
||||||
Object.entries(entry).forEach(value => {
|
Object.entries(entry).forEach(value => {
|
||||||
let template = document.createElement("p")
|
let template = document.createElement("p")
|
||||||
if (typeof value[1] == 'object') {
|
if (typeof value[1] == 'object') {
|
||||||
if (Array.isArray(value[1])) {
|
if (Array.isArray(value[1])) {
|
||||||
if (details[value[0]] && value[1].length > 0) {
|
if (details[value[0]] && value[1].length > 0) {
|
||||||
template.innerHTML = `<span class="font-weight-bold">${details[value[0]]}</span><br><span class="text-muted">${value[1].map(key => (key)).join(', ')}</span>`
|
template.innerHTML = `<span class="font-weight-bold">${details[value[0]]}</span><br><span class="text-muted">${value[1].map(key => (key)).join(', ')}</span>`
|
||||||
detailsfrag.appendChild(template)
|
detailsfrag.appendChild(template)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
detailsCreator(value[1])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
detailsCreator(value[1])
|
if (details[value[0]]) {
|
||||||
|
template.innerHTML = `<span class="font-weight-bold">${details[value[0]]}</span><br><span class="text-muted">${value[1].toString()}</span>`
|
||||||
|
detailsfrag.appendChild(template)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
})
|
||||||
if (details[value[0]]) {
|
}
|
||||||
template.innerHTML = `<span class="font-weight-bold">${details[value[0]]}</span><br><span class="text-muted">${value[1].toString()}</span>`
|
|
||||||
detailsfrag.appendChild(template)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
function cardCreator(media, regexParse) {
|
||||||
function cardCreator(media, regexParse) {
|
let template = document.createElement("div")
|
||||||
let template = document.createElement("div")
|
template.classList.add("card", "m-0", "p-0")
|
||||||
template.classList.add("card", "m-0", "p-0")
|
if (media) {
|
||||||
if (media) {
|
template.innerHTML = `
|
||||||
template.innerHTML = `
|
|
||||||
<div class="row h-full" style="--color:${media.coverImage.color || "#1890ff"};">
|
<div class="row h-full" style="--color:${media.coverImage.color || "#1890ff"};">
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
<img src="${media.coverImage.extraLarge || ""}"
|
<img src="${media.coverImage.extraLarge || ""}"
|
||||||
|
|
@ -388,8 +460,8 @@ function cardCreator(media, regexParse) {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
} else {
|
} else {
|
||||||
template.innerHTML = `
|
template.innerHTML = `
|
||||||
<div class="row h-full">
|
<div class="row h-full">
|
||||||
<div class="col-4 w-full bg-very-dark skeloader">
|
<div class="col-4 w-full bg-very-dark skeloader">
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -400,54 +472,54 @@ function cardCreator(media, regexParse) {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
|
}
|
||||||
|
return template
|
||||||
}
|
}
|
||||||
return template
|
let skeletonCard = cardCreator()
|
||||||
}
|
|
||||||
let skeletonCard = cardCreator()
|
|
||||||
|
|
||||||
const DOMPARSER = new DOMParser().parseFromString.bind(new DOMParser())
|
const DOMPARSER = new DOMParser().parseFromString.bind(new DOMParser())
|
||||||
|
|
||||||
async function nyaaSearch(media, episode) {
|
async function nyaaSearch(media, episode) {
|
||||||
if (parseInt(episode) < 10) {
|
if (parseInt(episode) < 10) {
|
||||||
episode = `0${episode}`
|
episode = `0${episode}`
|
||||||
}
|
}
|
||||||
if (media.status == "FINISHED") {
|
if (media.status == "FINISHED") {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
let table = document.querySelector("tbody.results")
|
||||||
|
let results = await nyaaRss(media, episode)
|
||||||
|
|
||||||
|
if (results.children.length == 0) {
|
||||||
|
halfmoon.initStickyAlert({
|
||||||
|
content: `Couldn't find torrent for ${media.title.userPreferred} Episode ${parseInt(episode)}! Try specifying a torrent manually.`,
|
||||||
|
title: "Search Failed",
|
||||||
|
alertType: "alert-danger",
|
||||||
|
fillType: ""
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
table.textContent = ""
|
||||||
|
table.appendChild(results)
|
||||||
|
halfmoon.toggleModal("tsearch")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let table = document.querySelector("tbody.results")
|
async function nyaaRss(media, episode) {
|
||||||
let results = await nyaaRss(media, episode)
|
let frag = document.createDocumentFragment(),
|
||||||
|
ep = (media.status == "FINISHED" && settings.torrent9) ? `"01-${media.episodes}"|"01~${media.episodes}"|"batch"|"Batch"|"complete"|"Complete"` : `"+${episode}+"`,
|
||||||
if (results.children.length == 0) {
|
url = new URL(`https://miru.kirdow.com/request/?url=https://nyaa.si/?page=rss$c=1_2$f=${settings.torrent3 == true ? 2 : 0}$s=seeders$o=desc$q="${Object.values(media.title).concat(media.synonyms).filter(name => name != null).join("\"|\"")}"${ep}"${settings.torrent1}"`)
|
||||||
halfmoon.initStickyAlert({
|
res = await fetch(url)
|
||||||
content: `Couldn't find torrent for ${media.title.userPreferred} Episode ${parseInt(episode)}! Try specifying a torrent manually.`,
|
await res.text().then((xmlTxt) => {
|
||||||
title: "Search Failed",
|
try {
|
||||||
alertType: "alert-danger",
|
let doc = DOMPARSER(xmlTxt, "text/xml")
|
||||||
fillType: ""
|
if (settings.torrent2 && doc.querySelectorAll("infoHash")[0]) {
|
||||||
})
|
addTorrent(doc.querySelectorAll("infoHash")[0].textContent, media, episode)
|
||||||
} else {
|
halfmoon.toggleModal("tsearch")
|
||||||
table.textContent = ""
|
}
|
||||||
table.appendChild(results)
|
doc.querySelectorAll("item").forEach((item, index) => {
|
||||||
halfmoon.toggleModal("tsearch")
|
let i = item.querySelector.bind(item)
|
||||||
}
|
let template = document.createElement("tr")
|
||||||
}
|
template.innerHTML += `
|
||||||
|
|
||||||
async function nyaaRss(media, episode) {
|
|
||||||
let frag = document.createDocumentFragment(),
|
|
||||||
ep = (media.status == "FINISHED" && settings.torrent9) ? `"01-${media.episodes}"|"01~${media.episodes}"|"batch"|"Batch"|"complete"|"Complete"` : `"+${episode}+"`,
|
|
||||||
url = new URL(`https://miru.kirdow.com/request/?url=https://nyaa.si/?page=rss$c=1_2$f=${settings.torrent3 == true ? 2 : 0}$s=seeders$o=desc$q="${Object.values(media.title).concat(media.synonyms).filter(name => name != null).join("\"|\"")}"${ep}"${settings.torrent1}"`)
|
|
||||||
res = await fetch(url)
|
|
||||||
await res.text().then((xmlTxt) => {
|
|
||||||
try {
|
|
||||||
let doc = DOMPARSER(xmlTxt, "text/xml")
|
|
||||||
if (settings.torrent2 && doc.querySelectorAll("infoHash")[0]) {
|
|
||||||
addTorrent(doc.querySelectorAll("infoHash")[0].textContent, media, episode)
|
|
||||||
halfmoon.toggleModal("tsearch")
|
|
||||||
}
|
|
||||||
doc.querySelectorAll("item").forEach((item, index) => {
|
|
||||||
let i = item.querySelector.bind(item)
|
|
||||||
let template = document.createElement("tr")
|
|
||||||
template.innerHTML += `
|
|
||||||
<th>${(index + 1)}</th>
|
<th>${(index + 1)}</th>
|
||||||
<td>${i("title").textContent}</td>
|
<td>${i("title").textContent}</td>
|
||||||
<td>${i("size").textContent}</td>
|
<td>${i("size").textContent}</td>
|
||||||
|
|
@ -455,86 +527,86 @@ async function nyaaRss(media, episode) {
|
||||||
<td>${i("leechers").textContent}</td>
|
<td>${i("leechers").textContent}</td>
|
||||||
<td>${i("downloads").textContent}</td>
|
<td>${i("downloads").textContent}</td>
|
||||||
<td class="pointer">Play</td>`
|
<td class="pointer">Play</td>`
|
||||||
template.onclick = () => { addTorrent(i('infoHash').textContent, media, episode) }
|
template.onclick = () => { addTorrent(i('infoHash').textContent, media, episode) }
|
||||||
frag.appendChild(template)
|
|
||||||
})
|
|
||||||
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return frag
|
|
||||||
}
|
|
||||||
async function resolveName(name, method) {
|
|
||||||
if (!store.hasOwnProperty(name) && !alResponse.data.Page.media.some(media => (Object.values(media.title).concat(media.synonyms).filter(name => name != null).includes(name) && ((store[name] = media) && true)))) {
|
|
||||||
let res = await alRequest(name, method)
|
|
||||||
if (!res.data.Page.media[0]) {
|
|
||||||
res = await alRequest(name.replace(" (TV)", "").replace(` (${new Date().getFullYear()})`, ""), method)
|
|
||||||
}
|
|
||||||
if (settings.torrent7 && !res.data.Page.media[0] && method == "SearchReleasesSingle") {
|
|
||||||
res = await alRequest(name, "SearchAnySingle")
|
|
||||||
}
|
|
||||||
store[name] = res.data.Page.media[0]
|
|
||||||
}
|
|
||||||
return store[name]
|
|
||||||
}
|
|
||||||
|
|
||||||
const nameParseRegex = {
|
|
||||||
simple: /(\[.[^\]]*\]\ ?|\(.[^\)]*\)\ ?)?(.+?(?=\ \-\ \d{2,}|\ \–\ \d{2,}))?(\ \-\ |\ \–\ )?(\d{2,})?(.*)?/i,
|
|
||||||
fallback: /((?:\[[^\]]*\])*)?\s*((?:[^\d\[\.](?!S\d))*)?\s*((?:S\d+[^\w\[]*E?)?[\d\-]*)\s*(.*)?/i
|
|
||||||
}
|
|
||||||
let store = JSON.parse(localStorage.getItem("store")) || {},
|
|
||||||
lastResult
|
|
||||||
|
|
||||||
async function releasesRss() {
|
|
||||||
let frag = document.createDocumentFragment(),
|
|
||||||
releases = document.querySelector(".releases"),
|
|
||||||
url
|
|
||||||
if (Object.values(torrent4list.options).filter(item => item.value == settings.torrent4)[0]){
|
|
||||||
url = settings.torrent4 == "Erai-raws" ? new URL(Object.values(torrent4list.options).filter(item => item.value == settings.torrent4)[0].innerText + settings.torrent1 + "-magnet") : new URL(Object.values(torrent4list.options).filter(item => item.value == settings.torrent4)[0].innerText + settings.torrent1)
|
|
||||||
} else {
|
|
||||||
url = settings.torrent4 + settings.torrent1
|
|
||||||
}
|
|
||||||
let res = await fetch(url)
|
|
||||||
await res.text().then(async (xmlTxt) => {
|
|
||||||
try {
|
|
||||||
let doc = DOMPARSER(xmlTxt, "text/xml")
|
|
||||||
if (lastResult != doc) {
|
|
||||||
releases.textContent = '';
|
|
||||||
releases.appendChild(skeletonCard)
|
|
||||||
lastResult = doc
|
|
||||||
let items = doc.querySelectorAll("item")
|
|
||||||
for (let item of items) {
|
|
||||||
let i = item.querySelector.bind(item),
|
|
||||||
regexParse = nameParseRegex.simple.exec(i("title").textContent)
|
|
||||||
let media = await resolveName(regexParse[2], "SearchReleasesSingle"),
|
|
||||||
template = cardCreator(media, regexParse)
|
|
||||||
template.onclick = () => {
|
|
||||||
addTorrent(i('link').textContent, media, regexParse[4])
|
|
||||||
}
|
|
||||||
frag.appendChild(template)
|
frag.appendChild(template)
|
||||||
}
|
})
|
||||||
releases.textContent = '';
|
|
||||||
releases.appendChild(frag)
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
localStorage.setItem("store", JSON.stringify(store))
|
} catch (e) {
|
||||||
}
|
console.error(e)
|
||||||
clearRelCache.onclick = () => {
|
}
|
||||||
localStorage.removeItem("store")
|
})
|
||||||
store = {}
|
return frag
|
||||||
}
|
}
|
||||||
setInterval(() => {
|
async function resolveName(name, method) {
|
||||||
if (document.location.hash == "#releases") {
|
if (!store.hasOwnProperty(name) && !alResponse.data.Page.media.some(media => (Object.values(media.title).concat(media.synonyms).filter(name => name != null).includes(name) && ((store[name] = media) && true)))) {
|
||||||
|
let res = await alRequest(name, method)
|
||||||
|
if (!res.data.Page.media[0]) {
|
||||||
|
res = await alRequest(name.replace(" (TV)", "").replace(` (${new Date().getFullYear()})`, ""), method)
|
||||||
|
}
|
||||||
|
if (settings.torrent7 && !res.data.Page.media[0] && method == "SearchReleasesSingle") {
|
||||||
|
res = await alRequest(name, "SearchAnySingle")
|
||||||
|
}
|
||||||
|
store[name] = res.data.Page.media[0]
|
||||||
|
}
|
||||||
|
return store[name]
|
||||||
|
}
|
||||||
|
|
||||||
|
const nameParseRegex = {
|
||||||
|
simple: /(\[.[^\]]*\]\ ?|\(.[^\)]*\)\ ?)?(.+?(?=\ \-\ \d{2,}|\ \–\ \d{2,}))?(\ \-\ |\ \–\ )?(\d{2,})?(.*)?/i,
|
||||||
|
fallback: /((?:\[[^\]]*\])*)?\s*((?:[^\d\[\.](?!S\d))*)?\s*((?:S\d+[^\w\[]*E?)?[\d\-]*)\s*(.*)?/i
|
||||||
|
}
|
||||||
|
let store = JSON.parse(localStorage.getItem("store")) || {},
|
||||||
|
lastResult
|
||||||
|
|
||||||
|
async function releasesRss() {
|
||||||
|
let frag = document.createDocumentFragment(),
|
||||||
|
releases = document.querySelector(".releases"),
|
||||||
|
url
|
||||||
|
if (Object.values(torrent4list.options).filter(item => item.value == settings.torrent4)[0]) {
|
||||||
|
url = settings.torrent4 == "Erai-raws" ? new URL(Object.values(torrent4list.options).filter(item => item.value == settings.torrent4)[0].innerText + settings.torrent1 + "-magnet") : new URL(Object.values(torrent4list.options).filter(item => item.value == settings.torrent4)[0].innerText + settings.torrent1)
|
||||||
|
} else {
|
||||||
|
url = settings.torrent4 + settings.torrent1
|
||||||
|
}
|
||||||
|
let res = await fetch(url)
|
||||||
|
await res.text().then(async (xmlTxt) => {
|
||||||
|
try {
|
||||||
|
let doc = DOMPARSER(xmlTxt, "text/xml")
|
||||||
|
if (lastResult != doc) {
|
||||||
|
releases.textContent = '';
|
||||||
|
releases.appendChild(skeletonCard)
|
||||||
|
lastResult = doc
|
||||||
|
let items = doc.querySelectorAll("item")
|
||||||
|
for (let item of items) {
|
||||||
|
let i = item.querySelector.bind(item),
|
||||||
|
regexParse = nameParseRegex.simple.exec(i("title").textContent)
|
||||||
|
let media = await resolveName(regexParse[2], "SearchReleasesSingle"),
|
||||||
|
template = cardCreator(media, regexParse)
|
||||||
|
template.onclick = () => {
|
||||||
|
addTorrent(i('link').textContent, media, regexParse[4])
|
||||||
|
}
|
||||||
|
frag.appendChild(template)
|
||||||
|
}
|
||||||
|
releases.textContent = '';
|
||||||
|
releases.appendChild(frag)
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
localStorage.setItem("store", JSON.stringify(store))
|
||||||
|
}
|
||||||
|
clearRelCache.onclick = () => {
|
||||||
|
localStorage.removeItem("store")
|
||||||
|
store = {}
|
||||||
|
}
|
||||||
|
setInterval(() => {
|
||||||
|
if (document.location.hash == "#releases") {
|
||||||
|
releasesRss()
|
||||||
|
}
|
||||||
|
}, 30000);
|
||||||
|
async function loadAnime() {
|
||||||
|
await searchAnime()
|
||||||
releasesRss()
|
releasesRss()
|
||||||
}
|
}
|
||||||
}, 30000);
|
loadAnime()
|
||||||
async function loadAnime() {
|
|
||||||
await searchAnime()
|
|
||||||
releasesRss()
|
|
||||||
}
|
|
||||||
loadAnime()
|
|
||||||
|
|
@ -122,14 +122,14 @@ async function buildVideo(file, nowPlaying) {
|
||||||
setTimeout(onProgress, 100)
|
setTimeout(onProgress, 100)
|
||||||
}
|
}
|
||||||
setTimeout(onProgress, 100)
|
setTimeout(onProgress, 100)
|
||||||
if (nowPlaying) {
|
if (nowPlaying && nowPlaying[0]) {
|
||||||
playerData.nowPlaying = nowPlaying
|
playerData.nowPlaying = nowPlaying
|
||||||
} else if (settings.torrent7) {
|
} else if (settings.torrent7) {
|
||||||
let regexParse = nameParseRegex.simple.exec(file.name)
|
let regexParse = nameParseRegex.simple.exec(file.name)
|
||||||
playerData.nowPlaying = [await resolveName(regexParse[2], "SearchAnySingle"), regexParse[4]]
|
playerData.nowPlaying = [await resolveName(regexParse[2], "SearchAnySingle"), regexParse[4]]
|
||||||
console.log(regexParse)
|
console.log(regexParse)
|
||||||
}
|
}
|
||||||
if (playerData.nowPlaying && playerData.nowPlaying[0] && parseInt(playerData.nowPlaying[1]) >= playerData.nowPlaying[0].episodes) {
|
if (playerData.nowPlaying && playerData.nowPlaying[0] && playerData.nowPlaying[0].episodes && parseInt(playerData.nowPlaying[1]) >= playerData.nowPlaying[0].episodes) {
|
||||||
bnext.setAttribute("disabled", "")
|
bnext.setAttribute("disabled", "")
|
||||||
} else {
|
} else {
|
||||||
bnext.removeAttribute("disabled")
|
bnext.removeAttribute("disabled")
|
||||||
|
|
@ -669,16 +669,16 @@ if ('mediaSession' in navigator) {
|
||||||
//AL entry auto add
|
//AL entry auto add
|
||||||
function checkCompletion() {
|
function checkCompletion() {
|
||||||
if (!playerData.watched && typeof video !== 'undefined' && video.duration - 180 < video.currentTime && playerData.nowPlaying && playerData.nowPlaying[0]) {
|
if (!playerData.watched && typeof video !== 'undefined' && video.duration - 180 < video.currentTime && playerData.nowPlaying && playerData.nowPlaying[0]) {
|
||||||
if(settings.other2){
|
if (settings.other2) {
|
||||||
alEntry()
|
alEntry()
|
||||||
} else{
|
} else {
|
||||||
halfmoon.initStickyAlert({
|
halfmoon.initStickyAlert({
|
||||||
content: `Do You Want To Mark <br><b>${playerData.nowPlaying[0].title.userPreferred}</b><br>Episode ${playerData.nowPlaying[1]} As Completed?<br>
|
content: `Do You Want To Mark <br><b>${playerData.nowPlaying[0].title.userPreferred}</b><br>Episode ${playerData.nowPlaying[1]} As Completed?<br>
|
||||||
<button class="btn btn-sm btn-square btn-success mt-5" onclick="alEntry()" data-dismiss="alert" type="button" aria-label="Close">✓</button>
|
<button class="btn btn-sm btn-square btn-success mt-5" onclick="alEntry()" data-dismiss="alert" type="button" aria-label="Close">✓</button>
|
||||||
<button class="btn btn-sm btn-square mt-5" data-dismiss="alert" type="button" aria-label="Close"><span aria-hidden="true">X</span></button>`,
|
<button class="btn btn-sm btn-square mt-5" data-dismiss="alert" type="button" aria-label="Close"><span aria-hidden="true">X</span></button>`,
|
||||||
title: "Episode Complete",
|
title: "Episode Complete",
|
||||||
timeShown: 180000
|
timeShown: 180000
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
playerData.watched = true
|
playerData.watched = true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,13 +56,45 @@ const announceList = [
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const torrentRx = /(magnet:)?([A-F\d]{8,40})?(.*\.torrent)?/i;
|
const torrentRx = /(magnet:)?([A-F\d]{8,40})?(.*\.torrent)?/i;
|
||||||
window.addEventListener("paste", async (e) => {
|
window.addEventListener("paste", async e => {
|
||||||
let content = await navigator.clipboard.readText(),
|
let item = e.clipboardData.items[0];
|
||||||
regexParse = torrentRx.exec(content)
|
console.log(item)
|
||||||
if (regexParse[1] || regexParse[2] || regexParse[3]) {
|
|
||||||
|
if (item && item.type.indexOf("image") === 0) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
addTorrent(content);
|
let blob = item.getAsFile();
|
||||||
|
|
||||||
|
let reader = new FileReader();
|
||||||
|
reader.onload = e => {
|
||||||
|
console.log(e.target.result);
|
||||||
|
fetch("https://trace.moe/api/search", {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({ image: e.target.result }),
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
})
|
||||||
|
.then((res) => res.json())
|
||||||
|
.then(async (result) => {
|
||||||
|
if (result.docs[0].similarity >= 0.85) {
|
||||||
|
console.log(result.docs[0].anilist_id)
|
||||||
|
let res = await alRequest(result.docs[0].anilist_id, "SearchIDSingle")
|
||||||
|
viewAnime(res.data.Media)
|
||||||
|
} else{
|
||||||
|
console.log("no." + result.docs[0].similarity)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
reader.readAsDataURL(blob);
|
||||||
|
} else if (item && item.type.indexOf("text") === 0) {
|
||||||
|
item.getAsString(text => {
|
||||||
|
console.log(text)
|
||||||
|
let regexParse = torrentRx.exec(text)
|
||||||
|
if (regexParse[1] || regexParse[2] || regexParse[3]) {
|
||||||
|
e.preventDefault();
|
||||||
|
addTorrent(text);
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
//for debugging
|
//for debugging
|
||||||
function t(a) {
|
function t(a) {
|
||||||
|
|
@ -128,12 +160,11 @@ async function addTorrent(magnet, media, episode) {
|
||||||
bpl.setAttribute("disabled", "")
|
bpl.setAttribute("disabled", "")
|
||||||
videofile = videoFiles[0]
|
videofile = videoFiles[0]
|
||||||
}
|
}
|
||||||
console.log(videoFile)
|
|
||||||
if (media && episode) {
|
if (media && episode) {
|
||||||
buildVideo(videoFile[0]||videoFiles[0], [media, episode])
|
videoFile ? buildVideo(videoFile[0], [media, episode]) : buildVideo(videoFiles[0], [media, episode])
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
buildVideo(videoFile[0])
|
videoFile ? buildVideo(videoFile[0], [media, episode]) : buildVideo(videoFiles[0], [media, episode])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
halfmoon.initStickyAlert({
|
halfmoon.initStickyAlert({
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue