This file is indexed.

/usr/share/weechat/python/lastfm.py is in weechat-scripts 20111030-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"""
    lastfm.py

    author: Adam Saponara <saponara TA gmail TOD com>
      desc: Sends your latest Last.fm track to the current buffer
     usage:
       /set plugins.var.python.lastfm.lastfm_username yourusername
       /lastfm
   license: GPLv3

   history:

       0.3 - 2011-03-11, Sebastien Helleu <flashcode@flashtux.org>:
             get python 2.x binary for hook_process (fix problem when
             python 3.x is default python version)

       0.2 - using hook_process for last.fm call (prevents hang)
           - using ?limit=1 in last.fm call (faster, more efficient)

       0.1 - initial script

"""

import weechat
import feedparser

weechat.register("lastfm", "Adam Saponara", "0.3", "GPL3", "Sends your latest Last.fm track to the current buffer", "", "")

defaults = {
        "lastfm_username" : "nobody",
        "command" : "/me is listening to %s"
}

cmd_hook_process = ""
cmd_buffer       = ""
cmd_stdout       = ""
cmd_stderr       = ""

for k, v in defaults.iteritems():
        if not weechat.config_is_set_plugin(k):
                weechat.config_set_plugin(k, v)

def lastfm_cmd(data, buffer, args):
        global cmd_hook_process, cmd_buffer, cmd_stdout, cmd_stderr
        if cmd_hook_process != "":
                weechat.prnt(buffer, "Lastfm is already running!")
                return weechat.WEECHAT_RC_OK
        cmd_buffer = buffer
        cmd_stdout = ""
        cmd_stderr = ""
        python2_bin = weechat.info_get("python2_bin", "") or "python"
        cmd_hook_process = weechat.hook_process(
                python2_bin + " -c \"\n"
                "import sys, feedparser\n"
                "feed = None\n"
                "feed = feedparser.parse('http://ws.audioscrobbler.com/1.0/user/%(username)s/recenttracks.rss?limit=1')\n"
                "if not feed or feed.bozo:\n"
                "	print >>sys.stderr, 'Could not fetch Last.fm RSS feed.',\n"
                "elif not 'items' in feed or len(feed['items']) < 1:\n"
                "	print >>sys.stderr, 'No tracks found in Last.fm RSS feed.',\n"
                "else:\n" 
                "	print feed['items'][0]['title'].replace(u'\u2013', '-').encode('ascii', 'replace'),\n"
                "\"" % {"username" : weechat.config_get_plugin('lastfm_username')},
                10000, "lastfm_cb", "")
        return weechat.WEECHAT_RC_OK

def lastfm_cb(data, command, rc, stdout, stderr):
        global cmd_hook_process, cmd_buffer, cmd_stdout, cmd_stderr
        cmd_stdout += stdout
        cmd_stderr += stderr
        if int(rc) >= 0:
                if cmd_stderr != "":
                        weechat.prnt(cmd_buffer, "%s" % cmd_stderr)
                if cmd_stdout != "":
                        weechat.command(cmd_buffer, weechat.config_get_plugin("command") % cmd_stdout)
                cmd_hook_process = ""
        return weechat.WEECHAT_RC_OK

hook = weechat.hook_command(
        "lastfm",
        "Sends your latest Last.fm track to the current buffer. Before using /lastfm, set your Last.fm username like this:\n\n"
        "    /set plugins.var.python.lastfm.lastfm_username yourusername\n\n"
        "You can also customize the command that will be sent to the buffer like this:\n\n"
        "    /set plugins.var.python.lastfm.command Right now I'm listening to %s\n",
        "", "", "", "lastfm_cmd", "")