mirror of
https://github.com/ThaUnknown/miru.git
synced 2026-08-16 18:15:40 +00:00
name resolving cleanup, improvement and finishing
This commit is contained in:
parent
d57d9b1788
commit
3a4b24d8d2
6 changed files with 12 additions and 33 deletions
|
|
@ -727,11 +727,6 @@
|
|||
<input type="checkbox" id="torrent5">
|
||||
<label for="torrent5">Drive Caching</label>
|
||||
</div>
|
||||
<div class="custom-switch mb-10" data-toggle="tooltip" data-placement="top"
|
||||
data-title="Tries To Resolve Anime Names From Manually Added Torrent Names, Might Lead To Wrong Anime Being Detected">
|
||||
<input type="checkbox" id="torrent7" checked>
|
||||
<label for="torrent7">Resolve Names</label>
|
||||
</div>
|
||||
<div class="custom-switch mb-20" data-toggle="tooltip" data-placement="top"
|
||||
data-title="Tries To Find Batches For Finished Shows Instead Of Downloading 1 Episode At A Time">
|
||||
<input type="checkbox" id="torrent9">
|
||||
|
|
@ -776,7 +771,7 @@
|
|||
<script src="https://cdn.jsdelivr.net/gh/halfmoonui/halfmoon@1.1.1/js/halfmoon.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/webtorrent@latest/webtorrent.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/matroska-subtitles@latest/dist/matroska-subtitles.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/indexeddb-chunk-store@2.2.1/idbchunkstore.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/indexeddb-chunk-store@latest/idbchunkstore.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/anitomyscript@2.0.4/dist/anitomyscript.bundle.min.js"></script>
|
||||
<script src="js/settingsHandler.js"></script>
|
||||
<script src="js/rangeParser.js"></script>
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ async function alRequest(opts) {
|
|||
let query,
|
||||
variables = {
|
||||
type: "ANIME",
|
||||
sort: "TRENDING_DESC",
|
||||
sort: opts.sort || "TRENDING_DESC",
|
||||
page: opts.page || 1,
|
||||
perPage: opts.perPage || 30,
|
||||
status_in: opts.status_in || "[CURRENT,PLANNING]",
|
||||
|
|
@ -539,22 +539,7 @@ async function nyaaRss(media, episode) {
|
|||
})
|
||||
return frag
|
||||
}
|
||||
//resolve anime name based on torrent name and store it
|
||||
async function resolveName(name, method, release) {
|
||||
if (!store.hasOwnProperty(name) && !(alResponse && !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({ perPage: 1, name: name, method: method })
|
||||
if (!res.data.Page.media[0]) {
|
||||
res = await alRequest({ name: name.replace(" (TV)", "").replace(` (${new Date().getFullYear()})`, "").replace("-", ""), method: method, perPage: 1 })
|
||||
console.log(name.replace(" (TV)", "").replace(` (${new Date().getFullYear()})`, "").replace("-", ""))
|
||||
}
|
||||
console.log(res)
|
||||
if (settings.torrent7 && !res.data.Page.media[0] && release) {
|
||||
res = await alRequest({ name: name, method: "SearchName", perPage: 1, status: "RELEASING" })
|
||||
}
|
||||
store[name] = res.data.Page.media[0]
|
||||
}
|
||||
return store[name]
|
||||
}
|
||||
//resolve anime name based on file name and store it
|
||||
|
||||
async function resolveFileMedia(opts) {
|
||||
// opts.fileName opts.method opts.isRelease
|
||||
|
|
@ -570,14 +555,16 @@ async function resolveFileMedia(opts) {
|
|||
}
|
||||
res = await alRequest(method)
|
||||
if (!res.data.Page.media[0]) {
|
||||
method.name = method.name.replace(" (TV)", "").replace(` (${new Date().getFullYear()})`, "").replace("-", "") // this needs to be improved!!!
|
||||
method.name = method.name.replace(" (TV)", "").replace(` (${new Date().getFullYear()})`, "").replace("-", "").replace("S2","2") // this needs to be improved!!!
|
||||
method.status = undefined
|
||||
if (opts.isRelease) method.sort = "START_DATE_DESC"
|
||||
res = await alRequest(method)
|
||||
}
|
||||
if (res.data.Page.media[0]) store[elems.anime_title] = res.data.Page.media[0]
|
||||
}
|
||||
let episode, media = store[elems.anime_title]
|
||||
// resolve episode, if movie, dont.
|
||||
if (media && media.format != "MOVIE" && elems.episode_number) {
|
||||
if ((media?.format != "MOVIE" || media.episodes) && elems.episode_number) {
|
||||
async function resolveSeason(opts) {
|
||||
// opts.media, opts.episode, opts.increment, opts.offset
|
||||
let epMin, epMax
|
||||
|
|
|
|||
|
|
@ -649,9 +649,9 @@ if ('mediaSession' in navigator) {
|
|||
|
||||
//AL entry auto add
|
||||
function checkCompletion() {
|
||||
if (!playerData.watched && video.duration - 180 < video.currentTime && playerData.nowPlaying && playerData.nowPlaying[0]) {
|
||||
if (settings.other2) {
|
||||
if (parseInt(playerData.nowPlaying[1]) <= playerData.nowPlaying[0].episodes || !playerData.nowPlaying[0].episodes) alEntry()
|
||||
if (!playerData.watched && video.duration - 180 < video.currentTime && playerData.nowPlaying && playerData.nowPlaying[0].episodes) {
|
||||
if (settings.other2 && !(!playerData.nowPlaying[0].episodes && playerData.nowPlaying[0].streamingEpisodes.length)) {
|
||||
if (parseInt(playerData.nowPlaying[1]) <= playerData.nowPlaying[0].episodes) alEntry()
|
||||
} else {
|
||||
halfmoon.initStickyAlert({
|
||||
content: `Do You Want To Mark <br><b>${playerData.nowPlaying[0].title.userPreferred}</b><br>Episode ${playerData.nowPlaying[1]} As Completed?<br>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const settingsElements = [
|
||||
volume, player2, player3, player5, player6, player8, player10, subtitle1, subtitle3, torrent1, torrent2, torrent3, torrent4, torrent5, torrent6, torrent7, torrent9, other2
|
||||
volume, player2, player3, player5, player6, player8, player10, subtitle1, subtitle3, torrent1, torrent2, torrent3, torrent4, torrent5, torrent6, torrent9, other2
|
||||
]
|
||||
setRes.addEventListener("click", restoreDefaults)
|
||||
settingsTab.addEventListener("click", applySettingsTimeout)
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ function renderSubs(trackNumber) {
|
|||
lossyRender: true,
|
||||
fonts: playerData.fonts.length == 0 ? ["https://fonts.gstatic.com/s/roboto/v20/KFOlCnqEu92Fr1MmEU9fBBc4.woff2"] : playerData.fonts,
|
||||
workerUrl: 'js/subtitles-octopus-worker.js',
|
||||
debug: true,
|
||||
timeOffset: 0
|
||||
};
|
||||
playerData.octopusInstance = new SubtitlesOctopus(options);
|
||||
|
|
|
|||
|
|
@ -84,9 +84,7 @@ loadOfflineStorage()
|
|||
function cleanupTorrents() {
|
||||
client.torrents.filter(torrent => {
|
||||
return !offlineTorrents.has(torrent.infoHash) || torrent.progress != 1 // creates an array of all non-offline store torrents and removes them
|
||||
}).forEach(torrent => {
|
||||
torrent.destroy({ destroyStore: true })
|
||||
})
|
||||
}).forEach(torrent => torrent.destroy({ destroyStore: true }))
|
||||
}
|
||||
|
||||
// manually add trackers
|
||||
|
|
|
|||
Loading…
Reference in a new issue