コード例 #1
0
    def populate_playlists_for_menu(self, playlistinfo):
        if self.mergepl_id:
            self.UIManager().remove_ui(self.mergepl_id)
        if self.actionGroupPlaylists:
            self.UIManager().remove_action_group(self.actionGroupPlaylists)
            self.actionGroupPlaylists = None
        self.actionGroupPlaylists = gtk.ActionGroup('MPDPlaylists')
        self.UIManager().ensure_update()
        actions = []
        for i in range(len(playlistinfo)):
            action_name = "Playlist: " + playlistinfo[i].replace("&", "")
            actions.append((action_name, gtk.STOCK_JUSTIFY_CENTER,
                            misc.unescape_html(playlistinfo[i]), None, None,
                            self.on_playlist_menu_click))
        self.actionGroupPlaylists.add_actions(actions)
        uiDescription = """
			<ui>
			  <popup name="mainmenu">
			      <menu action="plmenu">
			"""
        for i in range(len(playlistinfo)):
            action_name = "Playlist: " + playlistinfo[i].replace("&", "")
            uiDescription = uiDescription + """<menuitem action=\"""" + action_name + """\" position="bottom"/>"""
        uiDescription = uiDescription + """</menu></popup></ui>"""
        self.mergepl_id = self.UIManager().add_ui_from_string(uiDescription)
        self.UIManager().insert_action_group(self.actionGroupPlaylists, 0)
        self.UIManager().get_widget('/hidden').set_property('visible', False)
        # If we're not on the Current tab, prevent additional menu items
        # from displaying:
        self.update_menu_visibility()
コード例 #2
0
ファイル: lyricwiki.py プロジェクト: xcorp/sonata-svn
 def get_lyrics_thread(self, callback, artist, title):
     try:
         lyricpage = urllib.urlopen(('http://lyrics.wikia.com/index.php?'
                                     'title=%s:%s&action=edit') \
                                    % (self.lyricwiki_format(artist),
                                       self.lyricwiki_format(title))).read()
         content = re.split("<textarea[^>]*>",
                            lyricpage)[1].split("</textarea>")[0]
         content = content.strip()
         redir_tag = "#redirect"
         if content[:len(redir_tag)].lower() == redir_tag:
             addr = "http://lyrics.wikia.com/index.php?title=%s&action=edit" \
                     % urllib.quote(content.split("[[")[1].split("]]")[0])
             lyricpage = urllib.urlopen(addr).read()
             content = re.split("<textarea[^>]*>",
                                lyricpage)[1].split("</textarea>")[0]
             content = content.strip()
         lyrics = content.split(
             "&lt;lyrics&gt;")[1].split("&lt;/lyrics&gt;")[0].strip()
         if lyrics != ('&lt;!-- PUT LYRICS HERE '
                               '(and delete this entire line) --&gt;'):
             lyrics = misc.unescape_html(lyrics)
             lyrics = misc.wiki_to_html(lyrics)
             lyrics = lyrics.decode("utf-8")
             self.call_back(callback, lyrics=lyrics)
         else:
             error = _("Lyrics not found")
             self.call_back(callback, error=error)
     except:
         error = _("Fetching lyrics failed")
         self.call_back(callback, error=error)
コード例 #3
0
ファイル: playlists.py プロジェクト: themylogin/sonata
 def populate_playlists_for_menu(self, playlistinfo):
     if self.mergepl_id:
         self.UIManager().remove_ui(self.mergepl_id)
     if self.actionGroupPlaylists:
         self.UIManager().remove_action_group(self.actionGroupPlaylists)
         self.actionGroupPlaylists = None
     self.actionGroupPlaylists = gtk.ActionGroup('MPDPlaylists')
     self.UIManager().ensure_update()
     actions = [("Playlist: %s" % playlist.replace("&", ""),
             gtk.STOCK_JUSTIFY_CENTER,
             misc.unescape_html(playlist), None, None,
             self.on_playlist_menu_click)
             for playlist in playlistinfo]
     self.actionGroupPlaylists.add_actions(actions)
     uiDescription = """
         <ui>
           <popup name="mainmenu">
               <menu action="plmenu">
         """
     uiDescription += "".join('<menuitem action=\"%s\"/>' % action[0]
                     for action in actions)
     uiDescription += '</menu></popup></ui>'
     self.mergepl_id = self.UIManager().add_ui_from_string(uiDescription)
     self.UIManager().insert_action_group(self.actionGroupPlaylists, 0)
     self.UIManager().get_widget('/hidden').set_property('visible', False)
     # If we're not on the Current tab, prevent additional menu items
     # from displaying:
     self.update_menu_visibility()
