読者です 読者をやめる 読者になる 読者になる

りんごの備忘録

へなちょこポカ大生のへなちょこブログ

AppleScriptで聞いている曲をTwitterに呟くまで

Twitterで今聞いてる曲を#nowplayingとして呟きたい!!でもサードーパーティーで最適なアプリケーションが見つからない.それならば作ってしまえばいいのだ,ということでAppleScriptを使って作ってみた.
確実に前回の記事と順番を間違えた
今回もPashuaと
www.bluem.net
Twitter Scripterを使わせてもらいました
www.mousedown.net
Pashuaをダウンロード,解凍すると"Pashua.scpt"と"Pashua.app"の二つを探してApplicationのフォルダにぶち込んでおく

Pashua.scptをそのまま使うと不具合が起こる場合があるので下記の部分を修正しておく(原因は調べた気がするが忘れた)

tell application "Finder" to delete tmpfile

                      ⬇︎

tell application "Finder"
	delete tmpfile
end tell

PashuaとTwitterScripterを組み合わせるとこのようになった.Pictureフォルダにはアートワークがない場合の別の画像を用意しておいた.(名前はcover_not.png)

global sendText
tell application "iTunes"
	set theArtist to artist of current track
	set theAlbum to album of current track
	set theName to name of current track
	set sendText to "♪" & theArtist & "/" & theName & " /" & theAlbum & " #nowplaying" as text
	if (count of artwork of current track) ≥ 1 then
		set artworkExists to true
		set anArtwork to raw data of artwork 1 of current track
		tell application "iTunes" to tell artwork 1 of current track
			set d to raw data
			if format is «class PNG » then
				set x to "png"
			else
				set x to "jpg"
			end if
		end tell
		(((path to pictures folder) as text) & "cover." & x)
		set b to open for access file result with write permission
		set eof b to 0
		write d to b
		close access b
	else
		set artworkExists to false
	end if
end tell

tell application "Finder"
	set appPath to (path to applications folder)
	set thisFolder to appPath as string
	if "Pashua:Pashua.app:" exists then
		-- Looks like the Pashua disk image is mounted. Run from there.
		set customLocation to "Pashua:"
	else
		-- Search for Pashua in the standard locations
		set customLocation to ""
	end if
end tell

try
	set thePath to alias (thisFolder & "Pashua.scpt")
	set pashuaBinding to load script thePath
	
	tell pashuaBinding
		-- Display the dialog
		
		try
			set pashuaLocation to getPashuaPath(customLocation)
			
			if artworkExists is true then
				set dialogConfiguration to my getDialogConfiguration((((path to pictures folder) as text) & "cover." & x))
			else
				set dialogConfiguration to my getDialogConfiguration((((path to pictures folder) as text) & "cover_not.png"))
				
			end if
			
			set theResult to showDialog(dialogConfiguration, customLocation)
			if {} = theResult then
				
			else if cb of theResult is not "1" then
				tell application "Twitter Scripter"
					if artworkExists is true then
						tweet sendText & return & tf of theResult using account pop of theResult with image (((path to pictures folder) as text) & "cover." & x)
					else if artworkExists is false then
						tweet sendText & return & tf of theResult using account pop of theResult
					end if
				end tell
				
			end if
		end try
	end tell
end try


-- Returns the configuration string for an example dialog
on getDialogConfiguration(pashuaLocation)
	
	if pashuaLocation is not "" then
		set img to "img.type = image
	          img.x = 320
	          img.y = 90
			  img.maxwidth = 128
			  img.tooltip = Album Art
	          img.path =" & (POSIX path of pashuaLocation) & return
	else
		set img to ""
	end if
	
	return "
# Set window title
*.title = Currently playing...

# Introductory text
txt.type = text
txt.label = Track/Album Info
txt.default =" & sendText & return & "
txt.height = 10
txt.width = 300
txt.x = 0
txt.y = 160
#txt.tooltip = This is an element of type “text”

# Add a cancel button with default label
cb.type = cancelbutton
cb.label = Cansel

# Add a text field
tf.type = textfield
tf.label = 
tf.default = 
tf.width = 300
tf.tooltip = This is an element of type “textfield”

# Add a popup menu
pop.type = popup
pop.label = Tweet Account
pop.width = 300
pop.option = 
pop.option = 
pop.default = 
pop.tooltip = This is an element of type “popup”

db.type = defaultbutton
db.label = Tweet
" & img
end getDialogConfiguration

AppleScriptで二次創作の原曲名を取得するまで

