Beispiel #1
0
def extract(link):

    # Check is sample folder exists
    if not os.path.isdir(SAMPLES):
        os.mkdir(SAMPLES)

    file_name = ''

    url = url_extract(link)
    DL = Downloader()

    if url == 'www.youtube.com':
        file_name = DL.YT_extract(link)

        os.rename(
            os.getcwd() + '/' + file_name,
            SAMPLES + file_name.replace(' (Video)-' + link.split('=')[-1], ''))

        detect_key(SAMPLES +
                   file_name.replace(' (Video)-' + link.split('=')[-1], ''))

    elif url == 'soundcloud.com':
        file_name = DL.SC_extract(link)
        print('Currently not supporting Soundcloud due to API Issues.')
        sys.exit(1)

    else:
        print('Link is not Youtube or Soundcloud.')
        print('Please use either of the websites.')
        sys.exit(1)

    return file_name