コード例 #4
0
	def populate_playlists_for_menu(self, playlistinfo):
		if self.mergepl_id:
			self.UIManager().remove_ui(self.mergepl_id)
		if self.actionGroupPlaylists:
			self.UIManager().remove_action_group(self.actionGroupPlaylists)
			self.actionGroupPlaylists = None
		self.actionGroupPlaylists = gtk.ActionGroup('MPDPlaylists')
		self.UIManager().ensure_update()
		actions = []
		for i in range(len(playlistinfo)):
			action_name = "Playlist: " + playlistinfo[i].replace("&", "")
			actions.append((action_name, gtk.STOCK_JUSTIFY_CENTER, misc.unescape_html(playlistinfo[i]), None, None, self.on_playlist_menu_click))
		self.actionGroupPlaylists.add_actions(actions)
		uiDescription = """
			<ui>
			  <popup name="mainmenu">
			      <menu action="plmenu">
			"""
		for i in range(len(playlistinfo)):
			action_name = "Playlist: " + playlistinfo[i].replace("&", "")
			uiDescription = uiDescription + """<menuitem action=\"""" + action_name + """\" position="bottom"/>"""
		uiDescription = uiDescription + """</menu></popup></ui>"""
		self.mergepl_id = self.UIManager().add_ui_from_string(uiDescription)
		self.UIManager().insert_action_group(self.actionGroupPlaylists, 0)
		self.UIManager().get_widget('/hidden').set_property('visible', False)
		# If we're not on the Current tab, prevent additional menu items
		# from displaying:
		self.update_menu_visibility()
コード例 #5
0
    def get_lyrics_thread(self, callback, artist, title):
        try:
            lyricpage = urllib.urlopen(
                "http://lyricwiki.org/index.php?"
                "title=%s:%s&action=edit" % (self.lyricwiki_format(artist), self.lyricwiki_format(title))
            ).read()
            content = re.split("<textarea[^>]*>", lyricpage)[1].split("</textarea>")[0]
            content = content.strip()
            redir_tag = "#redirect"
            if content[: len(redir_tag)].lower() == redir_tag:
                addr = "http://lyricwiki.org/index.php?title=%s&action=edit" % urllib.quote(
                    content.split("[[")[1].split("]]")[0]
                )
                lyricpage = urllib.urlopen(addr).read()
                content = re.split("<textarea[^>]*>", lyricpage)[1].split("</textarea>")[0]
                content = content.strip()
            lyrics = content.split("&lt;lyrics>")[1].split("&lt;/lyrics>")[0]
            lyrics = misc.unescape_html(lyrics)
            lyrics = misc.wiki_to_html(lyrics)
            lyrics = lyrics.decode("utf-8").replace(
                "<!-- PUT LYRICS HERE (and delete this entire line) -->", "Lyrics Unavailable."
            )
            self.call_back(callback, lyrics=lyrics)

        except:
            error = _("Fetching lyrics failed")
            self.call_back(callback, error=error)
