17
May/09
0
comments

Songtexte in iTunes von LyricWiki.org

[Update 13.11.2009] Seit dem 02. August 2009 ist es LyricWiki nicht mehr erlaubt, Songtexte über sein API zur Verfügung zu stellen. Das bedeutet, daß die nachfolgend beschriebene Lösung zum Einbinden von Songtexten in iTunes-Musikstücke nicht mehr funktioniert. Auf der Seite LyricWiki API changes sind einige weitere Details vom LyricWiki-Schöpfer Sean Colombo zu erfahren.

iTunes hilft zwar bei der Suche nach Album-Covern, bietet aber kein Pendant für die Suche nach Songtexten. Auf dougscripts.com gibt es so manche AppleScript-Perle zu finden; so auch ein iTunes AppleScript von Doug Adams, mit dem anhand des Songnamens nebst Künstler aus iTunes heraus Songtexte auf LyricWiki.org gesucht und – falls gefunden – direkt in die Musikdatei (mp3) eingebunden werden können. Das Skript ist auch für weniger erfahrene Anwender sehr leicht in iTunes einzubinden und ebenso einfach zu bedienen: Song in iTunes anklicken, Skript aus dem Menü starten und den auf LyricWiki.org gefundenen Songtext in die Musikdatei übernehmen. Fertig!

Zur Installation: Auf der Seite Lyrics via LyricWiki steht eine *.dmg-Datei zum Download bereit. Wer statt des Installers gerne selber Hand anlegt, kann das untenstehende Script in eine Datei, bspw. LyricWiki.scpt, kopieren und diese im Verzeichnis ~/Library/iTunes/Scripts/ ablegen. Falls das Unterverzeichnis Scripts nicht existiert einfach “von Hand” anlegen.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
(*
"Lyrics via LyricWiki" for iTunes
written by Doug Adams
dougadams@mac.com
Thanks to the many Correspondents who emailed me info on the SOAP command.
<http://lyricwiki.org/LyricWiki_talk:SOAP>
 
v1.1 may 11 2009
- addressed issue with high-ASCII text
 
v1.0 February 28 2009
-- initial release
 
Get more free AppleScripts and info on writing your own
at Doug's AppleScripts for iTunes
http://dougscripts.com/itunes/
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
Get a copy of the GNU General Public License by writing to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
or visit http://www.gnu.org/copyleft/gpl.html
*)
 
property my_title : "Lyrics via LyricWiki"
property nom : ""
property art : ""
global sel
tell application "iTunes"
  if player state is playing then
    set sel to current track
    tell sel to set {nom, art} to {get name, get artist}
  else if selection is not {} and (count items of selection) is 1 then
    set sel to item 1 of selection
    tell sel to set {nom, art} to {get name, get artist}
  else
    return
  end if
end tell
 
-- log {nom, art}
if nom is "" or art is "" then
  display dialog "The track does not have enough information to search LyricWiki." buttons {"OK"} with icon stop with title my_title
  return
end if
try
  tell application "http://lyricwiki.org/server.php" to set rez to (call soap {method name:"getSong", method namespace uri:"urn:LyricWiki", SOAPAction:"urn:LyricWiki#getSong", parameters:{artist:art as text, song:nom as text}})
on error m
  tell application "iTunes"
    display dialog "Error from LyricWiki:" & return & return & tab & m with title my_title
  end tell
end try
 
-- log rez
set theLyrics to do shell script "echo " & quoted form of ((lyrics of rez) as text) & " | iconv -t ISO-8859-1 -f UTF-8"
set lyricWikiPageURL to |url| of rez
 
-- copy to lyrics or display LyricsWiki page?
if theLyrics does not contain "Not found" then
  set displayLyrics to my text_to_list(theLyrics, (ASCII character 13))
  set opt to (choose from list displayLyrics with prompt (art & return & "\"" & nom & "\"") as text OK button name "Use Lyrics for Track" with empty selection allowed)
  if opt is false then return
  (*
    tell application "Finder"
      open location lyricWikiPageURL
    end tell
  *)
  tell application "iTunes"
    try
      set sel's lyrics to theLyrics
    end try
  end tell
else
  display dialog "Lyrics for \"" & art & "\" - \"" & nom & "\" not found at LyricWiki." buttons "OK" with icon stop with title my_title
end if
 
on text_to_list(txt, delim)
  set saveD to AppleScript's text item delimiters
  try
    set AppleScript's text item delimiters to {delim}
    set theList to every text item of txt
    on error errStr number errNum
    set AppleScript's text item delimiters to saveD
    error errStr number errNum
  end try
  set AppleScript's text item delimiters to saveD
  return (theList)
end text_to_list

Nutzung: Nach Auswahl einer Musikdatei In iTunes den Eintrag “LyricWiki” im Script-Menü (sieht wie eine Schritftrolle aus) wählen. Falls keine Lyrics auf LyricWiki.org für den gewählten Song gefunden werden, gibt das Script eine entsprechende Meldung aus. Andernfalls wird der Songtext angezeigt und kann, falls gewünscht, in die Musikdatei übernommen werden.

Kommentare » Bisher keiner.
Kategorie » Nerd Talk
Comments (0) Trackbacks (0)

No comments yet.

Leave a comment

Name

E-Mail

Website

Ihr Kommentar

No trackbacks yet.