Created
May 15, 2014 15:25
-
-
Save ysakasin/36afa99819a3cedd28cf to your computer and use it in GitHub Desktop.
Twitterクライアント'Shrimp'のNow playingプラグイン
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
class ShrimpPlugin | |
def initialize() | |
end | |
def OnInitialize(plugin) | |
plugin.PluginName = 'Now playing' | |
plugin.PluginDeveloper = 'NKMR_YA' | |
plugin.PluginVersion = 100 | |
plugin.PluginDescription = 'foobar2000で再生中の音楽または入力した曲名を変形します' | |
end | |
def OnCreateTweetBoxMenu(hook) | |
hook.OnClickedMenu = Proc.new do |data| | |
data.text = nowPlaying(data.text) | |
end | |
hook.text = 'Now playing' | |
end | |
def windowTitle() | |
proc = System::Diagnostics::Process.GetProcessesByName('foobar2000') | |
if proc.length != 0 | |
"#{proc[0].MainWindowTitle}" | |
else | |
nil | |
end | |
end | |
def musicTitle() | |
title = windowTitle() | |
if title | |
title.sub!(/^.*?\[.*?\]/, '') | |
title.sub!(/\[.*?\]$/, '') | |
title.strip! | |
end | |
title | |
end | |
def nowPlaying(text) | |
title = musicTitle() || text | |
"NowPlaying: #{title} #nowPlaying" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment