Skip to content

Commit

Permalink
Merge pull request #1 from ibrahim-nazari/main
Browse files Browse the repository at this point in the history
 if onl image preview is not available skip that, and set ration as 1…
  • Loading branch information
ibrahim-nazari committed May 7, 2024
2 parents ebcf73f + 5de3f50 commit 66cdd8f
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,19 @@ app.post("/", async (req, res) => {
let newData = data;
const imagesource = data?.images[0] || null;
if (imagesource) {
let result = await probe(imagesource);
const ratio = Number((result.width / result.height).toFixed(2));
newData = {
...newData,
ratio,
};
try {
let result = await probe(imagesource);
const ratio = Number((result.width / result.height).toFixed(2));
newData = {
...newData,
ratio,
};
} catch (error) {
newData = {
...newData,
ratio: 1,
};
}
}
if (newData.mediaType == "video.other") {
const videoId = youtube_parser(url);
Expand Down

0 comments on commit 66cdd8f

Please sign in to comment.