sorted trackers, now playing media information, retardism fixes

This commit is contained in:
ThaUnknown 2020-09-03 01:08:24 +02:00
parent 12f6f94acb
commit 5bfc1c3f1b
3 changed files with 10 additions and 7 deletions

View file

@ -238,9 +238,10 @@ const DOMPARSER = new DOMParser().parseFromString.bind(new DOMParser()),
searchTitle = document.querySelector("#title"),
searchEpisode = document.querySelector("#ep")
var selected
async function nyaaSearch(media, episode) {
if (episode.length < 2) {
if (parseInt(episode) < 10) {
episode = `0${episode}`
}
let titles = Object.values(media.title).concat(media.synonyms).filter(name => name != null),
@ -254,7 +255,7 @@ async function nyaaSearch(media, episode) {
};
if (results.children.length == 0) {
halfmoon.initStickyAlert({
content: `Couldn't find torrent for ${!!media.title.english ? media.title.english : media.title.romaji}! Try specifying a torrent manually.`,
content: `Couldn't find torrent for ${!!media.title.english ? media.title.english : media.title.romaji} Episode ${parseInt(episode)}! Try specifying a torrent manually.`,
title: "Search Failed",
alertType: "alert-danger",
fillType: ""
@ -263,6 +264,7 @@ async function nyaaSearch(media, episode) {
table.textContent = ""
table.appendChild(results)
halfmoon.toggleModal("tsearch")
selected = [media,parseInt(episode)]
}
}

View file

@ -145,8 +145,7 @@ function bpp() {
}
function bnext() {
console.log("todo")
// TODO: get magnet link of next current next episode [using search]
nyaaSearch(nowPlaying[0], nowPlaying[1]+1)
}
//volume shit

View file

@ -2,9 +2,9 @@ const client = new WebTorrent(),
dummyTorrent = client.add('06d67cc41f44fd57241551b6d95c2d1de38121ae'),
torrentPrototype = Object.getPrototypeOf(dummyTorrent),
announceList = [
['wss://tracker.webtorrent.io'],
['wss://tracker.btorrent.xyz'],
['wss://tracker.openwebtorrent.com'],
['wss://tracker.btorrent.xyz'],
['wss://tracker.webtorrent.io'],
['wss://tracker.fastcast.nz'],
['wss://video.blender.org:443/tracker/socket'],
['wss://tube.privacytools.io:443/tracker/socket'],
@ -31,6 +31,7 @@ WEBTORRENT_ANNOUNCE = announceList
return url.indexOf('wss://') === 0 || url.indexOf('ws://') === 0
})
var nowPlaying
function addTorrent(magnet) {
if (client.torrents[0]) {
client.remove(client.torrents[0].infoHash)
@ -41,7 +42,7 @@ function addTorrent(magnet) {
torrent.on('download', onProgress)
torrent.on('upload', onProgress)
// torrent.on('warning', console.log) too spammy for now
// torrent.on('warning', console.log) // too spammy for now
// torrent.on('error', console.log)
torrent.on('done', function () {
setInterval(onProgress, 5000)
@ -76,6 +77,7 @@ function addTorrent(magnet) {
})
video.src = `/webtorrent/${torrent.infoHash}/${encodeURI(videoFile.path)}`
document.location.href = "#player"
nowPlaying = [selected[0], selected[1]]
halfmoon.toggleModal("tsearch")
})
}