summaryrefslogtreecommitdiff
path: root/scripts/python
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2007-02-19 19:33:37 +0000
committerSebastien Helleu <flashcode@flashtux.org>2007-02-19 19:33:37 +0000
commit1dc994e5f6a4aff8bb047bc7d8c7b1f1c1eb08f0 (patch)
treed5250245d83d0c658f15a8636da93b6f6ca32fe8 /scripts/python
parent429167f032219d2b687ef8b877ceeaf62e30366c (diff)
downloadweechat-1dc994e5f6a4aff8bb047bc7d8c7b1f1c1eb08f0.zip
Added scripts last.fm.py and weexaile.py
Diffstat (limited to 'scripts/python')
-rw-r--r--scripts/python/last.fm.py56
-rw-r--r--scripts/python/weexaile.py53
2 files changed, 109 insertions, 0 deletions
diff --git a/scripts/python/last.fm.py b/scripts/python/last.fm.py
new file mode 100644
index 000000000..87256f7ce
--- /dev/null
+++ b/scripts/python/last.fm.py
@@ -0,0 +1,56 @@
+"""
+ :Author: Tim Schumacher <tim AT we-are-teh-b DOT org>
+
+ :What it does:
+ This script informs the active window of your last
+ submitted song at last.fm
+
+ :Usage:
+ /np - Displays your last submitted song.
+
+ :Configuration Variables:
+ ============= ==========================================
+ Variable name Meaning
+ ============= ==========================================
+ lastfmuser Your username at last.fm
+
+ Released under GPL licence.
+"""
+#!/usr/bin/python
+
+todo = """
+ - Realy check if a song was recent.
+ - Define 'recent' through a userdefinedvar
+ - Add more help
+
+"""
+
+import urllib
+import weechat as wc
+
+wc.register("lastfmnp", "0.2.1", "", "now playing for last.fm")
+
+def getLastSong(server, args):
+ """
+ Provides your last submitted song in last.fm to the actual context
+ """
+ user = wc.get_plugin_config("lastfmuser")
+ url = "http://ws.audioscrobbler.com/1.0/user/" + user + "/recenttracks.txt"
+ url_handle = urllib.urlopen(url)
+ lines = url_handle.readlines()
+ song = lines[0].split(",")[1].replace("\n","");
+ if song == '':
+ song = 'nothing :-)';
+ wc.command("np: " + song)
+ return 0
+
+
+wc.add_command_handler("np", "getLastSong")
+
+default = {
+ "lastfmuser": "timds235"
+}
+
+for k, v in default.items():
+ if not wc.get_plugin_config(k):
+ wc.set_plugin_config(k, v)
diff --git a/scripts/python/weexaile.py b/scripts/python/weexaile.py
new file mode 100644
index 000000000..bfab1f378
--- /dev/null
+++ b/scripts/python/weexaile.py
@@ -0,0 +1,53 @@
+#Author: Pablo Escobar <pablo__escobar AT tlen DOT pl>
+#What it does: This script shows the currently played song in exaile
+#Usage: /weexaile - Displays the songname
+#Released under GNU GPL v2 or newer
+
+#/usr/bin/python
+#coding: utf-8
+
+import weechat
+import re
+import codecs
+from os import popen
+
+weechat.register ('exaile', '0.01', '', """exaile-weechat current song script (usage: /weexaile)""")
+weechat.add_command_handler ('weexaile', 'show_it_to_them')
+
+default = {
+ "msg_head": "is playing",
+ "msg_tail": "with exaile",
+ "spacer": "★",
+ "colour_artist": "C03",
+ "colour_title": "C02",
+ "colour_lenght": "C05",
+ "colour_spacer": "C08",
+}
+
+for k, v in default.items():
+ if not weechat.get_plugin_config(k):
+ weechat.set_plugin_config(k, v)
+
+def show_it_to_them(server, args):
+ spacer = weechat.get_plugin_config("spacer")
+ msg_tail = weechat.get_plugin_config("msg_tail")
+ msg_head = weechat.get_plugin_config("msg_head")
+ colour_artist = weechat.get_plugin_config("colour_artist")
+ colour_title = weechat.get_plugin_config("colour_title")
+ colour_lenght = weechat.get_plugin_config("colour_lenght")
+ colour_spacer = weechat.get_plugin_config("colour_spacer")
+ exaile_running = popen ('exaile --get-title')
+ exaile_running_text = exaile_running.readline().rstrip()
+ if exaile_running_text != "No running Exaile instance found.":
+ song_name = popen ('exaile --get-title')
+ song_name_text = song_name.readline().rstrip()
+ song_artist = popen ('exaile --get-artist')
+ song_artist_text = song_artist.readline().rstrip()
+ song_length = popen ('exaile --get-length')
+ song_length_text = song_length.readline().rstrip()
+ song_current = popen ('exaile --current-position')
+ song_current_text = str(round(float(song_current.readline().rstrip()),2))
+ all = '/me ' + msg_head + ' %' + colour_title + song_name_text + ' %' + colour_spacer + spacer + ' %' + colour_artist + song_artist_text + ' %' + colour_spacer + spacer + ' %' + colour_lenght + song_length_text + " (" + song_current_text + "%)" + " %C00" + msg_tail
+ weechat.command(all)
+ return 0
+