Jump to content

Recommended Posts

Posted (edited)

I could tell you about it but I'll just answer any questions and let you look through it instead

#include <IE.au3>
#include <array.au3>
$t = InputBox("","For the Progess Bar: Please Enter the number of songs you selected (approx will do)")
$iTunesApp = ObjCreate("iTunes.Application")
$o_IE = _IECreate("about:blank",0,0)
ProgressOn("","")
$n = 0

For $track in $iTunesApp.SelectedTracks
    If $track.Comment = NOT "[L]" OR "[lyrics not available at absolutelyrics]" Then
        $artist = $track.Artist
        $name = $track.Name
        $text = _GetLyrics($artist,$name,$o_IE)
        If $text = NOT "elp" Then
            $text2 = _AddLyrics($text,$name)
            MsgBox(0,"Lyrics exported",$text,2)
            $n = $n - 1
        EndIf
    EndIf
    $n = $n + 1
    ProgressSet($n / $t * 100)
Next
ProgressOff()

Func _AddLyrics($text,$name)
    For $track in $iTunesApp.SelectedTracks
        If $track.Name = $name Then
            $track.lyrics = $text
            $track.comment = "[L]"
        EndIf
        $text2 = $track.lyrics
    Next
    Return $text2
EndFunc

Func _GetLyrics($artist,$name,$o_IE)
    $artist = StringReplace($artist," ","_")
    $name = StringReplace($name," ","_")
    $artist = StringReplace($artist,"'","%27")
    $name = StringReplace($name,"'","%27")
    $s_Url = String("http://www.absolutelyrics.com/lyrics/view/" & $artist & "/" & $name & "/")
    _IENavigate($o_IE,$s_Url)
    $text = _IEBodyReadText($o_IE)
    $searchstring = StringInStr($text,"The page cannot be found" OR "is not found at")
    If $searchstring = 0 Then
        $del1 = String("Absolute Lyrics</a>")
        $del2 = String("---------------")
        $text = StringSplit($text,$del1,1)
        If @error = 1 Then
            Return "elp"
        Else
            $text = StringSplit($text[2],$del2,1)
            $text = StringTrimLeft($text[1],7)
            Return $text
        EndIf
    Else
        For $track in $iTunesApp.SelectedTracks
            If $track.Name = $name Then
                $track.comment = "[lyrics not available at absolutelyrics]"
            EndIf
        Next
        Return "elp"
    EndIf
EndFunc
Edited by yaziquex

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...