Skip to content

Commit

Permalink
*: fix several bugs (#802)
Browse files Browse the repository at this point in the history
Fix three issues
1. video does not show on macOS
2. song is marked as bad even if has mv media
3. user avatar never shows
  • Loading branch information
cosven authored Feb 21, 2024
1 parent 7307151 commit 1e73da5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion feeluown/gui/components/avatar.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async def _show_provider_current_user(self, source):
assert provider is not None
user = None
if isinstance(provider, SupportsCurrentUser):
user = await run_fn(provider.get_current_user_or_none, source)
user = await run_fn(provider.get_current_user_or_none)

if user is None:
return None
Expand Down
2 changes: 2 additions & 0 deletions feeluown/gui/uimain/nowplaying_overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,11 @@ def enter_video_mode(self):
video_widget = self._app.ui.mpv_widget
video_widget.overlay_auto_visible = True
if video_widget.parent() == self.artwork_view:
video_widget.show()
self.artwork_view.set_body(video_widget)
else:
with video_widget.change_parent():
video_widget.show()
self.artwork_view.set_body(video_widget)
self.ctl_btns.hide()
self.progress.hide()
Expand Down
4 changes: 4 additions & 0 deletions feeluown/gui/watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,11 @@ def enter_fullwindow_mode(self, go_back=None):
if video_widget.parent() != self._fullwindow_container:
with video_widget.change_parent():
self._fullwindow_container.set_body(video_widget)
video_widget.show()
self._fullwindow_container.show()
self._fullwindow_container.raise_()
else:
video_widget.show()
self._fullwindow_container.show()
self._fullwindow_container.raise_()

Expand Down Expand Up @@ -139,9 +141,11 @@ def enter_pip_mode(self):

if video_widget.parent() != self._pip_container:
with video_widget.change_parent():
video_widget.show()
self._pip_container.attach_widget(video_widget)
self._pip_container.show()
else:
video_widget.show()
self._pip_container.show()

video_widget.ctl_bar.clear_adhoc_btns()
Expand Down
9 changes: 9 additions & 0 deletions feeluown/library/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ def auth(self, user):
"""use provider as a specific user"""
self._user = user

def get_current_user_or_none(self):
"""
.. versionadded: 4.0
"""
try:
return self.get_current_user()
except NoUserLoggedIn:
return None

def search(self, *args, **kwargs):
pass

Expand Down
21 changes: 10 additions & 11 deletions feeluown/player/playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,16 +489,12 @@ async def a_set_current_song(self, song):
"""
target_song = song # The song to be set.
media = None # The corresponding media to be set.

try:
media = await self._prepare_media(song)
except MediaNotFound as e:
if e.reason is MediaNotFound.Reason.check_children:
await self.a_set_current_song_children(song)
return

logger.info(f'no media found for {song} due to {e}, mark it as bad')
self.mark_as_bad(song)
except ProviderIOError as e:
# FIXME: This may cause infinite loop when the prepare media always fails
logger.error(f'prepare media failed: {e}, try next song')
Expand All @@ -507,24 +503,27 @@ async def a_set_current_song(self, song):
except Exception as e: # noqa
# When the exception is unknown, we mark the song as bad.
self._app.show_msg(f'获取歌曲链接失败: {e}')
logger.exception('prepare media failed due to unknown error, '
'so we mark the song as a bad one')
self.mark_as_bad(song)
logger.exception('prepare media failed due to unknown error')
else:
assert media, "media must not be empty"

# The song has no media, try to find and use standby unless it is in fm mode.
if media is None:
# if mode is fm mode, do not find standby song, just skip the song.
if self.mode is PlaylistMode.fm:
run_afn(self.a_next)
return
if self._app.config.ENABLE_MV_AS_STANDBY:
self._app.show_msg('尝试获取音乐视频的播放资源...')
media = await self._prepare_mv_media(song)

if media:
self._app.show_msg('使用音乐视频作为其播放资源 ✅')
else:
# if mode is fm mode, do not find standby song, just skip the song.
if self.mode is PlaylistMode.fm:
self.mark_as_bad(song)
run_afn(self.a_next)
return

logger.info(f"no media found for {song}, mark it as bad")
self.mark_as_bad(song)
target_song, media = await self.find_and_use_standby(song)

metadata = await self._prepare_metadata_for_song(target_song)
Expand Down

0 comments on commit 1e73da5

Please sign in to comment.