Skip to content

Commit

Permalink
Add 'PREFER_MP4' setting to Philomena model (issue #2680)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bionus committed May 6, 2022
1 parent 2280983 commit 8af5b6c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/sites/Philomena/model.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const PREFER_MP4 = false;

function completeImage(img: IImage & { json_uris: string }): IImage {
if (img.json_uris) {
const uris = JSON.parse(img.json_uris.replace(/"/g, '"'));
Expand All @@ -9,6 +11,9 @@ function completeImage(img: IImage & { json_uris: string }): IImage {
}
if ("full" in uris && uris["full"].length > 5) {
img.file_url = uris["full"];
if (PREFER_MP4) {
img.file_url = img.file_url!.replace(".webm", ".mp4");
}
}
}

Expand Down Expand Up @@ -153,9 +158,14 @@ export const source: ISource = {
data = data["image"];
}

let imageUrl = data["representations"]["full"];
if (PREFER_MP4) {
imageUrl = imageUrl.replace(".webm", ".mp4");
};

return {
createdAt: data["created_at"],
imageUrl: data["representations"]["full"],
imageUrl,
tags: makeTags(data["tags"], data["tag_ids"]),
};
},
Expand Down

0 comments on commit 8af5b6c

Please sign in to comment.