export const runtime = 'nodejs'

import { execFile } from 'child_process';
import { promisify } from 'util';


export function pickBestPlayAddr(variants: PlayVariant[] | undefined | null) {
    if (!variants?.length) return null;

    const best = variants.reduce((best, cur) => {
        const b1 = best?.bit_rate ?? -1;
        const b2 = cur?.bit_rate ?? -1;
        return b2 > b1 ? cur : best;
    });

    return best?.play_addr ?? null;
}
