Fixed media module trying to fetch invalid source URLs. Added Accidental Gangbang to Adult Time.
This commit is contained in:
32
src/media.js
32
src/media.js
@@ -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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user