tumblr: formatting

This commit is contained in:
wukko 2023-12-25 22:40:02 +06:00
parent 354fbdfa55
commit 0dcd36c16f

View file

@ -3,10 +3,12 @@ import { genericUserAgent } from "../../config.js";
export default async function(obj) { export default async function(obj) {
let { subdomain } = psl.parse(obj.url.hostname); let { subdomain } = psl.parse(obj.url.hostname);
if (subdomain?.includes('.'))
if (subdomain?.includes('.')) {
return { error: ['ErrorBrokenLink', 'tumblr'] } return { error: ['ErrorBrokenLink', 'tumblr'] }
else if (subdomain === 'www') } else if (subdomain === 'www') {
subdomain = undefined; subdomain = undefined
}
let html = await fetch(`https://${subdomain ?? obj.user}.tumblr.com/post/${obj.id}`, { let html = await fetch(`https://${subdomain ?? obj.user}.tumblr.com/post/${obj.id}`, {
headers: { "user-agent": genericUserAgent } headers: { "user-agent": genericUserAgent }
@ -29,5 +31,5 @@ export default async function(obj) {
} }
} else r = { error: 'ErrorEmptyDownload' }; } else r = { error: 'ErrorEmptyDownload' };
return r; return r
} }