コード例 #6
0
ファイル: lyricwiki.py プロジェクト: themylogin/sonata
 def get_lyrics_thread(self, callback, artist, title):
     try:
         lyricpage = urllib.urlopen(
             "http://lyricwiki.org/index.php?title=%s:%s&action=edit" %
             (self.lyricwiki_format(artist),
              self.lyricwiki_format(title))).read()
         content = re.split("<textarea[^>]*>",
                            lyricpage)[1].split("</textarea>")[0]
         content = content.strip()
         redir_tag = "#redirect"
         if content[:len(redir_tag)].lower() == redir_tag:
             addr = "http://lyricwiki.org/index.php?title=%s&action=edit" % urllib.quote(
                 content.split("[[")[1].split("]]")[0])
             lyricpage = urllib.urlopen(addr).read()
             content = re.split("<textarea[^>]*>",
                                lyricpage)[1].split("</textarea>")[0]
             content = content.strip()
         lyrics = content.split("&lt;lyrics&gt;")[1].split(
             "&lt;/lyrics&gt;")[0]
         if lyrics.strip(
         ) != "&lt;!-- PUT LYRICS HERE (and delete this entire line) --&gt;":
             lyrics = misc.unescape_html(lyrics)
             lyrics = misc.wiki_to_html(lyrics)
             lyrics = lyrics.decode("utf-8")
             self.call_back(callback, lyrics=lyrics)
         else:
             error = _("Lyrics not found")
             self.call_back(callback, error=error)
     except:
         error = _("Fetching lyrics failed")
         self.call_back(callback, error=error)
コード例 #7
0
	def on_streams_edit(self, action):
		model, selected = self.streams_selection.get_selected_rows()
		try:
			streamname = misc.unescape_html(model.get_value(model.get_iter(selected[0]), 1))
			for i, name in enumerate(self.config.stream_names):
				if name == streamname:
					self.on_streams_new(action, i)
					return
		except:
			pass
コード例 #8
0
ファイル: playlists.py プロジェクト: themylogin/sonata
 def on_playlist_menu_click(self, action):
     plname = misc.unescape_html(action.get_name().replace("Playlist: ", ""))
     response = ui.show_msg(self.window, _("Would you like to replace the existing playlist or append these songs?"), _("Existing Playlist"), "existingPlaylist", (_("Replace playlist"), 1, _("Append songs"), 2), default=self.config.existing_playlist_option)
     if response == 1: # Overwrite
         self.config.existing_playlist_option = response
         mpdh.call(self.client, 'playlistclear', plname)
         self.add_selected_to_playlist(plname)
     elif response == 2: # Append songs:
         self.config.existing_playlist_option = response
         self.add_selected_to_playlist(plname)
コード例 #9
0
	def on_streams_edit(self, action):
		model, selected = self.streams_selection.get_selected_rows()
		try:
			streamname = misc.unescape_html(model.get_value(model.get_iter(selected[0]), 1))
			for i, name in enumerate(self.config.stream_names):
				if name == streamname:
					self.on_streams_new(action, i)
					return
		except:
			pass
コード例 #10
0
    def get_lyrics_thread(self, callback, artist, title):
        # FIXME locking...
        global ServiceProxy
        if ServiceProxy is None:
            try:
                from ZSI import ServiceProxy
                # Make sure we have the right version..
                if not hasattr(ServiceProxy, 'ServiceProxy'):
                    ServiceProxy = None
            except ImportError:
                ServiceProxy = None
        if ServiceProxy is None:
            self.call_back(
                callback,
                None,
                None,
                error=_("ZSI not found, fetching lyrics support disabled."))
            return

        # FIXME locking...
        if self.lyricServer is None:
            wsdlFile = "http://lyricwiki.org/server.php?wsdl"
            try:
                self.lyricServer = True
                timeout = socketgettimeout()
                socketsettimeout(consts.LYRIC_TIMEOUT)
                self.lyricServer = ServiceProxy.ServiceProxy(
                    wsdlFile,
                    cachedir=os.path.expanduser("~/.service_proxy_dir"))
            except:
                self.lyricServer = None
                socketsettimeout(timeout)
                error = _("Couldn't connect to LyricWiki")
                self.call_back(callback, error=error)
                return

        try:
            timeout = socketgettimeout()
            socketsettimeout(consts.LYRIC_TIMEOUT)
            lyrics = self.lyricServer.getSong(
                artist=self.lyricwiki_format(artist),
                song=self.lyricwiki_format(title))['return']["lyrics"]
            if lyrics.lower() != "not found":
                lyrics = misc.unescape_html(lyrics)
                lyrics = misc.wiki_to_html(lyrics)
                lyrics = lyrics.encode("ISO-8859-1")
                self.call_back(callback, lyrics=lyrics)
            else:
                error = _("Lyrics not found")
                self.call_back(callback, error=error)
        except:
            error = _("Fetching lyrics failed")
            self.call_back(callback, error=error)

        socketsettimeout(timeout)
