Beispiel #1
0
    def __search(self, song, buffer, refresh, add):
        artist = song.comma("artist")
        title = song.comma("title")

        try:
            sock = urlopen(
                "http://lyricwiki.org/api.php?"
                "client=QuodLibet&func=getSong&artist=%s&song=%s&fmt=text" % (
                quote(artist.encode('utf-8')),
                quote(title.encode('utf-8'))))
            text = sock.read()
        except Exception as err:
            encoding = util.get_locale_encoding()
            try:
                err = err.strerror.decode(encoding, 'replace')
            except:
                err = _("Unable to download lyrics.")
            GLib.idle_add(buffer.set_text, err)
            return

        sock.close()

        if text == 'Not found':
            GLib.idle_add(
                buffer.set_text, _("No lyrics found for this song."))
            return
        else:
            GLib.idle_add(buffer.set_text, text)
            GLib.idle_add(refresh.set_sensitive, True)
Beispiel #2
0
 def plugin_songs(self, songs):
     if not self.selected_tag:
         return
     l = dict.fromkeys([song(self.selected_tag) for song in songs]).keys()
     # If no tags values were found, show an error dialog
     if list(l) == ['']:
         ErrorMessage(app.window, _('Search failed'),
                      _('Tag "%s" not found.') % self.selected_tag).run()
         return
     for a in l:
         # Only search for non-empty tags
         if a:
             a = quote(str(a).title().replace(' ', '_'))
             util.website(WIKI_URL % get_lang() + a)
Beispiel #3
0
def escape_filename(s):
    """Escape a string in a manner suitable for a filename.

    Args:
        s (text_type)
    Returns:
        fsnative
    """

    s = text_type(s)
    s = quote(s.encode("utf-8"), safe=b"")
    if isinstance(s, text_type):
        s = s.encode("ascii")
    return bytes2fsn(s, "utf-8")
Beispiel #4
0
def escape_filename(s):
    """Escape a string in a manner suitable for a filename.

    Args:
        s (text_type)
    Returns:
        fsnative
    """

    s = text_type(s)
    s = quote(s.encode("utf-8"), safe=b"")
    if isinstance(s, text_type):
        s = s.encode("ascii")
    return bytes2fsn(s, "utf-8")
Beispiel #5
0
    def __search(self, song, buffer, refresh, add):
        artist = song.comma("artist")
        title = song.comma("title")

        try:
            sock = urlopen(
                "http://lyricwiki.org/api.php?"
                "client=QuodLibet&func=getSong&artist=%s&song=%s&fmt=text" %
                (quote(artist.encode('utf-8')), quote(title.encode('utf-8'))))
            text = sock.read()
        except Exception as err:
            util.print_exc()
            GLib.idle_add(buffer.set_text, text_type(err))
            return

        sock.close()

        if text == 'Not found':
            GLib.idle_add(buffer.set_text, _("No lyrics found for this song."))
            return
        else:
            GLib.idle_add(buffer.set_text, text)
            GLib.idle_add(refresh.set_sensitive, True)
Beispiel #6
0
 def change_song(self, path):
     """Queue up a song"""
     self.player_request("playlist clear")
     self.player_request("playlist insert %s" % (quote(path)))
Beispiel #7
0
 def change_song(self, path):
     """Queue up a song"""
     self.player_request("playlist clear")
     self.player_request("playlist insert %s" % (quote(path)))
Beispiel #8
0
 def playlist_resume(self, name, resume, wipe=False):
     cmd = ("playlist resume %s noplay:%d wipePlaylist:%d" %
            (quote(name), int(not resume), int(wipe)))
     self.player_request(cmd, want_reply=False)
Beispiel #9
0
 def playlist_save(self, name):
     self.player_request("playlist save %s" % (quote(name)), False)
Beispiel #10
0
 def playlist_add(self, path):
     self.player_request("playlist add %s" % (quote(path)), False)
Beispiel #11
0
def create_api_search_url(song):
    artist, title = song("artist"), song("title")
    artist = quote(artist.encode('utf-8'))
    title = quote(title.encode('utf-8'))

    return LYRICS_WIKIA_URL % (artist, title)
Beispiel #12
0
    def __view_online(self, add, song):
        artist = song.comma('artist').encode('utf-8')
        title = song.comma('title').encode('utf-8')

        util.website("http://lyrics.wikia.com/%s:%s"
                     % (quote(artist), quote(title)))
Beispiel #13
0
 def playlist_resume(self, name, resume, wipe=False):
     cmd = ("playlist resume %s noplay:%d wipePlaylist:%d"
            % (quote(name), int(not resume), int(wipe)))
     self.player_request(cmd, want_reply=False)
Beispiel #14
0
 def playlist_save(self, name):
     self.player_request("playlist save %s" % (quote(name)), False)
Beispiel #15
0
 def playlist_add(self, path):
     self.player_request("playlist add %s" % (quote(path)), False)
Beispiel #16
0
 def playlist_play(self, path):
     """Play song immediately"""
     self.player_request("playlist play %s" % (quote(path)))
Beispiel #17
0
 def plugin_songs(self, songs):
     l = dict.fromkeys([song(self.k) for song in songs]).keys()
     for a in l:
         a = quote(str(a).title().replace(' ', '_'))
         website(WIKI_URL % get_lang() + a)
Beispiel #18
0
 def plugin_songs(self, songs):
     l = dict.fromkeys([song(self.k) for song in songs]).keys()
     for a in l:
         a = quote(str(a).title().replace(' ', '_'))
         website(WIKI_URL % get_lang() + a)
Beispiel #19
0
def create_api_search_url(song):
    artist, title = song("artist"), song("title")
    artist = quote(artist.encode('utf-8'))
    title = quote(title.encode('utf-8'))

    return LYRICS_WIKIA_URL % (artist, title)
Beispiel #20
0
    def __add(self, add, song):
        artist = song.comma('artist').encode('utf-8')

        util.website("http://lyricwiki.org/%s" % (quote(artist)))
Beispiel #21
0
    def __view_online(self, add, song):
        artist = song.comma('artist').encode('utf-8')
        title = song.comma('title').encode('utf-8')

        util.website("http://lyrics.wikia.com/%s:%s"
                     % (quote(artist), quote(title)))
Beispiel #22
0
 def playlist_play(self, path):
     """Play song immediately"""
     self.player_request("playlist play %s" % (quote(path)))
Beispiel #23
0
    def __add(self, add, song):
        artist = song.comma('artist').encode('utf-8')

        util.website("http://lyricwiki.org/%s" % (quote(artist)))