[東方の二次創作の曲を聴いても原曲名が思い出せない!!
そんなときいちいちwebで調べるのは面倒くさい.その手間を省くために原曲名を手軽に取得できるようにしてみた.ついでにtwitterに投稿するところまでやってみた.結局人の目を通す必要があるものになったのはご勘弁
さすがにAppleScriptのdisplay dialog には限界があったので,Carsten BlumさんのPashu,
www.bluem.net
twitterAPIは簡単に使えるようにするMousedownさんのtwitter scripter をありがたく使わせていただきました.
www.mousedown.net
いろんなサイトを参考にさせてもらいましたが備忘録をつける前に作ってしまっていたためほとんどメモしてなかったです...ごめんなさい....

global sendText1
global sendText2
--ここに東方の原曲名をぶち込む
set touhouOriginal to {"宇宙巫女現る", ¬
	"忘れがたき、よすがの緑", ¬
	"兎は舞い降りた", ¬
	"湖は浄めの月光を映して", ¬
	"九月のパンプキン", ¬
	"宇宙を飛ぶ不思議な巫女", ¬
	"永遠の春夢", ¬
	"凍り付いた永遠の都", ¬
	"逆転するホイールオブフォーチュン", ¬
	"遥か38万キロのボヤージュ", ¬
	"星条旗のピエロ", ¬
	"故郷の星が映る海", ¬
	"ピュアヒューリーズ ~ 心の在処", ¬
	"見た事も無い悪夢の世界", ¬
	"パンデモニックプラネット", ¬
	"神社から見える月", ¬
	"宇宙巫女帰還する", ¬
	"華狭間のバトルフィールド", ¬
	"ラストオカルティズム ~ 現し世の秘術師", ¬
	"弾幕アマノジャク ~ Impossible Spell Card.", ¬
	"反則の狼煙を上げろ", ¬
	"不可能弾幕には反則を", ¬
	"ミッドナイトスペルカード", ¬
	"ロマンチック逃飛行", ¬
	"永遠の三日天下", ¬
	"幻想浄瑠璃", ¬
	"妖怪の山 ~ Mysterious Mountain", ¬
	"不思議なお祓い棒", ¬
	"ミストレイク", ¬
	"秘境のマーメイド", ¬
	"運河を行き交う人妖", ¬
	"柳の下のデュラハン", ¬
	"満月の竹林", ¬
	"孤独なウェアウルフ", ¬
	"マジカルストーム", ¬
	"空中に沈む輝針城", ¬
	"リバースイデオロギー", ¬
	"針小棒大の天守閣", ¬
	"輝く針の小人族 ~ Little Princess", ¬
	"魔力の雷雲", ¬
	"始原のビート ~ Pristine Beat", ¬
	"小槌の魔力", ¬
	"不思議な不思議な道具達", ¬
	"プレイヤーズスコア", ¬
	"幻想郷の二ッ岩", ¬
	"亡失のエモーション", ¬
	"欲深き霊魂", ¬
	"死霊の夜桜", ¬
	"ゴーストリード", ¬
	"妖怪寺へようこそ", ¬
	"門前の妖怪小娘", ¬
	"素敵な墓場で暮しましょ", ¬
	"リジッドパラダイス", ¬
	"デザイアドライブ", ¬
	"古きユアンシェン", ¬
	"夢殿大祀廟", ¬
	"大神神話伝", ¬
	"小さな欲望の星空", ¬
	"聖徳伝説 ~ True Administrator", ¬
	"妖怪裏参道", ¬
	"佐渡の二ッ岩", ¬
	"神社の新しい風", ¬
	"デザイアドリーム", ¬
	"春の氷精", ¬
	"可愛い大戦争のリフレーン", ¬
	"いたずらに命をかけて", ¬
	"年中夢中の好奇心", ¬
	"真夜中のフェアリーダンス", ¬
	"妖精大戦争 ~ Fairy Wars", ¬
	"ルーズレイン", ¬
	"メイガスナイト", ¬
	"春の氷精 - 静 -", ¬
	"ニュースハウンド", ¬
	"あなたの町の怪事件", ¬
	"妖怪モダンコロニー", ¬
	"ネメシスの要塞", ¬
	"無間の鐘 ~ Infinite Nightmare", ¬
	"アンノウンX ~ Unfound Adventure", ¬
	"空に浮かぶ物体X", ¬
	"青空の影", ¬
	"春の湊に", ¬
	"小さな小さな賢将", ¬
	"閉ざせし雲の通い路", ¬
	"万年置き傘にご注意を", ¬
	"スカイルーイン", ¬
	"時代親父とハイカラ少女", ¬
	"幽霊客船の時空を越えた旅", ¬
	"キャプテン・ムラサ", ¬
	"魔界地方都市エソテリア", ¬
	"虎柄の毘沙門天", ¬
	"法界の火", ¬
	"感情の摩天楼 ~ Cosmic Mind", ¬
	"夜空のユーフォーロマンス", ¬
	"平安のエイリアン", ¬
	"妖怪寺", ¬
	"空の帰り道 ~ Sky Dream", ¬
	"地霊達の起床", ¬
	"暗闇の風穴", ¬
	"封じられた妖怪 ~ Lost Place", ¬
	"渡る者の途絶えた橋", ¬
	"緑眼のジェラシー", ¬
	"旧地獄街道を行く", ¬
	"華のさかづき大江山", ¬
	"ハートフェルトファンシー", ¬
	"少女さとり ~ 3rd eye", ¬
	"廃獄ララバイ", ¬
	"死体旅行 ~ Be of good cheer!", ¬
	"業火マントル", ¬
	"霊知の太陽信仰 ~ Nuclear Fusion", ¬
	"ラストリモート", ¬
	"ハルトマンの妖怪少女", ¬
	"地霊達の帰宅", ¬
	"エネルギー黎明 ~ Future Dream...", ¬
	"黒い海に紅く ~ Legendary Fish", ¬
	"有頂天変 ~ Wonderful Heaven", ¬
	"幼心地の有頂天", ¬
	"封印されし神々", ¬
	"人恋し神様 ~ Romantic Fall", ¬
	"稲田姫様に叱られるから", ¬
	"厄神様の通り道 ~ Dark Road", ¬
	"運命のダークサイド", ¬
	"神々が恋した幻想郷", ¬
	"芥川龍之介の河童 ~ Candid Friend", ¬
	"フォールオブフォール ~ 秋めく滝", ¬
	"少女が見た日本の原風景", ¬
	"信仰は儚き人間の為に", ¬
	"御柱の墓場 ~ Grave of Being", ¬
	"神さびた古戦場 ~ Suwa Foughten Field", ¬
	"明日ハレの日、ケの昨日", ¬
	"ネイティブフェイス", ¬
	"麓の神社", ¬
	"神は恵みの雨を降らす ~ Sylphid Dream", ¬
	"天狗の手帖 ~ Mysterious Note", ¬
	"風の循環 ~ Wind Tour", ¬
	"天狗が見ている ~ Black Eyes", ¬
	"東の国の眠らない夜", ¬
	"レトロスペクティブ京都", ¬
	"風神少女", ¬
	"花映塚 ~ Higan Retour", ¬
	"春色小径 ~ Colorful Path", ¬
	"オリエンタルダークフライト", ¬
	"フラワリングナイト", ¬
	"東方妖々夢 ~ Ancient Temple", ¬
	"狂気の瞳 ~ Invisible Full Moon", ¬
	"おてんば恋娘の冒険", ¬
	"幽霊楽団 ~ Phantom Ensemble", ¬
	"もう歌しか聞こえない ~ Flower Mix", ¬
	"お宇佐さまの素い幡", ¬
	"風神少女  (Short Version)", ¬
	"ポイズンボディ ~ Forsaken Doll", ¬
	"今昔幻想郷 ~ Flower Land", ¬
	"彼岸帰航 ~ Riverside View", ¬
	"六十年目の東方裁判 ~ Fate of Sixty Years", ¬
	"花の映る塚", ¬
	"此岸の塚", ¬
	"花は幻想のままに", ¬
	"魂の花 ~ Another Dream...", ¬
	"永夜抄 ~ Eastern Night", ¬
	"幻視の夜 ~ Ghostly Eyes", ¬
	"蠢々秋月 ~ Mooned Insect", ¬
	"夜雀の歌声 ~ Night Bird", ¬
	"もう歌しか聞こえない", ¬
	"懐かしき東方の血 ~ Old World", ¬
	"プレインエイジア", ¬
	"永夜の報い ~ Imperishable Night", ¬
	"少女綺想曲 ~ Dream Battle", ¬
	"恋色マスタースパーク", ¬
	"シンデレラケージ ~ Kagome-Kagome", ¬
	"ヴォヤージュ1969", ¬
	"千年幻想郷 ~ History of the Moon", ¬
	"竹取飛翔 ~ Lunatic Princess", ¬
	"ヴォヤージュ1970", ¬
	"エクステンドアッシュ ~ 蓬莱人", ¬
	"月まで届け、不死の煙", ¬
	"月見草", ¬
	"Eternal Dream ~ 幽玄の槭樹", ¬
	"東方妖怪小町", ¬
	"Demystify Feast", ¬
	"夜が降りてくる ~ Evening Star", ¬
	"御伽の国の鬼が島 ~ Missing Power", ¬
	"妖々夢 ~ Snow or Cherry Petal", ¬
	"無何有の郷 ~ Deep Mountain", ¬
	"クリスタライズシルバー", ¬
	"遠野幻想物語", ¬
	"ティアオイエツォン(withered leaf)", ¬
	"ブクレシュティの人形師", ¬
	"人形裁判 ~ 人の形弄びし少女", ¬
	"天空の花の都", ¬
	"広有射怪鳥事 ~ Till When?", ¬
	"アルティメットトゥルース", ¬
	"幽雅に咲かせ、墨染の桜 ~ Border of Life", ¬
	"ボーダーオブライフ", ¬
	"妖々跋扈", ¬
	"少女幻葬 ~ Necro-Fantasy", ¬
	"妖々跋扈 ~ Who done it!", ¬
	"ネクロファンタジア", ¬
	"春風の夢", ¬
	"さくらさくら ~ Japanize Dream...", ¬
	"赤より紅い夢", ¬
	"ほおずきみたいに紅い魂", ¬
	"妖魔夜行", ¬
	"ルーネイトエルフ", ¬
	"おてんば恋娘", ¬
	"上海紅茶館 ~ Chinese Tea", ¬
	"明治十七年の上海アリス", ¬
	"ヴワル魔法図書館", ¬
	"ラクトガール ~ 少女密室", ¬
	"メイドと血の懐中時計", ¬
	"月時計 ~ ルナ・ダイアル", ¬
	"ツェペシュの幼き末裔", ¬
	"亡き王女の為のセプテット", ¬
	"魔法少女達の百年祭", ¬
	"U.N.オーエンは彼女なのか?", ¬
	"紅より儚い永遠", ¬
	"紅楼 ~ Eastern Dream...", ¬
	"怪綺談 ~ Mystic Square", ¬
	"Dream Express", ¬
	"魔法陣 ~ Magic Square", ¬
	"夢想時空", ¬
	"霊天 ~ Spiritual Heaven", ¬
	"Romantic Children", ¬
	"プラスチックマインド", ¬
	"メイプルワイズ", ¬
	"禁断の魔法 ~ Forbidden Magic", ¬
	"真紅の少女 ~ Crimson Dead!!", ¬
	"裏切りの少女 ~ Judas Kiss", ¬
	"the Last Judgement", ¬
	"悲しき人形 ~ Doll of Misery", ¬
	"世界の果て ~ World's End", ¬
	"神話幻想 ~ Infinite Being", ¬
	"不思議の国のアリス", ¬
	"the Grimoire of Alice", ¬
	"神社", ¬
	"Endless", ¬
	"久遠の楽園", ¬
	"Mystic Dream", ¬
	"Peaceful Romancer", ¬
	"魂の休らむ所", ¬
	"幻想郷 ~ Lotus Land Story", ¬
	"Witching Dream", ¬
	"Selene's light", ¬
	"装飾戦 ~ Decoration Battle", ¬
	"Break the Sabbath", ¬
	"紅響曲 ~ Scarlet Phoneme", ¬
	"Bad Apple!!", ¬
	"霊戦 ~ Perdition crisis", ¬
	"アリスマエステラ", ¬
	"少女綺想曲 ~ Capriccio", ¬
	"星の器 ~ Casket of Star", ¬
	"Lotus Love", ¬
	"眠れる恐怖 ~ Sleeping Terror", ¬
	"Dream Land", ¬
	"幽夢 ~ Inanimate Dream", ¬
	"禁じざるをえない遊戯", ¬
	"メイド幻想 ~ Icemilk Magic", ¬
	"かわいい悪魔 ~ Innocence", ¬
	"Peaceful", ¬
	"Arcadian Dream", ¬
	"幻想の住人", ¬
	"東方怪綺談", ¬
	"Lotus Road", ¬
	"Dreamy pilot", ¬
	"Incomplete Plot", ¬
	"Border Land", ¬
	"Magic Shop of Raspberry", ¬
	"Crescent Dream", ¬
	"夢は時空を越えて", ¬
	"Selection", ¬
	"東方妖恋談", ¬
	"Reincarnation", ¬
	"Dim. Dream", ¬
	"Tabula rasa ~ 空白少女", ¬
	"Maniacal Princess", ¬
	"夢消失 ~ Lost Dream", ¬
	"夢幻遊戯 ~ Dream War", ¬
	"魔法決戦! ~ Fight it out!", ¬
	"Sailor of Time", ¬
	"Strawberry Crisis!!", ¬
	"非統一魔法世界論", ¬
	"魔法鐘愛", ¬
	"久遠の夢", ¬
	"東方の青い空", ¬
	"永遠の満月", ¬
	"Maple Dream...", ¬
	"霊人の休日", ¬
	"勝利デモ", ¬
	"ゲームオーバー", ¬
	"時の風", ¬
	"スターボウドリーム", ¬
	"Phantasmagoria", ¬
	"東方封魔録 ~浄土曼荼羅", ¬
	"博麗 ~Eastern Wind", ¬
	"She's in a temper!!", ¬
	"End of Daylight", ¬
	"やみのちから", ¬
	"幻夢界", ¬
	"死を賭して", ¬
	"ひもろぎ、むらさきにもえ", ¬
	"恋色マジック", ¬
	"東方封魔録 ~幽幻乱舞", ¬
	"Complete Darkness", ¬
	"エキストララブ", ¬
	"戦車むすめのみるゆめ", ¬
	"遠野の森", ¬
	"昔話わんだーらんど", ¬
	"博麗神社境内", ¬
	"陽落ちて", ¬
	"封魔終演", ¬
	"A Sacred Lot", ¬
	"風の神社", ¬
	"永遠の巫女", ¬
	"Highly Responsive to Prayers", ¬
	"東方怪奇談", ¬
	"Oriental Magician", ¬
	"破邪の小太刀", ¬
	"The Legend of KAGE", ¬
	"The Positive and Negative", ¬
	"天使伝説", ¬
	"魔鏡", ¬
	"いざ、倒れ逝くその時まで", ¬
	"死なばもろとも", ¬
	"星幽剣士", ¬
	"アイリス", ¬
	"the Legend of KAGE", ¬
	"Civilization of Magic", ¬
	"星幽天使", ¬
	"秋霜玉 ~ Clockworks", ¬
	"フォルスストロベリー", ¬
	"プリムローズシヴァ", ¬
	"幻想帝都", ¬
	"ディザストラスジェミニ", ¬
	"華の幻想 紅夢の宙", ¬
	"天空アーミー", ¬
	"スプートニク幻夜", ¬
	"機械サーカス ~ Reverie", ¬
	"カナベラルの夢幻少女", ¬
	"魔法少女十字軍", ¬
	"アンティークテラー", ¬
	"夢機械 ~ Innocent Power", ¬
	"幻想科学 ~ Doll's Phantom", ¬
	"少女神性 ~ Pandora's Box", ¬
	"シルクロードアリス", ¬
	"魔女達の舞踏会 ~ Magus", ¬
	"二色蓮花蝶 ~ Ancients", ¬
	"ハーセルヴズ", ¬
	"タイトルドメイド", ¬
	"稀翁玉 ~ Fairy Dance", ¬
	"天鵞絨少女戦 ~ Velvet Battle", ¬
	"Castle Explorer -in the Sky", ¬
	"オルフェの詩 ~ Pseudoclassic", ¬
	"新幻想 ~ New Fantasy", ¬
	"オルレアンの聖騎士", ¬
	"My Maid, Sweet Maid", ¬
	"桜花之恋塚 ~ Flower of Japan", ¬
	"乙女戦士 ~ Heart of Valkyrie", ¬
	"エニグマティクドール ~ God Knows", ¬
	"トルテルマジック", ¬
	"Witch of Love Potion", ¬
	"Magical and Hopeless", ¬
	"Sacred Battle", ¬
	"呑んべぇのレムリア", ¬
	"神魔討綺伝 ~ Magus in Mystic Geometries", ¬
	"神魔討綺伝 AN ORDEAL FROM GOD", ¬
	"東方幻想麻雀", ¬
	"キュアリアス上海古牌", ¬
	"蓬莱人形 ~ Dolls in Pseudo Paradise", ¬
	"蓬莱伝説", ¬
	"二色蓮花蝶 ~ Red and White", ¬
	"桜花之恋塚 ~ Japanese Flower", ¬
	"エニグマティクドール", ¬
	"サーカスレヴァリエ", ¬
	"人形の森", ¬
	"リーインカーネイション", ¬
	"空飛ぶ巫女の不思議な毎日", ¬
	"蓮台野夜行 ~ Ghostly Field Club", ¬
	"夜のデンデラ野を逝く", ¬
	"少女秘封倶楽部", ¬
	"古の冥界寺", ¬
	"魔術師メリー", ¬
	"月の妖鳥、化猫の幻", ¬
	"過去の花 ~ Fairy of Flower", ¬
	"幻想の永遠祭", ¬
	"夢違科学世紀 ~ Changeability of Strange Dream", ¬
	"童祭 ~ Innocent Treasures", ¬
	"華胥の夢", ¬
	"科学世紀の少年少女", ¬
	"夢と現の境界", ¬
	"幻想機械 ~ Phantom Factory", ¬
	"幽玄の槭樹 ~ Eternal Dream", ¬
	"ヒロシゲ36号 ~ Neo Super-Express", ¬
	"53ミニッツの青い海", ¬
	"青木ヶ原の伝説", ¬
	"月まで届け不死の煙", ¬
	"最も澄みわたる空と海", ¬
	"月面ツアーへようこそ", ¬
	"天空のグリニッジ", ¬
	"車椅子の未来宇宙", ¬
	"衛星カフェテラス", ¬
	"G Free", ¬
	"大空魔術 ~ Magical Astronomy", ¬
	"向こう側の月", ¬
	"未知の花 魅知の旅", ¬
	"衛星トリフネ", ¬
	"トロヤ群の密林", ¬
	"フェアリー冒険譚", ¬
	"天鳥船神社", ¬
	"天鳥船神社の結界", ¬
	"宇宙に浮かぶ幻想郷", ¬
	"緑のサナトリウム", ¬
	"牛に引かれて善光寺参り", ¬
	"アガルタの風", ¬
	"イザナギオブジェクト", ¬
	"日本中の不思議を集めて", ¬
	"他愛も無い二人の博物誌", ¬
	"Dr.レイテンシーの眠れなくなる瞳", ¬
	"須臾はプランクを超えて", ¬
	"シュレディンガーの化猫", ¬
	"禁忌の膜壁", ¬
	"永遠の三日天下", ¬
	"東方幻想郷より", ¬
	"装飾戦 ~ Decoration Battle (未使用バージョン)", ¬
	"幽夢 ~ Inanimate Dream (未使用バージョン)", ¬
	"東方封魔録 ~ 浄土曼荼羅", ¬
	"博麗 ~ Eastern Wind", ¬
	"東方封魔録 ~ 幽幻乱舞", ¬
	"エキストララブ ", ¬
	"東方夢時空より", ¬
	"Tabula rasa", ¬
	"魔法決戦! ~ Fight it out!", ¬
	"テーマ・オブ・イースタンストーリー", ¬
	"花映塚", ¬
	"ジャパニーズサーガ", ¬
	"阿礼の子供", ¬
	"夜の鳩山を飛ぶ‐Power Mix", ¬
	"サニールチルフレクション", ¬
	"夜だから眠れない", ¬
	"妖精燦々として", ¬
	"サニーミルクの紅霧異変", ¬
	"雪月桜花の国", ¬
	"スターヴォヤージュ2008", ¬
	"二つの世界", ¬
	"神域のかくれんぼ暮らし", ¬
	"妖怪宇宙旅行", ¬
	"綿月のスペルカード ~ Lunatic Blue", ¬
	"呑んべぇのレムリア (Retro Ver)", ¬
	"六十年目の東方裁判", ¬
	"Cradle - 東方幻樂祀典 -", ¬
	"妖々跋扈 ~ Speed Fox!", ¬
	"The Grimoire of Marisa", ¬
	"魔法使いの憂鬱", ¬
	"宵闇の魔術師", ¬
	"Magic of Life", ¬
	"Plastic Space", ¬
	"Inventive City", ¬
	"夢幻回廊", ¬
	"蓬莱幻想 ~ far East", ¬
	"魔法少女十字軍 ~ Little Little Crusader", ¬
	"夜の鳩山を飛ぶ", ¬
	"Frontal Attack", ¬
	"少女綺想曲 ~ Dream Battle ", ¬
	"少女綺想曲 ~ Capriccio", ¬
	"春色小径 ", ¬
	"人形裁判", ¬
	"聖徳伝説", ¬
	"ポイズンボディ", ¬
	"永夜抄", ¬
	"砕月", ¬
	"遥か38万キロのボヤージュ"}

tell application "iTunes"
	set theName to name of current track
	set theArtist to artist of current track
	set theAlbum to album of current track
	set theComments to comment of current track
	--set theNameT to name of current track
end tell

set bRes to ""

if theComments is "" then
	set theName to reftheText(theName, {" (", " ~", " -"}) -- ()が曲名に入っている場合
	set theName to replaceText(theName, "'", "") --'が曲名に入っている場合
	set theName to replaceText(theName, "★", "☆")
	set theName to replaceText(theName, "♥", "")
	set html2 to googleSerch2(theName, theAlbum)
	set html2 to replaceText(html2, {"</em>", "<em>", "&#39;", "&#9829;"}, {"", "", "'", ""})
	set html1 to googleSerch1(theName, theArtist)
	set html1 to replaceText(html1, {"</em>", "<em>", "&#39;", "&#9829;"}, {"", "", "'", ""}) --余分文字の削除
	
	
	set theFirstCount to 60 --曲名の後の最初の文字数
	
	set theReturnOriginal to findOriginal(html1, html2, theName, theFirstCount, touhouOriginal)
	set bList to removeDuplicates(theReturnOriginal) of me
	if (count bList) is 1 then
		
		repeat with i in touhouOriginal
			if i contains theName or i is equal to theName then
				set end of bList to i
			end if
		end repeat
		tell application "Safari"
			tell application "System Events"
				--keystroke "w" using {option down, command down}
				--keystroke "h" using command down
			end tell
		end tell
		tell application "iTunes"
			set theArtist to artist of current track
			set theAlbum to album of current track
			set theName to name of current track
			set sendText1 to theArtist & "/" & theName & "『 " & theAlbum & "』" as text
			set sendText2 to " Original : " & item 1 of bList & "#nowplaying"
			if (count of artwork of current track) ≥ 1 then
				set artworkExists to true
				set anArtwork to raw data of artwork 1 of current track
				tell application "iTunes" to tell artwork 1 of current track
					set d to raw data
					if format is «class PNG » then
						set x to "png"
					else
						set x to "jpg"
					end if
				end tell
				(((path to pictures folder) as text) & "cover." & x)
				set b to open for access file result with write permission
				set eof b to 0
				write d to b
				close access b
			else
				set artworkExists to false
				
			end if
			set comment of current track to (item 1 of bList) as text
		end tell
		
	else
		
		repeat with i in touhouOriginal
			if i contains theName or i is equal to theName then
				set end of bList to i
			end if
		end repeat
		
		set bRes to choose from list bList with multiple selections allowed
		set mySelect to result
		tell application "Safari"
			activate
		end tell
		tell application "Safari"
			tell application "System Events"
				--keystroke "w" using {option down, command down}
				--keystroke "h" using command down
			end tell
		end tell
		tell application "iTunes"
			set theArtist to artist of current track
			set theAlbum to album of current track
			set theName to name of current track
			if mySelect is not false then
				
				set defaultDelimit to AppleScript's text item delimiters
				set AppleScript's text item delimiters to "&"
				set mySelect to mySelect as text
				set AppleScript's text item delimiters to defaultDelimit
				set comment of current track to mySelect
				
			end if
			if mySelect is not false then
				set sendText1 to theArtist & "/" & theName & "『 " & theAlbum & "』" as text
				set sendText2 to "Original:" & mySelect & " #nowplaying"
			else
				set sendText1 to theArtist & "/" & theName & "『 " & theAlbum & "』" as text
				set sendText2 to " #nowplaying"
				
			end if
			if (count of artwork of current track) ≥ 1 then
				set artworkExists to true
				set anArtwork to raw data of artwork 1 of current track
				tell application "iTunes" to tell artwork 1 of current track
					set d to raw data
					if format is «class PNG » then
						set x to "png"
					else
						set x to "jpg"
					end if
				end tell
				(((path to pictures folder) as text) & "cover." & x)
				set b to open for access file result with write permission
				set eof b to 0
				write d to b
				close access b
			else
				set artworkExists to false
				
			end if
		end tell
		
		
		
	end if
else
	tell application "iTunes"
		set theArtist to artist of current track
		set theAlbum to album of current track
		set theName to name of current track
		set theComments to comment of current track
		set sendText1 to theArtist & "/" & theName & "『 " & theAlbum & "』" as text
		set sendText2 to " Original : " & theComments & " #nowplaying"
		if (count of artwork of current track) ≥ 1 then
			set artworkExists to true
			set anArtwork to raw data of artwork 1 of current track
			tell application "iTunes" to tell artwork 1 of current track
				set d to raw data
				if format is «class PNG » then
					set x to "png"
				else
					set x to "jpg"
				end if
			end tell
			(((path to pictures folder) as text) & "cover." & x)
			set b to open for access file result with write permission
			set eof b to 0
			write d to b
			close access b
		else
			set artworkExists to false
			
		end if
	end tell
	
end if

--ここからPashuaの設定
--popupのところにtwitter scripter で登録したアカウント名を入れる
tell application "Finder"
	set appPath to (path to applications folder)
	set thisFolder to appPath as string
	if "Pashua:Pashua.app:" exists then
		-- Looks like the Pashua disk image is mounted. Run from there.
		set customLocation to "Pashua:"
	else
		-- Search for Pashua in the standard locations
		set customLocation to ""
	end if
end tell

try
	set thePath to alias (thisFolder & "Pashua.scpt")
	set pashuaBinding to load script thePath
	
	tell pashuaBinding
		-- Display the dialog
		
		try
			set pashuaLocation to getPashuaPath(customLocation)
			
			if artworkExists is true then
				set dialogConfiguration to my getDialogConfiguration((((path to pictures folder) as text) & "cover." & x))
			else
				set dialogConfiguration to my getDialogConfiguration((((path to pictures folder) as text) & "cover_not.png"))
				
			end if
			
			set theResult to showDialog(dialogConfiguration, customLocation)
			if {} = theResult then
				
			else if cb of theResult is not "1" then
				tell application "Twitter Scripter"
					if artworkExists is true then
						tweet sendText1 & return & sendText2 & tf of theResult using account pop of theResult with image (((path to pictures folder) as text) & "cover." & x)
					else if artworkExists is false then
						tweet sendText1 & return & sendText2 & tf of theResult using account pop of theResult
					end if
				end tell
				
			end if
		end try
	end tell
end try


--Pashuaによるダイアログの見た目の設定
-- Returns the configuration string for an example dialog
on getDialogConfiguration(pashuaLocation)
	
	if pashuaLocation is not "" then
		set img to "img.type = image
	          img.x = 320
	          img.y = 90
			  img.maxwidth = 128
			  img.tooltip = Album Art
	          img.path =" & (POSIX path of pashuaLocation) & return
	else
		set img to ""
	end if
	
	return "
# Set window title
*.title = Currently playing...

# Introductory text
txt.type = text
txt.label = Track/Album Info
txt.default = [return]" & sendText1 & "[return]" & sendText2 & "
txt.height = 10
txt.width = 300
txt.x = 0
txt.y = 160
#txt.tooltip = This is an element of type “text”

# Add a cancel button with default label
cb.type = cancelbutton
cb.label = Cansel

# Add a text field
tf.type = textfield
tf.label = 
tf.default = 
tf.width = 300
tf.tooltip = This is an element of type “textfield”


# Add a popup menu
pop.type = popup
pop.label = Tweet Account
pop.width = 300
pop.option = 
pop.option = 
pop.default = 
pop.tooltip = This is an element of type “popup”

db.type = defaultbutton
db.label = Tweet



" & img
end getDialogConfiguration


on googleSerch1(theName, theArtist)
	tell application "Safari"
		set google to "https://www.google.co.jp/search?num=100&inlang=ja&hl=ja&site=webhp&oe=Shift_JIS&q=" & theName & " " & theArtist & " " & "東方"
		open location google
		delay 2
		set html1 to (source of document 1)
		--quit
	end tell
	return html1
end googleSerch1

on googleSerch2(theName, theAlbum)
	tell application "Safari"
		set google to "https://www.google.co.jp/search?num=100&inlang=ja&hl=ja&site=webhp&oe=Shift_JIS&q=" & theName & " " & theAlbum & " " & "東方"
		
		open location google
		delay 2
		set html2 to (source of document 1)
		--quit
	end tell
	return html2
end googleSerch2

--切り取った文字内の原曲を検索
on findOriginal(theText1, theText2, serchStr, theCount, theList)
	set wordBehind1 to findBehindword(theText1, serchStr, theCount)
	set wordBehind2 to findBehindword(theText2, serchStr, theCount)
	set theOriginal to {}
	repeat with curwordBehind1 in wordBehind1
		repeat with curMusic1 in theList
			if findText(curwordBehind1, curMusic1) is not {} then
				set end of the theOriginal to curMusic1
			end if
		end repeat
	end repeat
	
	repeat with curwordBehind2 in wordBehind2
		repeat with curMusic2 in theList
			if findText(curwordBehind2, curMusic2) is not {} then
				set end of the theOriginal to curMusic2
			end if
		end repeat
	end repeat
	return theOriginal
end findOriginal



on replaceText(theText, serchStr, replaceStr)
	set tmp to AppleScript's text item delimiters
	set AppleScript's text item delimiters to serchStr
	set theList to every text item of theText
	set AppleScript's text item delimiters to replaceStr
	set theText to theList as string
	set AppleScript's text item delimiters to tmp
	set the clipboard to theText
	return theText
end replaceText





on findBehindword(theText, serchStr, theCount)
	--display dialog serchStr
	script theText_ref
		property contents : theText
	end script
	set tmp to AppleScript's text item delimiters
	set AppleScript's text item delimiters to serchStr
	set contents of theText_ref to every text item of contents of theText_ref
	set theList to {}
	set x to 0
	set delNum to number of serchStr
	repeat with curItem in contents of theText_ref
		if (number of curItem) is less than theCount then
			set wordCount to (number of curItem)
		else
			set wordCount to theCount
		end if
		set AppleScript's text item delimiters to tmp
		if wordCount is not 0 then
			set the end of theList to characters 1 thru wordCount of curItem as text
		end if
	end repeat
	
	(*repeat with now in theList
		display dialog now
	end repeat*)
	if (number of theList) = 1 then return {}
	--return items 1 thru -2 of theList
	return theList
end findBehindword


--theText中のserchStrを検索する
on findText(theText, serchStr)
	set tmp to AppleScript's text item delimiters
	set AppleScript's text item delimiters to serchStr
	set theText to every text item of theText
	set theList to {}
	set x to 0
	set delNum to number of serchStr
	repeat with curItem in theText
		set x to x + (number of curItem)
		set end of theList to x + 1
		set x to x + delNum
	end repeat
	set AppleScript's text item delimiters to tmp
	if (number of theList) = 1 then return {}
	--return items 1 thru -2 of theList
	return theList
end findText



--theWord以降を削除
on reftheText(theText, theWord)
	set tmp to AppleScript's text item delimiters
	set AppleScript's text item delimiters to theWord
	set theText to first text item of (theText as string)
	set AppleScript's text item delimiters to tmp
	return theText
end reftheText

--重複削除
on removeDuplicates(aList)
	
	set newList to {}
	repeat with i from 1 to (count aList)
		set anItem to item 1 of aList
		set aList to rest of aList
		if {anItem} is not in aList then set end of newList to anItem
	end repeat
	return newList
end removeDuplicates

すごく長く見えるけどほとんど原曲っていうね.....
このスクリプトをworkflowの形で保存して,quicksilverでもBetterTouchToolでもで呼び出せばSafariが開いて原曲名の一覧が出てきます
Twitterにつぶやくとこんな風になる
f:id:rinringo429:20160911025003p:plain:w300
f:id:rinringo429:20160911024356p:plain:w300