コード例 #11
0
    def get_lyrics_thread(self, callback, artist, title):
        # FIXME locking...
        global ServiceProxy
        if ServiceProxy is None:
            try:
                from ZSI import ServiceProxy

                # Make sure we have the right version..
                if not hasattr(ServiceProxy, "ServiceProxy"):
                    ServiceProxy = None
            except ImportError:
                ServiceProxy = None
        if ServiceProxy is None:
            self.call_back(callback, None, None, error=_("ZSI not found, fetching lyrics support disabled."))
            return

            # FIXME locking...
        if self.lyricServer is None:
            wsdlFile = "http://lyricwiki.org/server.php?wsdl"
            try:
                self.lyricServer = True
                timeout = socketgettimeout()
                socketsettimeout(consts.LYRIC_TIMEOUT)
                self.lyricServer = ServiceProxy.ServiceProxy(
                    wsdlFile, cachedir=os.path.expanduser("~/.service_proxy_dir")
                )
            except:
                self.lyricServer = None
                socketsettimeout(timeout)
                error = _("Couldn't connect to LyricWiki")
                self.call_back(callback, error=error)
                return

        try:
            timeout = socketgettimeout()
            socketsettimeout(consts.LYRIC_TIMEOUT)
            lyrics = self.lyricServer.getSong(artist=self.lyricwiki_format(artist), song=self.lyricwiki_format(title))[
                "return"
            ]["lyrics"]
            if lyrics.lower() != "not found":
                lyrics = misc.unescape_html(lyrics)
                lyrics = misc.wiki_to_html(lyrics)
                lyrics = lyrics.encode("ISO-8859-1")
                self.call_back(callback, lyrics=lyrics)
            else:
                error = _("Lyrics not found")
                self.call_back(callback, error=error)
        except:
            error = _("Fetching lyrics failed")
            self.call_back(callback, error=error)

        socketsettimeout(timeout)
コード例 #12
0
	def on_playlist_menu_click(self, action):
		plname = misc.unescape_html(action.get_name().replace("Playlist: ", ""))
		response = ui.show_msg(self.window, _("Would you like to replace the existing playlist or append these songs?"), _("Existing Playlist"), "existingPlaylist", (_("Replace playlist"), 1, _("Append songs"), 2), default=self.config.existing_playlist_option)
		if response == 1: # Overwrite
			self.config.existing_playlist_option = response
			self.playlist_create(plname)
		elif response == 2: # Append songs:
			self.config.existing_playlist_option = response
			mpdh.call(self.client, 'command_list_ok_begin')
			for song in self.get_current_songs():
				mpdh.call(self.client, 'playlistadd', plname, mpdh.get(song, 'file'))
			mpdh.call(self.client, 'command_list_end')
		return
コード例 #13
0
	def on_playlist_rename(self, _action):
		plname = self.prompt_for_playlist_name(_("Rename Playlist"), 'renamePlaylist')
		if plname:
			model, selected = self.playlists_selection.get_selected_rows()
			oldname = misc.unescape_html(model.get_value(model.get_iter(selected[0]), 1))
			if self.playlist_name_exists(_("Rename Playlist"), 'renamePlaylistError', plname, oldname):
				return
			self.playlist_create(plname, oldname)
			# Re-select item:
			row = 0
			for pl in self.playlistsdata:
				if pl[1] == plname:
					self.playlists_selection.select_path((row,))
					return
				row = row + 1
コード例 #14
0
ファイル: info.py プロジェクト: BackupTheBerlios/sonata-svn
	def get_lyrics_response(self, artist_then, title_then, song_dir,
				lyrics=None, error=None):
		if lyrics and not error:
			filename = self.target_lyrics_filename(artist_then, title_then, song_dir)
			# Save lyrics to file:
			misc.create_dir('~/.lyrics/')
			f = open(filename, 'w')
			lyrics = misc.unescape_html(lyrics)
			try:
				f.write(lyrics.decode(self.enc).encode('utf8'))
			except:
				f.write(lyrics)
			f.close()

		self._show_lyrics(artist_then, title_then, lyrics, error)
