Created
April 4, 2014 01:54
-
-
Save IzumiSy/9966572 to your computer and use it in GitHub Desktop.
Plugin for radiotray
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[RadioTrayPlugin] | |
name=Website Jumper | |
desc=Open the website of the current radio | |
script=WebsiteJumper.py | |
class=WebsiteJumper | |
author=Seiya IZUMI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from events.EventSubscriber import EventSubscriber | |
from events.EventManager import EventManager | |
from Plugin import Plugin | |
import webbrowser | |
class WebsiteJumper(Plugin): | |
# 初期化時に実行される関数 | |
def __init__(self): | |
super(WebsiteJumper, self).__init__() | |
# 何に使うのかはわからないが必要らしい | |
def getName(self): | |
return self.name | |
# プラグインの設定から有効化されたときに実行される関数 | |
def activate(self): | |
# SONG_CHANGEDにフックする関数を登録 | |
self.eventSubscriber.bind(EventManager.SONG_CHANGED, self.on_song_changed) | |
# プラグインメニューに登録 | |
self.tooltip.addSource(self.def_tooltip) | |
# プラグインのメニューに表示するために必要な関数 | |
def hasMenuItem(self): | |
return True | |
# メニューに登録する名前を返す | |
def def_tooltip(self): | |
return "Website Jumper" | |
# SONG_CHANGEDにフックされる関数 | |
def on_song_changed(self, data): | |
global location | |
if ('location' in data.keys()): | |
location = data['location'] | |
# メニューから選択された場合の処理 | |
def on_menu(self, data): | |
print "[WebsiteJumper] open %s" % (location) | |
webbrowser.open(location) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment