ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

IDEA: Batch download lyrics for your mp3 songs in your library to the ID3 tag

<< < (2/6) > >>

fatjoe:
Yeah my main problem is I want to do this without playing the song. I just want to run it and get it to try find lyrics for my entire mp3 library i define ~

fatjoe:
$10 paypal or donation credits or whatever you guys callit for person who can do this.

Nothing fancy. Just select a directory, maybe a checkbox for search lyrics for songs in subfolders also. Then just one at a time grab a song in the folder & seek lyrics for it based on title & artist in the ID3 tag from a few lyric sites like elyrics.net & elyricsworld.com etc and if found add it to the Lyrics section of the ID3 tag.

skrommel:
 :) I started building this app, using a command line mp3 tag tool, but it turns out that the tool crashes while writing the info back, so I started looking for an alternative, and of course someone has built this before. Try http://www.tagrunner.com for one of them.

Skrommel

skrommel:
 :) But if anyone can make the Tag.exe tool work, here's AddLyrics's source code.
I've changed it to download the lyrics to the same name as the MP3, but using the .txt extension.

Remember to download Tag.exe and place it in the same folder as the script.

Skrommel


--- ---;AddLyrics.ahk
; Downloads the lyrics of MP3 files
; Uses Tag.exe from http://www.softpedia.com/get/Multimedia/Audio/Tag-Editors/Tag.shtml
;Skrommel @2006


#SingleInstance,Force
#NoEnv
SetBatchLines,-1