コード例 #15
0
ファイル: playlists.py プロジェクト: themylogin/sonata
 def on_playlist_rename(self, _action):
     plname = self.prompt_for_playlist_name(_("Rename Playlist"), 'renamePlaylist')
     if plname:
         model, selected = self.playlists_selection.get_selected_rows()
         oldname = misc.unescape_html(model.get_value(model.get_iter(selected[0]), 1))
         if self.playlist_name_exists(_("Rename Playlist"), 'renamePlaylistError', plname, oldname):
             return
         self.playlist_create(plname, oldname)
         # Re-select item:
         row = 0
         for pl in self.playlistsdata:
             if pl[1] == plname:
                 self.playlists_selection.select_path((row,))
                 return
             row = row + 1
コード例 #16
0
    def get_lyrics_response(self, artist_then, title_then, song_dir,
                lyrics=None, error=None):
        if lyrics and not error:
            filename = self.target_lyrics_filename(artist_then, title_then, song_dir)
            # Save lyrics to file:
            misc.create_dir('~/.lyrics/')
            try:
                with open(filename, 'w') as f:
                    lyrics = misc.unescape_html(lyrics)
                    try:
                        f.write(lyrics.decode(self.enc).encode('utf8'))
                    except:
                        f.write(lyrics)
            except IOError:
                pass

        self._show_lyrics(artist_then, title_then, lyrics, error)
コード例 #17
0
 def on_playlist_menu_click(self, action):
     plname = misc.unescape_html(action.get_name().replace(
         "Playlist: ", ""))
     response = ui.show_msg(
         self.window,
         _("Would you like to replace the existing playlist or append these songs?"
           ),
         _("Existing Playlist"),
         "existingPlaylist",
         (_("Replace playlist"), 1, _("Append songs"), 2),
         default=self.config.existing_playlist_option)
     if response == 1:  # Overwrite
         self.config.existing_playlist_option = response
         self.playlist_create(plname)
     elif response == 2:  # Append songs:
         self.config.existing_playlist_option = response
         mpdh.call(self.client, 'command_list_ok_begin')
         for song in self.get_current_songs():
             mpdh.call(self.client, 'playlistadd', plname,
                       mpdh.get(song, 'file'))
         mpdh.call(self.client, 'command_list_end')
     return
コード例 #18
0
ファイル: info.py プロジェクト: xcorp/sonata-svn
    def _set_lyrics(self, lyrics):
        if lyrics is None:
            return

        lyrics_buf = self.lyricsText.get_buffer()
        lyrics_buf.set_text('')

        # pango needs only ampersand to be escaped
        lyrics = misc.unescape_html(lyrics).replace('&', '&amp;')

        try:
            attr_list, plain_text, accel_marker = pango.parse_markup(lyrics)
        except:
            # failed to parse, use lyrics as it is
            lyrics_buf.set_text(lyrics)
            return

        attr_iter = attr_list.get_iterator()

        while True:
            range = attr_iter.range()
            font = attr_iter.get_font()[0]
            text = plain_text[range[0]:range[1]]

            tags = []
            if font.get_weight() == pango.WEIGHT_BOLD:
                tags.append('bold')
            if font.get_style() == pango.STYLE_ITALIC:
                tags.append('italic')

            if tags:
                lyrics_buf.insert_with_tags_by_name(lyrics_buf.get_end_iter(),
                                                    text, *tags)
            else:
                lyrics_buf.insert(lyrics_buf.get_end_iter(), text)

            if not attr_iter.next():
                break
