|
| 1 | + |
1 | 2 | from __future__ import with_statement
|
2 | 3 |
|
3 | 4 | import sys
|
|
7 | 8 |
|
8 | 9 | import gtk
|
9 | 10 | import pango
|
10 |
| -import gobject |
11 | 11 |
|
12 | 12 | import ui
|
13 | 13 | import misc
|
14 | 14 | import mpdhelper as mpdh
|
15 | 15 | import consts
|
| 16 | +import threading |
16 | 17 | from pluginsystem import pluginsystem
|
17 | 18 |
|
18 | 19 |
|
@@ -386,18 +387,28 @@ def get_lyrics_start(self, search_artist, search_title, filename_artist,
|
386 | 387 | lyrics = lyrics[len(header):]
|
387 | 388 | self._show_lyrics(filename_artist, filename_title, lyrics=lyrics)
|
388 | 389 | else:
|
389 |
| - # Fetch lyrics from lyricwiki.org etc. |
390 |
| - lyrics_fetchers = pluginsystem.get('lyrics_fetching') |
391 |
| - callback = lambda * args: self.get_lyrics_response( |
392 |
| - filename_artist, filename_title, song_dir, *args) |
393 |
| - if lyrics_fetchers: |
394 |
| - msg = _("Fetching lyrics...") |
395 |
| - for _plugin, cb in lyrics_fetchers: |
396 |
| - cb(callback, search_artist, search_title) |
397 |
| - else: |
398 |
| - msg = _("No lyrics plug-in enabled.") |
399 |
| - self._show_lyrics(filename_artist, filename_title, |
400 |
| - lyrics=msg) |
| 390 | + # Fetch lyrics from plugins. |
| 391 | + thread = threading.Thread(target=self.fetch_lyrics_from_plugins, |
| 392 | + args=(search_artist, search_title, |
| 393 | + song_dir)) |
| 394 | + thread.start() |
| 395 | + |
| 396 | + def fetch_lyrics_from_plugins(self, search_artist, search_title, song_dir): |
| 397 | + lyrics_fetchers = pluginsystem.get('lyrics_fetching') |
| 398 | + if lyrics_fetchers: |
| 399 | + self._show_lyrics(search_artist, search_title, |
| 400 | + lyrics=_("Fetching lyrics...")) |
| 401 | + for plugin, get_lyrics in lyrics_fetchers: |
| 402 | + lyrics = get_lyrics(search_artist, search_title) |
| 403 | + if lyrics: |
| 404 | + self.get_lyrics_response(search_artist, search_title, |
| 405 | + song_dir, lyrics=lyrics) |
| 406 | + return |
| 407 | + msg = _("Lyrics not found.") |
| 408 | + else: |
| 409 | + msg = _("No lyrics plug-in enabled.") |
| 410 | + |
| 411 | + self._show_lyrics(search_artist, search_title, lyrics=msg) |
401 | 412 |
|
402 | 413 | def get_lyrics_response(self, artist_then, title_then, song_dir,
|
403 | 414 | lyrics=None, error=None):
|
|
0 commit comments