If 0=0
{
  MsgBox,0,AddLyrics - 1 Hour Software,Command line: `tAddLyrics <path to mp3(s)> [Recurse Replace]`nExample: `t`tAddLyrics "C:\MP3\*.mp3" Recurse Replace`n`nRecurse=Recurse into subfolders`nReplace=Replace exsting lyrics`n`nwww.1hoursoftware.com
  ExitApp
}

path=%1%
recurse=0
If (2="recurse" Or 3="recurse")
  recurse=1
replace=0
If (2="replace" Or 3="replace")
  replace=1

Loop,%path%,0,%recurse%
{
  TrayTip,AddLyrics,%A_LoopFileLongPath%
  SplitPath,A_LoopFileLongPath,name,dir,ext,name_no_ext,drive
input="%A_LoopFileLongPath%"
  output=%dir%\%name_no_ext%.txt
  Gosub,RETRIEVE
}
ExitApp


RETRIEVE:
file:=CMDret_RunReturn("Tag.exe " input)
StringGetPos,start,file,Artist:
If start<0
  Return
start+=10
StringGetPos,stop,file,`n,,% start
StringMid,artist,file,% start,% stop-start
StringReplace,artist,artist,%A_Space%,+
Loop
{
  StringGetPos,start,artist,++
  If start<0
    Break
  StringReplace,artist,artist,++,+,All
}

StringGetPos,start,file,Title:
If start<0
  Return
start+=10
StringGetPos,stop,file,`n,,% start
StringMid,title,file,% start,% stop-start
StringReplace,title,title,%A_Space%,+,All
Loop
{
  StringGetPos,start,title,++
  If start<0
    Break
  StringReplace,title,title,++,+,All
}

lyricsexist=1
StringGetPos,start,file,Lyrics:
If start<0
  lyricsexist=0

file=http://search.azlyrics.com/cgi-bin/azseek.cgi?q=%artist%+%title%

UrlDownloadToFile,%file%,file.htm
FileRead,file,file.htm
StringGetPos,start,file,<b>1.</b>
If start=0
  Return
StringGetPos,start,file,<a href=",,% start
start+=10
StringGetPos,stop,file,",,% start
StringMid,file,file,% start,% stop-start+1
TrayTip,AddLyrics,%file%

UrlDownloadToFile,%file%,file.htm
FileRead,file,file.htm
StringGetPos,start,file,"</b>
start+=9
StringGetPos,stop,file,`n<BR><BR>,,% start
StringMid,file,file,% start,% stop-start-2

tag=0
lyrics=
Loop,Parse,file
{
  If A_LoopField=<
  {
    tag=1
    Continue
  }
  If A_LoopField=>
  {
    tag=0
    Continue
  }
  If tag=0
    lyrics:=lyrics A_LoopField
}
If (lyrics<>"" And (replace=1 or lyricsexist=0))
{
  ;lyrics="%lyrics%"
  ;file:=CMDret_RunReturn("Tag.exe " input "-t Lyrics=" lyrics)
  FileDelete,%output%
  FileAppend,%lyrics%,%output%
}
Return


; ******************************************************************
; CMDret-AHK functions
; version 1.08 beta
;
; Updated: March 31, 2006
; by: corrupt
; Code modifications and/or contributions made by:
; Laszlo, shimanov, toralf 
; ******************************************************************
; Usage:
; CMDin - command to execute
; ******************************************************************
; Known Issues:
; - If using dir be sure to specify a path (example: cmd /c dir c:\)
; - Running 16 bit console applications may not produce output. Use
; a 32 bit application to start the 16 bit process to receive output 
; ******************************************************************
; Additional requirements:
; - none
; ******************************************************************
; Code Start
; ******************************************************************

CMDret_RunReturn(CMDin)
{
  Global cmdretPID
  idltm := A_TickCount + 20
  CMsize = 1
  VarSetCapacity(CMDout, 1, 32)
  VarSetCapacity(sui,68, 0)
  VarSetCapacity(pi, 16, 0)
  VarSetCapacity(pa, 12, 0)
  Loop, 4 {
    DllCall("RtlFillMemory", UInt,&pa+A_Index-1, UInt,1, UChar,12 >> 8*A_Index-8)
    DllCall("RtlFillMemory", UInt,&pa+8+A_Index-1, UInt,1, UChar,1 >> 8*A_Index-8)
  }
  IF (DllCall("CreatePipe", "UInt*",hRead, "UInt*",hWrite, "UInt",&pa, "Int",0) <> 0) {
    Loop, 4
      DllCall("RtlFillMemory", UInt,&sui+A_Index-1, UInt,1, UChar,68 >> 8*A_Index-8)
    DllCall("GetStartupInfo", "UInt", &sui)
    Loop, 4 {
      DllCall("RtlFillMemory", UInt,&sui+44+A_Index-1, UInt,1, UChar,257 >> 8*A_Index-8)
      DllCall("RtlFillMemory", UInt,&sui+60+A_Index-1, UInt,1, UChar,hWrite >> 8*A_Index-8)
      DllCall("RtlFillMemory", UInt,&sui+64+A_Index-1, UInt,1, UChar,hWrite >> 8*A_Index-8)
      DllCall("RtlFillMemory", UInt,&sui+48+A_Index-1, UInt,1, UChar,0 >> 8*A_Index-8)
    }
    IF (DllCall("CreateProcess", Int,0, Str,CMDin, Int,0, Int,0, Int,1, "UInt",0, Int,0, Int,0, UInt,&sui, UInt,&pi) <> 0) {
      Loop, 4
        cmdretPID += *(&pi+8+A_Index-1) << 8*A_Index-8
      Loop {
        idltm2 := A_TickCount - idltm
        If (idltm2 < 10) {
          DllCall("Sleep", Int, 10)
          Continue
        }
        IF (DllCall("PeekNamedPipe", "uint", hRead, "uint", 0, "uint", 0, "uint", 0, "uint*", bSize, "uint", 0 ) <> 0 ) {
          Process, Exist, %cmdretPID%
          IF (ErrorLevel OR bSize > 0) {
            IF (bSize > 0) {
              VarSetCapacity(lpBuffer, bSize+1)
              IF (DllCall("ReadFile", "UInt",hRead, "Str", lpBuffer, "Int",bSize, "UInt*",bRead, "Int",0) > 0) {
                IF (bRead > 0) {
                  TRead += bRead
                  VarSetCapacity(CMcpy, (bRead+CMsize+1), 0)
                  CMcpy = a
                  DllCall("RtlMoveMemory", "UInt", &CMcpy, "UInt", &CMDout, "Int", CMsize)
                  DllCall("RtlMoveMemory", "UInt", &CMcpy+CMsize, "UInt", &lpBuffer, "Int", bRead)
                  CMsize += bRead
                  VarSetCapacity(CMDout, (CMsize + 1), 0)
                  CMDout=a   
                  DllCall("RtlMoveMemory", "UInt", &CMDout, "UInt", &CMcpy, "Int", CMsize)
                }
              }
            }
          }
          ELSE
            break
        }
        ELSE
          break
        idltm := A_TickCount
      }
    }
    cmdretPID=
    DllCall("CloseHandle", UInt, hWrite)
    DllCall("CloseHandle", UInt, hRead)
  }
  IF (StrLen(CMDout) < TRead) {
    VarSetCapacity(CMcpy, TRead, 32)
    TRead2 = %TRead%
    Loop {
      DllCall("RtlZeroMemory", "UInt", &CMcpy, Int, TRead)
      NULLptr := StrLen(CMDout)
      cpsize := Tread - NULLptr
      DllCall("RtlMoveMemory", "UInt", &CMcpy, "UInt", (&CMDout + NULLptr + 2), "Int", (cpsize - 1))
      DllCall("RtlZeroMemory", "UInt", (&CMDout + NULLptr), Int, cpsize)
      DllCall("RtlMoveMemory", "UInt", (&CMDout + NULLptr), "UInt", &CMcpy, "Int", cpsize)
      TRead2 --
      IF (StrLen(CMDout) > TRead2)
        break
    }
  }
  StringTrimLeft, CMDout, CMDout, 1
  Return, CMDout
}

fatjoe:
not tooo familiar with AHK but I downloaded it ages ago and I used AHK2Exe version 1.0.40.06 to try convert your code from a .ahk file to exe but when i ran the finished program I got error:

error at line 8.

line text: #NOEnv
Error: this line does not contain a recognized action.

Any ideas?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version