Alfred Workflow: App Dig

  AppShopper是一个很实用的iOS/Mac App价格信息搜集网站,App Dig基于它,可以很方便的在Alfed里获取如限时免费等App价格变更信息,同时也支持AppShopper的Wish List。

App Dig Screenshot

DownloadSource

  • 支持App列表中显示应用图标1
  • 设置AppShopper用户名并公开Wish List可显示愿望列表2

  1. 显示应用图标时,获得App列表的时间可能增加,可在app setting中选择禁用 

  2. 在AppShopper的Wish List页面选中'Share My Wishlist'即可公开你的愿望列表 

Read more...

Alfred Workflow: 歌词搜索

  搜索歌词的Alfred Workflow,支持自动查找iTunes当前播放的歌曲或手动输入歌名查找,可将查到的歌词下载到本地或复制到剪切板或在Large Type显示,或直接保存到iTunes当前播放曲目中。

Lyric Screenshot

DownloadSource

  • ENTER 下载歌词到~/Downloads
  • CMD + ENTER 拷贝歌词内容到剪切板
  • ALT + ENTER 在Large Type显示歌词并拷贝内容到剪切版
  • CTRL + ENTER 保存歌词到iTunes当前正在播放的歌曲

说明:除了下载歌词,其它歌词内容都是去除了时间线信息的

让iTunes的歌曲自动获取歌词

Fetch Lyric for iTunes

  在4321.la看到使用AppleScript自动获取iTunes曲目歌词的脚本,相当不错,自己做了些修改,添加了当歌词已存在时忽略获取,可以通过Growl通知获取的结果等功能。代码如下:

-- FetchLyric
-- DESCRIPTION: 让iTunes内当前被选中的曲目自动下载并保存歌词,若歌词已存在将被忽略,支持Growl通知
-- AUTHOR: JinnLynn http:://jeeker.net
-- LAST UPDATED: 2012-05-04
-- INTRO PAGE: http://jeeker.net/fetch-lyric-for-itunes/
-- REF: Martian http://blog.4321.la/articles/2012/01/27/use-applescript-to-set-itunes-lyrics/
property scriptName : "FetchLyric"
property baseURL : "http://lyrics.sinaapp.com/"
property isGrowlRunning : false
property statusDesc : {"歌词已存在,无需再获取。", "歌词获取成功。", "歌词获取失败。", "未选择歌曲。"}
property STATUS_LYRIC_EXIST : 1
property STATUS_LYRIC_SUCCESS : 2
property STATUS_LYRIC_FAIL : 3
property STATUS_LYRIC_UNSELECTED : 4

tell application "System Events"
    set isGrowlRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0
end tell

script growl
    on growlNotify(artist, title, status)
        if isGrowlRunning = false then return
        tell application id "com.Growl.GrowlHelperApp"
            if title = "" then set title to "unknown"
            set the_title to title
            if artist is not equal to "" then set the_title to artist & " - " & the_title
            set the_desc to item status of statusDesc
            set the allNotificationsList to {scriptName}
            set the enabledNotificationsList to {scriptName}
            register as application ¬
                scriptName all notifications allNotificationsList ¬
                default notifications enabledNotificationsList ¬
                icon of application "iTunes"
            notify with name ¬
                scriptName title ¬
                the_title description ¬
                the_desc application name scriptName
            -- 尝试使用歌曲封面作为Growl图标出错
        end tell
    end growlNotify
end script

tell application "iTunes"
    if selection is {} then
        tell growl to growlNotify("", "", STATUS_LYRIC_UNSELECTED)
        return
    end if
    set k to count (item of selection)
    set i to 1
    repeat
        set theTrack to (item i of selection)
        set this_artist to (get artist of theTrack)
        set this_title to (get name of theTrack)
        set this_lyric to (get lyrics of theTrack)
        -- set this_artwork to data of artwork 1 of theTrack

        set fetch_status to STATUS_LYRIC_FAIL

        if length of this_lyric < 1 then
            -- 只有当歌曲中未存在歌词时才尝试获取歌词
            set requestData to "title=" & this_title & "&artist=" & this_artist
            set songLyrics to do shell script "curl -d '" & requestData & "' " & baseURL
            if length of songLyrics > 1 then
                -- 歌词成功获取
                set lyrics of theTrack to songLyrics
                set fetch_status to STATUS_LYRIC_SUCCESS
            end if
        else
            set fetch_status to STATUS_LYRIC_EXIST
        end if

        tell growl to growlNotify(this_artist, this_title, fetch_status)

        set i to i + 1
        if i > k then exit repeat
    end repeat
    -- 如果Growl未运行则显示对话框
    if isGrowlRunning = false then
        display dialog return & "歌词获取结束!" buttons {"确定"} default button 1 with icon 1 giving up after 5 with title scriptName
    end if
end tell

  USAGE: 在AppleScript Editor中新建包含上述脚本的文件,保存在 ~/Library/iTunes/Scripts 目录下,这时在iTunes菜单栏中就会出现AppleScript的下拉菜单,选中需要的歌曲执行其中的命令即可。或者也可以使用Automator将上述脚本生成系统服务,具体本文不做详述,自行Google。

  实际上实现功能需要服务端的支持,上述脚本中使用了Martian搭建在SAE上的服务端,如果你想搭建自己的服务端可以在Martian的文章中找到代码,或下载下面的文件,里面也包含了一个在服务端运行的PHP文件。

Project on GitHubDownload

  BTW: 尝试过使用歌曲封面做为Growl的图标没有成功,总提示无法生成数据,不知道什么原因。