现在的位置: 首页 > 综合 > 正文

[工具] [Geek向]使用AppleScript来自动获取填充ITunes歌曲歌词

2018年05月17日 ⁄ 综合 ⁄ 共 1383字 ⁄ 字号 评论关闭

转载自:http://mac.pcbeta.com/thread-88790-1-1.html

Martian真的是懒死了……Martian既不想开搜索引擎搜歌词,也不想开那内存吃货Xcode来帮忙……

于是我就用PHP和AppleScript写了一个小脚本来实现自动获取iTunes的歌曲歌词~

脚本源代码:

--AppleScript By Martian
--Ver 1.1
--http://blog.4321.la
--https://plus.google.com/100204491389909955903/
--http://twitter.com/martian_zhu
--http://about.me/martian_z

property myProgram : "4321.La"
property baseURL : "http://lyrics.sinaapp.com/"

--因为我实在是不想操心AppleScript的语法,所以一部分代码采用PHP编写
--为了获得最好的整理效果,PHP脚本挂在SAE上面,大陆用户的访问速度应该非常不错
--但是SAE的价格是按照请求次数计费,实在是不便宜,如果您能自己架设PHP服务器并且提供分流服务,我会非常感激!
--PHP源代码可以见我的博客帖子,里面有说明

--使用说明:
--1、打开iTunes,选择要添加歌词的歌曲,可以批量选择
--2、点击脚本上的“运行”即可,整理结束时iTunes会有提示
--3、虽然脚本支持批量整理,但是程序自动化整理永远不可能那么智能,不能保证歌曲歌词全部正确,可能需要您后期再次加工
--4、如果您的歌曲中含有繁体汉字,程序无法自动搜索歌词,这会在后续版本中修正

tell application "iTunes"
  if selection is not {} then
      set k to count (item of selection)
  else
      return
  end if
  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 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
      end if
      set i to i + 1
      if i > k then exit repeat
  end repeat
  display dialog return & "整理结束!" buttons {"确定"} default button 1 with icon 1 giving up after 15 with title myProgram
end tell

使用说明:
1、打开 应用程序 -
实用
工具 -
AppleScript编辑器.app


2、将上述代码粘贴进去

3、然后去看脚本里面的说明进一步操作

来自:http://blog.4321.la/articles/2012/01/27/use-applescript-to-set-itunes-lyrics/

抱歉!评论已关闭.