Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continue to download the playlist if missing files #172

Merged
merged 7 commits into from
Apr 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ jobs:
SPOTIPY_CLIENT_ID: ${{ secrets.SPOTIPY_CLIENT_ID }}
SPOTIPY_CLIENT_SECRET: ${{ secrets.SPOTIPY_CLIENT_SECRET }}
run: |
pip install pytest pytest-cov
pytest --cov=spotify_dl tests/
sudo apt-get install ffmpeg
make tests
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
.PHONY: tests
.PHONY: tests clean
default: tests

tests:
clean:
find . | grep -E "\(__pycache__|\.pyc|\.pyo$\)" | xargs rm -rf
rm -f tests/*mp3
rm -f tests/downloaded_songs.txt

tests: clean
pip install -e .
pip install pytest pytest-cov
pytest --cov=spotify_dl tests/
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
peewee==3.13.3
sentry_sdk==0.19.4
youtube-dl>=2021.1.24.1
youtube-dl>=2021.04.01
spotipy==2.16.1
mutagen==1.45.1
spotipy== 2.16.1
8 changes: 7 additions & 1 deletion spotify_dl/youtube.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import urllib.request
from os import path

import mutagen
import youtube_dl
from mutagen.easyid3 import EasyID3
from mutagen.id3 import APIC, ID3
Expand Down Expand Up @@ -65,7 +66,12 @@ def download_songs(songs, download_directory, format_string, skip_mp3,
continue

if not skip_mp3:
song_file = MP3(path.join(f"{file_path}.mp3"), ID3=EasyID3)
try:
song_file = MP3(path.join(f"{file_path}.mp3"), ID3=EasyID3)
except mutagen.MutagenError as e:
log.debug(e)
print('Failed to download: {}, please ensure YouTubeDL is up-to-date. '.format(query))
continue
song_file['date'] = song.get('year')
if keep_playlist_order:
song_file['tracknumber'] = str(song.get('playlist_num'))
Expand Down
6 changes: 4 additions & 2 deletions tests/test_spotify_fetch_tracks.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from spotipy.oauth2 import SpotifyClientCredentials
from spotify_dl.spotify import fetch_tracks
import spotipy

import base64

def spotify_auth():
client = spotipy.Spotify(auth_manager=SpotifyClientCredentials())
# test client ids, b64 for just to deter.
client = spotipy.Spotify(auth_manager=SpotifyClientCredentials(client_id=base64.b64decode('NjliZDE4ZjNiNDY3NGMyNTkwNTllMzE5YTQ1ZGQwMzY=').decode('ascii'),
client_secret=base64.b64decode('NTczY2UwYmM2OWUzNDdkNzg3NjgwZDBlMzJmOTQ3MGM=').decode('ascii')))
return client


Expand Down