请选择 进入手机版 | 继续访问电脑版

苹果发烧友论坛

 找回密码
 注册
查看: 3750|回复: 8

[Script脚本] 从Last.FM的资料库中给iTune中的音乐加标签 (shell)

[复制链接]
发表于 2010-8-18 23:08:49 | 显示全部楼层 |阅读模式
提示: 该帖被管理员或版主屏蔽
 楼主| 发表于 2010-8-18 23:10:07 | 显示全部楼层
Set tags in iTunes based Last.fm
  
Aug 13, '10 07:30:00AM • Contributed by: Anonymous

I lacked a function that would automatically set tags on my tracks according to Last.fm.

I therefore wrote a bash shell script that leeches the three most popular tags for a given band name and applied them to the track. I can then just have iTunes use these tags for the entire album.

Here is the script code:
  1. #!/bin/bash
  2. TAGS="extract.txt"

  3. TITLE=`exec osascript <<EOF
  4. tell application "iTunes"
  5.   get artist of current track
  6.     --set genre of current track to "HORSE POP"
  7. end tell`

  8. echo "Fetching tags for: "  $TITLE

  9. wget -q  http://last.fm/music/$TITLE/+tags  
  10. sed -n  's/rel="tag"//p' +tags >gt;>gt; $TAGS
  11. TAGLIST=`awk '{print $4,$6,$7,$8,$9,$10}' $TAGS |sort -r|head -3|sed 's/.*" >gt;//g'|sed 's/</a>gt;//g'`
  12. TAGLIST=`echo $TAGLIST|sed '/SCENE.*[^.]$/N;s/n */ /'`
  13. echo $TAGLIST >gt; $TAGS

  14. echo "Setting tags to :" $TAGLIST
  15. NEWTAGS=`exec osascript <</EOF
  16. set tags to do shell script "cat extract.txt"
  17. tell application "iTunes"
  18.   set genre of current track to tags
  19. end tell`

  20. rm +tags
  21. rm $TAGS
复制代码
It is not perfect but it is a start for making tagging easier, for me at least. Hopefully some of you will find it useful or inspiring.
回复 支持 反对

使用道具 举报

发表于 2010-8-18 23:16:40 | 显示全部楼层
其实,我还是不知道怎么用这个?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2010-8-18 23:24:04 | 显示全部楼层
其实,我还是不知道怎么用这个?
macing2010 发表于 2010-8-18 23:16

我也得好好研究下Orz
回复 支持 反对

使用道具 举报

QQ|小黑屋|手机版|Archiver|苹果发烧友论坛 ( 京ICP备16012027号-3 )

GMT+8, 2017-10-23 03:06 , Processed in 0.011446 second(s), 7 queries , Xcache On.

Powered by Discuz! X3.3 Licensed

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表