Skip to content

Commit

Permalink
补充URL有效性判断
Browse files Browse the repository at this point in the history
  • Loading branch information
0xHJK committed Jun 11, 2019
1 parent 34d1550 commit 547fe75
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions music_dl/song.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ def _download_file(self, url, outfile, stream=False):
:param stream: need process bar or not
:return:
"""
if not url:
self.logger.error("URL is empty.")
return
try:
r = requests.get(
url,
Expand Down Expand Up @@ -256,13 +259,16 @@ def _save_lyrics_text(self):
)

def download_song(self):
self._download_file(self.song_url, self.song_fullname, stream=True)
if self.song_url:
self._download_file(self.song_url, self.song_fullname, stream=True)

def download_lyrics(self):
self._download_file(self.lyrics_url, self.lyrics_fullname, stream=False)
if self.lyrics_url:
self._download_file(self.lyrics_url, self.lyrics_fullname, stream=False)

def download_cover(self):
self._download_file(self.cover_url, self.cover_fullname, stream=False)
if self.cover_url:
self._download_file(self.cover_url, self.cover_fullname, stream=False)

def download(self):
""" Main download function """
Expand Down

0 comments on commit 547fe75

Please sign in to comment.