code dump
This commit is contained in:
parent
445c5c35be
commit
a4150f41ce
26
autoindex.js
26
autoindex.js
@ -45,7 +45,7 @@ function deduplicateJointEpisode(textContent) {
|
|||||||
result.push(line);
|
result.push(line);
|
||||||
}
|
}
|
||||||
resolve(result.join('\n'));
|
resolve(result.join('\n'));
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const parser = new window.DOMParser();
|
const parser = new window.DOMParser();
|
||||||
@ -76,6 +76,7 @@ function createOrImproveMovieMeta(original, thumbnail, nfo) {
|
|||||||
original.classList.add('movie');
|
original.classList.add('movie');
|
||||||
original.innerHTML = imgTag + '<div class="meta-wrap">' + movieTitle + movieDescription + '</div>';
|
original.innerHTML = imgTag + '<div class="meta-wrap">' + movieTitle + movieDescription + '</div>';
|
||||||
original.parentElement.classList.add('enhanced');
|
original.parentElement.classList.add('enhanced');
|
||||||
|
// quick innerHTML hack to create elements here lol
|
||||||
imgTag = original.querySelector('.thumbnail');
|
imgTag = original.querySelector('.thumbnail');
|
||||||
movieTitle = original.querySelector('.movie-title');
|
movieTitle = original.querySelector('.movie-title');
|
||||||
movieDescription = original.querySelector('.movie-description');
|
movieDescription = original.querySelector('.movie-description');
|
||||||
@ -91,15 +92,16 @@ function createOrImproveMovieMeta(original, thumbnail, nfo) {
|
|||||||
const titleEl = content.querySelector('title');
|
const titleEl = content.querySelector('title');
|
||||||
const plotEl = content.querySelector('plot');
|
const plotEl = content.querySelector('plot');
|
||||||
const airedEl = content.querySelector('aired');
|
const airedEl = content.querySelector('aired');
|
||||||
|
const premieredEl = content.querySelector('premiered');
|
||||||
|
|
||||||
if (!titleEl || !plotEl) {
|
if (!titleEl || !plotEl) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (airedEl) {
|
if (airedEl || premieredEl) {
|
||||||
const timestamp = original.parentElement.parentElement.querySelector('.timestamp');
|
const timestamp = original.parentElement.parentElement.querySelector('.timestamp');
|
||||||
if (timestamp) {
|
if (timestamp) {
|
||||||
timestamp.innerText = airedEl.textContent;
|
timestamp.innerText = (airedEl || premieredEl).textContent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +119,6 @@ function createOrImproveMovieMeta(original, thumbnail, nfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let tvShow;
|
let tvShow;
|
||||||
|
|
||||||
function accountForMetadata() {
|
function accountForMetadata() {
|
||||||
allLinks.forEach((link) => {
|
allLinks.forEach((link) => {
|
||||||
const url = link.getAttribute('href');
|
const url = link.getAttribute('href');
|
||||||
@ -125,8 +126,8 @@ function accountForMetadata() {
|
|||||||
link.parentElement.parentElement.style.display = 'none';
|
link.parentElement.parentElement.style.display = 'none';
|
||||||
let findOriginal
|
let findOriginal
|
||||||
if (url === 'tvshow.nfo' || url === 'poster.jpg') {
|
if (url === 'tvshow.nfo' || url === 'poster.jpg') {
|
||||||
// dirty hack
|
const isTVShow = allLinks.find((found) => found.getAttribute('href') === 'tvshow.nfo');
|
||||||
if (url === 'poster.jpg' && window.location.pathname.includes('/movies/')) {
|
if (url === 'poster.jpg' && !isTVShow) {
|
||||||
findOriginal = document.querySelector('a:not([href=".."])');
|
findOriginal = document.querySelector('a:not([href=".."])');
|
||||||
} else {
|
} else {
|
||||||
if (tvShow) {
|
if (tvShow) {
|
||||||
@ -145,13 +146,13 @@ function accountForMetadata() {
|
|||||||
const sn = url.match(/season(\d+)/);
|
const sn = url.match(/season(\d+)/);
|
||||||
if (sn) {
|
if (sn) {
|
||||||
const number = parseInt(sn[1], 10);
|
const number = parseInt(sn[1], 10);
|
||||||
const findByNumber = allLinks.filter((url) => url.innerText.includes(number));
|
const findByNumber = allLinks.find((allurl) => allurl.innerText.includes(number));
|
||||||
if (findByNumber.length) {
|
if (findByNumber) {
|
||||||
findOriginal = findByNumber[0];
|
findOriginal = findByNumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
findOriginal = findByInfoFile(encodeURIComponent(decodeURIComponent(url)));
|
findOriginal = findByInfoFile(url);
|
||||||
}
|
}
|
||||||
if (findOriginal) {
|
if (findOriginal) {
|
||||||
createOrImproveMovieMeta(findOriginal,
|
createOrImproveMovieMeta(findOriginal,
|
||||||
@ -200,8 +201,3 @@ if ('localStorage' in window) {
|
|||||||
} else {
|
} else {
|
||||||
accountForMetadata();
|
accountForMetadata();
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
const loc = 'Index of ' + decodeURIComponent(document.location.pathname);
|
|
||||||
document.getElementById('dirname').innerHTML = loc;
|
|
||||||
document.title = loc;
|
|
||||||
*/
|
|
||||||
|
Loading…
Reference in New Issue
Block a user