def test_download_from_list_without_youtube_api(self): expect_title = "1. Tony's Videos VERY SHORT VIDEO 28.10.2016" const.args.youtube_api_key = None youtube_tools.set_api_key() content = youtube_tools.go_pafy(raw_song, metadata) title = youtube_tools.get_youtube_title(content, 1) assert title == expect_title
def test_download_from_list_without_youtube_api(self, metadata_fixture, content_fixture): const.args.youtube_api_key = None youtube_tools.set_api_key() content_fixture = youtube_tools.go_pafy(TRACK_SEARCH, metadata_fixture) title = youtube_tools.get_youtube_title(content_fixture, 1, 1) assert title == "1/1: {0}".format(EXPECTED_TITLE)
def test_single_download_with_youtube_api(self): global content global title const.args.youtube_api_key = YT_API_KEY youtube_tools.set_api_key() content = youtube_tools.go_pafy(TRACK_SEARCH, metadata) title = youtube_tools.get_youtube_title(content) assert title == EXPECTED_TITLE
def test_single_download_with_youtube_api(self): global content global title expect_title = "Tony's Videos VERY SHORT VIDEO 28.10.2016" key = 'AIzaSyAnItl3udec-Q1d5bkjKJGL-RgrKO_vU90' const.args.youtube_api_key = key youtube_tools.set_api_key() content = youtube_tools.go_pafy(raw_song, metadata) title = youtube_tools.get_youtube_title(content) assert title == expect_title
def get_track(): const.args = handle.get_arguments() internals.filter_path(const.args.folder) youtube_tools.set_api_key() try: if const.args.song: for track in const.args.song: track_dl = downloader.Downloader(raw_song=track) track_dl.download_single() except KeyboardInterrupt as e: print("Exception occured in method 'get_track':", e) return False return True
def main(): const.args = handle.get_arguments() if const.args.version: print("spotdl {version}".format(version=__version__)) sys.exit() internals.filter_path(const.args.folder) youtube_tools.set_api_key() logzero.setup_default_logger(formatter=const._formatter, level=const.args.log_level) log.debug("Python version: {}".format(sys.version)) log.debug("Platform: {}".format(platform.platform())) log.debug(pprint.pformat(const.args.__dict__)) try: if const.args.song: download_single(raw_song=const.args.song) elif const.args.list: if const.args.write_m3u: youtube_tools.generate_m3u(track_file=const.args.list) else: download_list( tracks_file=const.args.list, skip_file=const.args.skip, write_successful_file=const.args.write_successful, ) elif const.args.playlist: spotify_tools.write_playlist(playlist_url=const.args.playlist) elif const.args.album: spotify_tools.write_album(album_url=const.args.album) elif const.args.all_albums: spotify_tools.write_all_albums_from_artist( artist_url=const.args.all_albums) elif const.args.username: spotify_tools.write_user_playlist(username=const.args.username) # actually we don't necessarily need this, but yeah... # explicit is better than implicit! sys.exit(0) except KeyboardInterrupt as e: log.exception(e) sys.exit(3)
def main(): const.args = handle.get_arguments() internals.filter_path(const.args.folder) youtube_tools.set_api_key() logzero.setup_default_logger(formatter=const._formatter, level=const.args.log_level) try: match_args() # actually we don't necessarily need this, but yeah... # explicit is better than implicit! sys.exit(0) except KeyboardInterrupt as e: log.exception(e) sys.exit(3)
def main_func_caller(): # Todo try new implementation internals.filter_path(const.args.folder) youtube_tools.set_api_key() logzero.setup_default_logger(formatter=const._formatter, level=const.args.log_level) try: operation, text_file, tracks_url = match_args() if operation is not 'list': list_downloader(operation, text_file, tracks_url) # I don't need this type of exception, I'll remove another time except Exception as e: print(e) operation = False log.exception(e) sys.exit(3)
def main(): const.args = handle.get_arguments() if const.args.version: print('spotdl {version}'.format(version=__version__)) sys.exit() internals.filter_path(const.args.folder) youtube_tools.set_api_key() const.log = const.logzero.setup_logger(formatter=const._formatter, level=const.args.log_level) global log log = const.log log.debug('Python version: {}'.format(sys.version)) log.debug('Platform: {}'.format(platform.platform())) log.debug(pprint.pformat(const.args.__dict__)) try: if const.args.song: download_single(raw_song=const.args.song) elif const.args.list: download_list(text_file=const.args.list) elif const.args.playlist: spotify_tools.write_playlist(playlist_url=const.args.playlist) elif const.args.album: spotify_tools.write_album(album_url=const.args.album) elif const.args.username: spotify_tools.write_user_playlist(username=const.args.username) # actually we don't necessarily need this, but yeah... # explicit is better than implicit! sys.exit(0) except KeyboardInterrupt as e: log.exception(e) sys.exit(3)
def test_default(self): expect_key = 'AIzaSyC6cEeKlxtOPybk9sEe5ksFN5sB-7wzYp0' const.args.youtube_api_key = None youtube_tools.set_api_key() key = youtube_tools.pafy.g.api_key assert key == expect_key
def test_custom(self): expect_key = 'some_api_key' const.args.youtube_api_key = expect_key youtube_tools.set_api_key() key = youtube_tools.pafy.g.api_key assert key == expect_key
def test_default(self): const.args.youtube_api_key = None youtube_tools.set_api_key() key = youtube_tools.pafy.g.api_key assert key == EXPECTED_YT_API_KEY
def test_custom(self): const.args.youtube_api_key = EXPECTED_YT_API_KEY_CUSTOM youtube_tools.set_api_key() key = youtube_tools.pafy.g.api_key assert key == EXPECTED_YT_API_KEY_CUSTOM
def test_single_download_with_youtube_api(self, title_fixture): const.args.youtube_api_key = YT_API_KEY youtube_tools.set_api_key() assert title_fixture == EXPECTED_TITLE