Compare commits

..

No commits in common. "a6a43082760963c2c580bb366aed94116c621118" and "568660c6a99f32cb6dfd8b6569b65ca5f7f77f5f" have entirely different histories.

1 changed files with 11 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import {
interface Attachment { interface Attachment {
url: string; // original media URL, ?sensitive=true stripped url: string; // original media URL, ?sensitive=true stripped
previewUrl?: string; // poster / cached preview (for video posters)
contentType: ContentType; contentType: ContentType;
} }
@ -65,6 +66,10 @@ export default class Mastodon extends ScrapeEngineBase {
post.contentType = att.contentType; post.contentType = att.contentType;
post.referrer = document.location.origin; post.referrer = document.location.origin;
if (att.contentType === "video" && att.previewUrl) {
post.extraContentUrl = att.previewUrl;
}
result.tryAddPost(post); result.tryAddPost(post);
} }
@ -99,12 +104,14 @@ export default class Mastodon extends ScrapeEngineBase {
if (!rawHref) continue; if (!rawHref) continue;
const img = a.querySelector("img"); const img = a.querySelector("img");
const preview = img?.currentSrc || img?.src;
const url = this.normalizeUrl(rawHref) || this.largestFromSrcset(img); const url = this.normalizeUrl(rawHref) || this.largestFromSrcset(img);
if (!url) continue; if (!url) continue;
add({ add({
url, url,
previewUrl: preview && preview !== url ? preview : undefined,
contentType: this.contentTypeFor(url), contentType: this.contentTypeFor(url),
}); });
} }
@ -118,8 +125,12 @@ export default class Mastodon extends ScrapeEngineBase {
const url = this.normalizeUrl(rawSrc); const url = this.normalizeUrl(rawSrc);
if (!url) continue; if (!url) continue;
// Use the poster as a thumbnail when available.
const poster = v.getAttribute("poster") || undefined;
add({ add({
url, url,
previewUrl: poster && poster !== url ? poster : undefined,
contentType: "video", contentType: "video",
}); });
} }