How to use the ytmdl.yt.search function in ytmdl

To help you get started, we’ve selected a few ytmdl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github deepjyoti30 / ytmdl / ytmdl.py View on Github external
link = url

        # In this case choice will be 0
        choice = 0
    else:
        if is_quiet:
            prepend.PREPEND(1)
            print('Quiet is enabled')

        prepend.PREPEND(1)
        print('Searching Youtube for ', end='')
        print(Fore.LIGHTYELLOW_EX, end='')
        print(song_name, end='')
        print(Style.RESET_ALL)

        data, urls = yt.search(song_name, args.better_search,
                                kw=[args.artist, args.album])
        
        # Handle the exception if urls has len 0
        if len(urls) == 0:
            prepend.PREPEND(2)
            print("No song found. Please try again with a different keyword.")
            print(Style.RESET_ALL, end='')
            exit()

        if len(data) > 1 and not is_quiet:
            # Ask for a choice
            choice = song.getChoice(data, 'mp3')
        else:
            choice = 0

        link = 'https://youtube.com{}'.format(urls[int(choice)])