Hexer10 / youtube_explode_dart

Dart library to interact with many Youtube APIs
https://pub.dev/packages/youtube_explode_dart
BSD 3-Clause "New" or "Revised" License
326 stars 143 forks source link

Fix VideoQuality.fromLabel to match higher resolutions first #254

Open jamiepiccolo opened 1 year ago

jamiepiccolo commented 1 year ago

VideoQuality.fromLabel would give incorrect qualities in some cases.

An example being the 1440p label where the method would assign VideoQuality.low144 because of a premature match of the string's prefix "144":

if (label.startsWith('144')) {
    return VideoQuality.low144;
}

...

if (label.startsWith('1440')) {
    return VideoQuality.high1440;
}

I simply reversed the resolution map and looped over it so that we start matching from the highest resolution first.