#!/usr/bin/env python3
import sys


def main():
    cmd_name = sys.argv[0]

    if "abd-dl-a" in cmd_name:
        if len(sys.argv) > 1 and not sys.argv[1].startswith('-'):
            sys.argv.insert(1, '-x')
            sys.argv.insert(2, '--audio-format')
            sys.argv.insert(3, 'mp3')
            sys.argv.insert(4, '--audio-quality')
            sys.argv.insert(5, '0')

    elif "abd-dl-v" in cmd_name:
        if len(sys.argv) > 1 and not sys.argv[1].startswith('-'):
            sys.argv.insert(1, '-f')
            sys.argv.insert(2, 'bestvideo+bestaudio/best')

    if __package__ is None and not getattr(sys, 'frozen', False):
        import os.path
        path = os.path.realpath(os.path.abspath(__file__))
        sys.path.insert(0, os.path.dirname(os.path.dirname(path)))

    try:
        from . import main as original_main
    except ImportError:
        from yt_dlp import main as original_main

    original_main()


if __name__ == '__main__':
    main()
