Skip to content

Instantly share code, notes, and snippets.

@ysakasin
Created May 15, 2014 15:25
Show Gist options
  • Save ysakasin/36afa99819a3cedd28cf to your computer and use it in GitHub Desktop.
Save ysakasin/36afa99819a3cedd28cf to your computer and use it in GitHub Desktop.
Twitterクライアント'Shrimp'のNow playingプラグイン
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