-- -----------------------------------------------------------------
-- Now Playing for me2day
-- -----------------------------------------------------------------
-- me2day user id & user key
property me2userid : "sumanpark"
property me2userkey : "********"
--------------------------------------------
property apiurl : "http://me2day.net/api/set_description/" & me2userid & ".xml"
property basic_auth_password : ""
property nonce : ""
property currentdata : ""
property prevdata : ""
property current_track : ""
property curr_position : ""
property is_on : false
on run
tell application "Finder"
try
if (get name of every process) contains "iTunes" then set is_on to true
on error
set is_on to false
end try
end tell
if is_on is true then
tell application "iTunes"
if player state is playing then
set currentdata to " -d description=\"" & my encode_html((artist of the current track as Unicode text) & " - " & (name of the current track as Unicode text)) & "\""
end if
end tell
end if
if (currentdata is not equal to prevdata) then
tell application "iTunes"
if player position is greater than 5 then
set pass to my get_basic_auth_password()
do shell script ("curl -u " & me2userid & ":" & pass & " " & apiurl & currentdata)
--return "curl -u " & me2userid & ":" & pass & " " & apiurl & currentdata
set prevdata to currentdata
end if
end tell
end if
return 5
end run
property chars : {{"&", "and"}, {" ", "%20"}}
on get_basic_auth_password()
if (length of basic_auth_password is greater than 0) then
return basic_auth_password
end if
set my_nonce to my get_nonce()
try
do shell script "/sbin/md5 -qs " & my_nonce & me2userkey
on error errMsg number errNo
error errMsg number errNo
return "failed"
end try
set basic_auth_password to my_nonce & result
return basic_auth_password
end get_basic_auth_password
on get_nonce()
if (length of nonce is greater than 0) then
return nonce
end if
set hx to ""
set hexc to "123456789abcdef"
repeat 8 times
set d to random number 15
if d = 0 then
set hx to hx & "0" as text
else
set hx to hx & (item d of hexc) as text
end if
end repeat
set nonce to hx
return nonce
end get_nonce
on encode_html(this_text)
repeat with replaceStrItems in chars
set this_text to my replace_chars(this_text, item 1 of replaceStrItems, item 2 of replaceStrItems)
end repeat
set this_text to my replace_unix(this_text)
end encode_html
on replace_chars(a_string, old_item, new_item)
set AppleScript's text item delimiters to the old_item
set the item_list to every text item of a_string
set AppleScript's text item delimiters to the new_item
set a_string to the item_list as string
set AppleScript's text item delimiters to ""
return a_string
end replace_chars
on replace_unix(a_string)
set old_item to "\""
set new_item to "\\\""
set a_string to replace_chars(a_string, old_item, new_item)
set old_item to "("
set new_item to "\\("
set a_string to replace_chars(a_string, old_item, new_item)
set old_item to ")"
set new_item to "\\)"
set a_string to replace_chars(a_string, old_item, new_item)
set old_item to "<"
set new_item to "\\<"
set a_string to replace_chars(a_string, old_item, new_item)
set old_item to ">"
set new_item to "\\>"
set a_string to replace_chars(a_string, old_item, new_item)
set old_item to "'"
set new_item to "\\'"
set a_string to replace_chars(a_string, old_item, new_item)
set old_item to "?"
set new_item to "\\?"
set a_string to replace_chars(a_string, old_item, new_item)
set old_item to ";"
set new_item to "\\;"
set a_string to replace_chars(a_string, old_item, new_item)
set old_item to "&"
set new_item to "\\&"
set a_string to replace_chars(a_string, old_item, new_item)
set old_item to "$"
set new_item to "\\$"
set a_string to replace_chars(a_string, old_item, new_item)
set old_item to "~"
set new_item to "\\~"
set a_string to replace_chars(a_string, old_item, new_item)
set old_item to "*"
set new_item to "\\*"
set a_string to replace_chars(a_string, old_item, new_item)
set old_item to "`"
set new_item to "\\`"
set a_string to replace_chars(a_string, old_item, new_item)
set old_item to "|"
set new_item to "\\|"
set a_string to replace_chars(a_string, old_item, new_item)
return a_string
end replace_unix
엇 왠지 Yahoo! Widget으로도 가능할 것 같은 예감이!
윈도우에 윈앰프랑 윈미플도 지원 해 주세요!!!
foobar같은 것으로 활용되어도 좋겠습니다만,
할줄을 모르니 원.. (먼산)
이참에 공부 좀 해봐야겠습니다.
혹시 <a href="http://www.lastfm.co.kr/tools/downloads/">라스트 에프엠</a>을 들어보셨습니까?
그것으로 듣고 있는 노래 제목을 me2day에 나오게 할수있나요?
일단 성공은했습니다!!!!!!! 하지만 아이튠즈 노래가 바뀌면 스크립트를 다시 실행해줘야 미투데이에 반영 되더군요..
ㅠ_ㅠ
제가 뭘 잘못 한걸까여 ㅠ_ㅠ
박수만 대표님아, 어제 강의 듣고 왔어요. 제가 1등인가요?
좋은 너를 위치! 감사하십시요.
너는 아름다운 웹사이트가 있는다!
일! 우수한 감사!
아주 유용한 정보!
좋은 위치는 찾아본 그것 즐겼다!
관심을 끌. 너가 좋을 동일할 지점을.
나는 합의한다 너에 이다. 그것은 이렇게 이다.
좋은 영역! 걸출한 영역!
그런 위치를 경이롭 위해 많게의 감사!
관심을 끌. 너가 좋을 동일할 지점을.
좋은 너를 위치! 감사하십시요.