コード例 #19
0
ファイル: info.py プロジェクト: BackupTheBerlios/sonata-svn
	def get_lyrics_thread(self, search_artist, search_title, filename_artist, filename_title, song_dir):
		filename_artist = misc.strip_all_slashes(filename_artist)
		filename_title = misc.strip_all_slashes(filename_title)
		filename = self.info_check_for_local_lyrics(filename_artist, filename_title, song_dir)
		search_str = misc.link_markup(_("search"), True, True, self.linkcolor)
		edit_str = misc.link_markup(_("edit"), True, True, self.linkcolor)
		if filename:
			# If the lyrics only contain "not found", delete the file and try to
			# fetch new lyrics. If there is a bug in Sonata/SZI/LyricWiki that
			# prevents lyrics from being found, storing the "not found" will
			# prevent a future release from correctly fetching the lyrics.
			f = open(filename, 'r')
			lyrics = f.read()
			f.close()
			if lyrics == _("Lyrics not found"):
				misc.remove_file(filename)
				filename = self.info_check_for_local_lyrics(filename_artist, filename_title, song_dir)
		if filename:
			# Re-use lyrics from file:
			f = open(filename, 'r')
			lyrics = f.read()
			f.close()
			# Strip artist - title line from file if it exists, since we
			# now have that information visible elsewhere.
			header = filename_artist + " - " + filename_title + "\n\n"
			if lyrics[:len(header)] == header:
				lyrics = lyrics[len(header):]
			gobject.idle_add(self.info_show_lyrics, lyrics, filename_artist, filename_title)
			gobject.idle_add(self.info_searchlabel.set_markup, search_str)
			gobject.idle_add(self.info_editlyricslabel.set_markup, edit_str)
		else:
			# Use default filename:
			filename = self.target_lyrics_filename(filename_artist, filename_title, song_dir)
			# Fetch lyrics from lyricwiki.org
			gobject.idle_add(self.info_show_lyrics, _("Fetching lyrics..."), filename_artist, filename_title)
			if self.lyricServer is None:
				wsdlFile = "http://lyricwiki.org/server.php?wsdl"
				try:
					self.lyricServer = True
					timeout = socketgettimeout()
					socketsettimeout(consts.LYRIC_TIMEOUT)
					self.lyricServer = ServiceProxy.ServiceProxy(wsdlFile, cachedir=os.path.expanduser("~/.service_proxy_dir")) 
				except:
					socketsettimeout(timeout)
					lyrics = _("Couldn't connect to LyricWiki")
					gobject.idle_add(self.info_show_lyrics, lyrics, filename_artist, filename_title)
					self.lyricServer = None
					gobject.idle_add(self.info_searchlabel.set_markup, search_str)
					gobject.idle_add(self.info_editlyricslabel.set_markup, edit_str)
					return
			try:
				timeout = socketgettimeout()
				socketsettimeout(consts.LYRIC_TIMEOUT)
				lyrics = self.lyricServer.getSong(artist=self.lyricwiki_format(search_artist), song=self.lyricwiki_format(search_title))['return']["lyrics"]
				if lyrics.lower() != "not found":
					lyrics = misc.unescape_html(lyrics)
					lyrics = misc.wiki_to_html(lyrics)
					lyrics = lyrics.encode("ISO-8859-1")
					gobject.idle_add(self.info_show_lyrics, lyrics, filename_artist, filename_title)
					# Save lyrics to file:
					misc.create_dir('~/.lyrics/')
					f = open(filename, 'w')
					lyrics = misc.unescape_html(lyrics)
					try:
						f.write(lyrics.decode(self.enc).encode('utf8'))
					except:
						f.write(lyrics)
					f.close()
				else:
					lyrics = _("Lyrics not found")
					gobject.idle_add(self.info_show_lyrics, lyrics, filename_artist, filename_title)
			except:
				lyrics = _("Fetching lyrics failed")
				gobject.idle_add(self.info_show_lyrics, lyrics, filename_artist, filename_title)
			gobject.idle_add(self.info_searchlabel.set_markup, search_str)
			gobject.idle_add(self.info_editlyricslabel.set_markup, edit_str)
			socketsettimeout(timeout)
