Skip to content

Commit

Permalink
Additional checks to handle bad video variants or videos with no vari…
Browse files Browse the repository at this point in the history
…ants avalible
  • Loading branch information
Inrixia committed Apr 18, 2023
1 parent 8da3642 commit a569956
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib/Video.ts
Expand Up @@ -246,7 +246,9 @@ export default class Video {
const downloadOrigin = this.getOrigin(delivery.origins);

// Sort qualities from highest to smallest
const availableVariants = delivery.variants.sort((a, b) => (b.order || 0) - (a.order || 0));
const availableVariants = delivery.variants.filter((variant) => variant.url !== "").sort((a, b) => (b.order || 0) - (a.order || 0));

if (availableVariants.length === 0) throw new Error("No variants available for download!");

// Set the quality to use based on whats given in the settings.json or the highest available
const downloadVariant = availableVariants.find((variant) => variant.label.includes(quality)) ?? availableVariants[0];
Expand Down

0 comments on commit a569956

Please sign in to comment.