How to use the ytmdl.prepend.PREPEND 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
sys.exit(0)
    else:
        prepend.PREPEND(1)
        print('Downloaded!')

    prepend.PREPEND(1)
    print('Converting to mp3...')

    conv_name = utility.convert_to_mp3(path)

    if not conv_name:
        prepend.PREPEND(2)
        print('Something went wrong while converting!\a')
        exit(-1)

    prepend.PREPEND(1)
    print('Getting song data...')

    # TRACK_INFO = song.getData(song_name)
    TRACK_INFO = metadata.SEARCH_SONG(song_name, filters=[args.artist, args.album])

    # declare a variable to store the option
    option = 0

    if TRACK_INFO is False:
        # prepend.PREPEND(2)
        # print('Data \a')
        # exit(0)
        pass
    elif len(TRACK_INFO) == 0:
        prepend.PREPEND(2)
        print('No data was found!\a')
github deepjyoti30 / ytmdl / ytmdl.py View on Github external
option = song.setData(TRACK_INFO, is_quiet, conv_name)

        if type(option) is not int:
            prepend.PREPEND(2)
            print('Something went wrong while writing data!\a')
            sys.exit(0)

    # Get the directory where song is moved

    DIR = dir.cleanup(TRACK_INFO, option)
    prepend.PREPEND(1)
    print('Moving to {}...'.format(DIR))

    if not DIR:
        prepend.PREPEND(2)
        print('Something went wrong while moving!\a')
        sys.exit(0)
    else:
        prepend.PREPEND(1)
        print('Done')
github deepjyoti30 / ytmdl / ytmdl.py View on Github external
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)])

    # Declare a var to store the name of the yt video
    yt_title = data[choice]['title']

    prepend.PREPEND(1)
github deepjyoti30 / ytmdl / ytmdl / song.py View on Github external
try:
        imgURL = SONG_INFO[index].artwork_url_100
        try:
            # Try to get 512 cover art
            imgURL = imgURL.replace('100x100', '2048x2048')
        except Exception:
            pass

        r = requests.get(imgURL)

        with open(defaults.DEFAULT.COVER_IMG, 'wb') as f:
            f.write(r.content)

        return True
    except TimeoutError:
        prepend.PREPEND(2)
        print('Could not get album cover. Are you connected to internet?\a')
        return False
    else:
        return False
github deepjyoti30 / ytmdl / ytmdl / cache.py View on Github external
def main(SONG_NAME=''):
    """Run on program call."""
    cache = Cache()
    match = cache.search(SONG_NAME)
    if match is not None:
        PREPEND(1)
        print(Fore.MAGENTA, end='')
        print('{} '.format(match[0]), end='')
        print(Style.RESET_ALL, end='')
        print('found.')
        while True:
            choice = input('Do you still want to continue[y/n]')
            choice = choice.lower()
            if choice == 'y' or choice == 'Y':
                return True
            elif choice == 'n' or choice == 'N':
                return False
    else:
        return True
github deepjyoti30 / ytmdl / ytmdl / song.py View on Github external
def getChoice(SONG_INFO, type):
    """If more than 1 result from getData then ask for a choice."""
    # Print 5 of the search results
    # In case less, print all

    prepend.PREPEND(1)
    print('Choose One')

    results = len(SONG_INFO)

    if results > 5:
        results = 5

    PRINT_WHOLE = True

    beg = 0
    while True:
        # Print the results first
        if PRINT_WHOLE:
            print_choice(beg, results, SONG_INFO, type)
        prepend.PREPEND(1)
        choice = input('Enter Choice [a valid choice] ')
github deepjyoti30 / ytmdl / ytmdl.py View on Github external
def extract_data():
    """Extract the arguments and act accordingly."""
    args = arguments()

    if args.list is not None:
        songs = utility.get_songs(args.list)
        if len(songs) != 0:
            prepend.PREPEND(1)
            print("Downloading songs in {}".format(args.list))
            for song_name in songs:
                args.SONG_NAME = song_name
                main(args)
        else:
            prepend.PREPEND(2)
            print("{}: is empty".format(args.list))
    else:
        main(args)
github deepjyoti30 / ytmdl / ytmdl.py View on Github external
def extract_data():
    """Extract the arguments and act accordingly."""
    args = arguments()

    if args.list is not None:
        songs = utility.get_songs(args.list)
        if len(songs) != 0:
            prepend.PREPEND(1)
            print("Downloading songs in {}".format(args.list))
            for song_name in songs:
                args.SONG_NAME = song_name
                main(args)
        else:
            prepend.PREPEND(2)
            print("{}: is empty".format(args.list))
    else:
        main(args)