コード例 #20
0
ファイル: info.py プロジェクト: BackupTheBerlios/sonata-svn
 def get_lyrics_thread(self, search_artist, search_title, filename_artist,
                       filename_title, song_dir):
     filename_artist = misc.strip_all_slashes(filename_artist)
     filename_title = misc.strip_all_slashes(filename_title)
     filename = self.info_check_for_local_lyrics(filename_artist,
                                                 filename_title, song_dir)
     search_str = misc.link_markup(_("search"), True, True, self.linkcolor)
     edit_str = misc.link_markup(_("edit"), True, True, self.linkcolor)
     if filename:
         # If the lyrics only contain "not found", delete the file and try to
         # fetch new lyrics. If there is a bug in Sonata/SZI/LyricWiki that
         # prevents lyrics from being found, storing the "not found" will
         # prevent a future release from correctly fetching the lyrics.
         f = open(filename, 'r')
         lyrics = f.read()
         f.close()
         if lyrics == _("Lyrics not found"):
             misc.remove_file(filename)
             filename = self.info_check_for_local_lyrics(
                 filename_artist, filename_title, song_dir)
     if filename:
         # Re-use lyrics from file:
         f = open(filename, 'r')
         lyrics = f.read()
         f.close()
         # Strip artist - title line from file if it exists, since we
         # now have that information visible elsewhere.
         header = filename_artist + " - " + filename_title + "\n\n"
         if lyrics[:len(header)] == header:
             lyrics = lyrics[len(header):]
         gobject.idle_add(self.info_show_lyrics, lyrics, filename_artist,
                          filename_title)
         gobject.idle_add(self.info_searchlabel.set_markup, search_str)
         gobject.idle_add(self.info_editlyricslabel.set_markup, edit_str)
     else:
         # Use default filename:
         filename = self.target_lyrics_filename(filename_artist,
                                                filename_title, song_dir)
         # Fetch lyrics from lyricwiki.org
         gobject.idle_add(self.info_show_lyrics, _("Fetching lyrics..."),
                          filename_artist, filename_title)
         if self.lyricServer is None:
             wsdlFile = "http://lyricwiki.org/server.php?wsdl"
             try:
                 self.lyricServer = True
                 timeout = socketgettimeout()
                 socketsettimeout(consts.LYRIC_TIMEOUT)
                 self.lyricServer = ServiceProxy.ServiceProxy(
                     wsdlFile,
                     cachedir=os.path.expanduser("~/.service_proxy_dir"))
             except:
                 socketsettimeout(timeout)
                 lyrics = _("Couldn't connect to LyricWiki")
                 gobject.idle_add(self.info_show_lyrics, lyrics,
                                  filename_artist, filename_title)
                 self.lyricServer = None
                 gobject.idle_add(self.info_searchlabel.set_markup,
                                  search_str)
                 gobject.idle_add(self.info_editlyricslabel.set_markup,
                                  edit_str)
                 return
         try:
             timeout = socketgettimeout()
             socketsettimeout(consts.LYRIC_TIMEOUT)
             lyrics = self.lyricServer.getSong(
                 artist=self.lyricwiki_format(search_artist),
                 song=self.lyricwiki_format(
                     search_title))['return']["lyrics"]
             if lyrics.lower() != "not found":
                 lyrics = misc.unescape_html(lyrics)
                 lyrics = misc.wiki_to_html(lyrics)
                 lyrics = lyrics.encode("ISO-8859-1")
                 gobject.idle_add(self.info_show_lyrics, lyrics,
                                  filename_artist, filename_title)
                 # Save lyrics to file:
                 misc.create_dir('~/.lyrics/')
                 f = open(filename, 'w')
                 lyrics = misc.unescape_html(lyrics)
                 try:
                     f.write(lyrics.decode(self.enc).encode('utf8'))
                 except:
                     f.write(lyrics)
                 f.close()
             else:
                 lyrics = _("Lyrics not found")
                 gobject.idle_add(self.info_show_lyrics, lyrics,
                                  filename_artist, filename_title)
         except:
             lyrics = _("Fetching lyrics failed")
             gobject.idle_add(self.info_show_lyrics, lyrics,
                              filename_artist, filename_title)
         gobject.idle_add(self.info_searchlabel.set_markup, search_str)
         gobject.idle_add(self.info_editlyricslabel.set_markup, edit_str)
         socketsettimeout(timeout)