diff --git a/Makefile b/Makefile index f82b56ed..b35d2d12 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ default: tests clean: find . | grep -E "\(__pycache__|\.pyc|\.pyo$\)" | xargs rm -rf - rm -f tests/*mp3 + rm -f tests/*mp* rm -f tests/downloaded_songs.txt tests: clean diff --git a/requirements.txt b/requirements.txt index 93cfc609..f21f08a3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ -peewee==3.13.3 sentry_sdk==0.19.4 -youtube-dl>=2021.04.01 +youtube-dl>=2021.06.06 spotipy==2.16.1 mutagen==1.45.1 spotipy== 2.16.1 \ No newline at end of file diff --git a/spotify_dl/cache.py b/spotify_dl/cache.py deleted file mode 100644 index ec3e51d3..00000000 --- a/spotify_dl/cache.py +++ /dev/null @@ -1,31 +0,0 @@ -from spotify_dl.models import Song -from peewee import DoesNotExist -from spotify_dl.scaffold import log - - -def check_if_in_cache(search_term): - """ - Checks if the specified search term is in the local database cache. - and returns the video id if it exists. - :param search_term: String to be searched for in the cache - :return A tuple with Boolean and video id if it exists - """ - try: - song = Song.get(search_term=search_term) - log.debug(f"Found id {song.video_id} for {search_term} in cache") - return True, song.video_id - except DoesNotExist: - log.debug(f"Couldn't find id for {search_term} in cache") - return False, None - - -def save_to_cache(search_term, video_id): - """ - Saves the search term and video id to the database cache so it can be looked up later. - :param search_term: Search term to be saved to in the cache - :param video_id: Video id to be saved to in the cache - :return Video id saved in the cache - """ - song_info, saved = Song.get_or_create(search_term=search_term, video_id=video_id) - log.debug(f"Saved: {saved} video id {song_info.video_id} in cache") - return song_info.video_id diff --git a/tests/test_cache_get.py b/tests/test_cache_get.py deleted file mode 100644 index 90e5c313..00000000 --- a/tests/test_cache_get.py +++ /dev/null @@ -1,20 +0,0 @@ -from spotify_dl.cache import check_if_in_cache, save_to_cache -from spotify_dl.models import db, Song - -search_term_wrong = 'bleh' -search_term = "Red Hot Chili Peppers - Dani California [Official Music Video]" - -video_id = "Sb5aq5HcS1A" -db.connect() -db.create_tables([Song]) - -def test_check_for_cache_miss(): - exists, song_info = check_if_in_cache(search_term=search_term_wrong) - assert exists is False - assert song_info is None - -def test_check_for_cache_hit(): - _ = save_to_cache(search_term=search_term, video_id='Sb5aq5HcS1A') - exists, cache_video_id = check_if_in_cache(search_term=search_term) - assert exists is True - assert cache_video_id == video_id \ No newline at end of file