Fixed media module trying to fetch invalid source URLs. Added Accidental Gangbang to Adult Time.

This commit is contained in:
DebaucheryLibrarian
2022-09-27 20:09:46 +02:00
parent 3db8b80164
commit 0fc37e46d2
29 changed files with 4857 additions and 2451 deletions

View File

@@ -96,15 +96,39 @@ function itemsByKey(items, key) {
return items.reduce((acc, item) => ({ ...acc, [item[key]]: item }), {});
}
function isValidUrl(url) {
try {
const urlObject = new URL(url);
return !!urlObject;
} catch (error) {
return false;
}
}
function toBaseSource(rawSource) {
if (rawSource && (rawSource.src || (rawSource.extract && rawSource.url) || rawSource.stream)) {
const baseSource = {};
if (rawSource.src) baseSource.src = rawSource.src;
if (rawSource.src) {
if (!isValidUrl(rawSource.src)) {
return null;
}
baseSource.src = rawSource.src;
}
if (rawSource.quality) baseSource.quality = rawSource.quality;
if (rawSource.type) baseSource.type = rawSource.type;
if (rawSource.url) baseSource.url = rawSource.url;
if (rawSource.url) {
if (!isValidUrl(rawSource.url)) {
return null;
}
baseSource.url = rawSource.url;
}
if (rawSource.extract) baseSource.extract = rawSource.extract;
if (rawSource.expectType) baseSource.expectType = rawSource.expectType;
@@ -135,6 +159,10 @@ function toBaseSource(rawSource) {
}
if (typeof rawSource === 'string') {
if (!isValidUrl(rawSource)) {
return null;
}
return {
src: rawSource,
};