Skip to content

Commit

Permalink
Merge pull request #5 from oldherl/master
Browse files Browse the repository at this point in the history
fix compatibility with feeluown >= 3.7.4 (#4)
  • Loading branch information
cosven committed Mar 27, 2021
2 parents 4832eb8 + 010d474 commit f7174fd
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions fuo_dl/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from fuocore import aio
from fuocore.models import ModelType
from feeluown.helpers import async_run
from feeluown.gui.helpers import async_run
from feeluown.widgets.statusline import StatusLineItem

from .manager import DownloadManager
Expand Down Expand Up @@ -72,14 +72,20 @@ def _download_cur_media(self):
async def download_song(self, song):
title = await async_run(lambda: song.title)
artists_name = await async_run(lambda: song.artists_name)
media = await aio.run_in_executor(None, self._app.playlist.prepare_media, song)
if media and media.url:
ext = guess_media_url_ext(media.url)
media = await aio.run_in_executor(
None,
self._app.library.song_prepare_media,
song,
self._app.playlist.audio_select_policy)
media = Media(media)
media_url = media.url
if media_url:
ext = guess_media_url_ext(media_url)
filename = cook_filename(title, artists_name, ext)
if self._mgr.is_file_downloaded(filename):
return
logger.info(f'download {media.url} into {filename}')
await self._mgr.get(media.url, filename)
logger.info(f'download {media_url} into {filename}')
await self._mgr.get(media_url, filename)
else:
# this should not happen, so we log a error msg
logger.error('url of current song is empty, will not download')
Expand Down

0 comments on commit f7174fd

Please sign in to comment.