Sign in to follow this  
Followers 0
GtaSpider

Receive CD Informations from FreeDB.org

10 posts in this topic

Hi everyone,

With this UDF you can receive informations about a AudioCD from the free Database FreeDB.org

Informations are:

  • Artist
  • Name
  • Year
  • Genre
  • Other informations (EXTD)
  • Track name
  • Track length
  • Track position

Hope anybody can use this, it would be great if you can give me some backcomments!

It's create a CDDB Query and send it to freedb.org per TCP/IP. (like e.g. Audiograbber do to find CD Infos)

You can find the CDDB.au3 and the Example.au3 in the ZIP

CDDB.au3___Example.zip

or here:

CDDB.au3

#include-once

;CDDB.au3 - By GtaSpider

Global $hWinmmDLL = DllOpen("winmm.dll")


;===============================================================================
;
; Function Name:   _CDDBCreateQuery($sCD)
; Description::    Create a CDDB Query for e.g. freedb.org
; Parameter(s):    $sCd - The CD Drive, e.g. e: or D:
; Requirement(s):  -
; Return Value(s): On Success: Returns the CD Query.
;           : On Error:
;           : @error = 1 $sCD isn't a CD Drive
;           : @error = 2 MCICommand failed - @extended = 0 --> Open CD faild
;                                      @extended = 1 --> Number of Tracks faild
;           : @error = 3 Failed to get the CD Checksum (CD ID) - @extended: Errorcode from __CDDBGetCDID()
;           : @error = 4 Failed to get tracks
;           : @error = 5 Failed to get LeadOut
;
; Author(s):       GtaSpider
;
;===============================================================================
;
Func _CDDBCreateQuery($sCD)
    Local $sRet, $iTotal, $i
    $sCD = StringUpper(StringLeft($sCD, 2))
    If (Not FileExists($sCD)) Or DriveGetType($sCD) <> "CDROM" Then Return SetError(1, 0, 0)
    $sRet = __SendMCIString("open " & $sCD & " type cdaudio alias cd1")
    If @error Then Return SetError(2, 0, 0)
    $sRet = __SendMCIString("status cd1 number of tracks wait")
    If @error Then Return SetError(2, 1, 0)
    $iTotal = $sRet
    $sRet = "cddb query " & __CDDBGetCDID($iTotal) & " " & $iTotal & " "
    If @error Then Return SetError(3, @error, 0)
    For $i = 1 To $iTotal
        $sRet &= __CDDBGetTrack($i) & " "
        If @error Then Return SetError(4, 0, 0)
    Next
    $sRet &= __CDDBGetLeadOut()
    If @error Then Return SetError(4, 0, 0)
    Return $sRet
EndFunc   ;==>_CDDBCreateQuery


;===============================================================================
;
; Function Name:   _RecvFreeDB
; Description::    Connect to the Freedb.org Database
; Parameter(s):    $sQuery: The Query Returned e.g. by _CDDBCreateQuery
; Requirement(s):  Internet Connection
; Return Value(s): On Success: Returns the string received from freedb.org in "INI format"
;           : On Error:
;           : @error = 1 - Wrong Query
;           : @error = 2 - Failed to get the IP from freedb.org
;           : @error = 3 - Failed to connect to freedb.org
;           : @error = 4 - Error on freedb.org - Freedb is not ready (maybe too much Clients)
;           : @error = 5 - Error on freedb.org - Authorization failed
;           : @error = 6 - Error on freedb.org - Failed to set protocol ID
;           : @error = 7 - Error on freedb.org - No matches found
;           : @error = 8 - Error on freedb.org - No informations found
; Author(s):       GtaSpider
;
;===============================================================================
;
Func _FreeDBRecvDB($sQuery, $fSecTry = False)
    Local $sIP, $hSocket, $sCDChcksum
    $sCDChcksum = StringRegExp($sQuery, "cddb query (.*?) ", 3)
    If @error Or (Not IsArray($sCDChcksum)) Then Return SetError(1, 0, 0)
    $sCDChcksum = $sCDChcksum[0]
    TCPStartup()
    $sIP = TCPNameToIP("mirror1.freedb.org")
    If @error Or (Not StringLen($sIP)) Then Return SetError(2, 0, 0)
    $hSocket = TCPConnect($sIP, 8880)
    If @error Then Return SetError(3, @error, 0)
    $sRecv = __TCPRecv($hSocket)
    If (Not StringInStr($sRecv, "201")) And (Not StringInStr($sRecv, "ready")) Then Return SetError(4, 0, $sRecv)
    TCPSend($hSocket, "cddb hello GtaSpider AutoIt AutoIt " & @AutoItVersion & @CRLF)
    $sRecv = __TCPRecv($hSocket)
    If Not StringInStr($sRecv, "200 Hello and welcome") Then Return SetError(5, 0, $sRecv)

    TCPSend($hSocket, "proto 5" & @CRLF)
    $sRecv = __TCPRecv($hSocket)
    If Not StringInStr($sRecv, "201 OK, CDDB protocol level now: 5") Then Return SetError(6, 0, $sRecv)
    
    TCPSend($hSocket, $sQuery & @CRLF)
    $sRecv = __TCPRecv($hSocket) ; genre CDID Artist / CDName, z.B. 200 rock b009520e Green Day / Dookie
    If StringInStr($sRecv, "211 Found inexact matches") And $fSecTry = False Then
        TCPCloseSocket($hSocket)
        TCPShutdown()
        Return _FreeDBRecvDB(StringReplace($sQuery, $sCDChcksum, StringLower(Hex(Number("0x" & $sCDChcksum) - 0x200, 8))), True)
    ElseIf StringInStr($sRecv, "211 Found inexact matches") And $fSecTry Then
        Return $sRecv
    EndIf
    If Not StringInStr($sRecv, "200") Then Return SetError(7, 0, $sRecv)
    $aSS = StringSplit($sRecv, " ")
    TCPSend($hSocket, "cddb read " & $aSS[2] & " " & $sCDChcksum & @CRLF)
    $sRecv = __TCPRecv($hSocket)
    If Not StringInStr($sRecv, "210") Then Return SetError(8, 0, $sRecv)
    Return $sRecv
EndFunc   ;==>_FreeDBRecvDB

;===============================================================================
;
; Function Name:   _FreeDBRetCDInfos
; Description::    Returns Artist, Albumname, Genre, Year and other informations of the CD in an array
; Parameter(s):    $sDatabase - The Databasestring from e.g. _FreeDBRecvDB
; Requirement(s):  -
; Return Value(s): On Success: Returns an array with following informations:
;           : $aRet[0] = Artist
;           : $aRet[1] = Album
;           : $aRet[2] = Genre
;           : $aRet[3] = Year
;           : $aRet[4] = Other Informations
; Author(s):       GtaSpider
;
;===============================================================================
;


Func _FreeDBRetCDInfos($sDatabase)
    Local $aSS, $aRet[5], $sRDB
    $sRDB = __ReadDatabase($sDatabase, "DTITLE")
    If @error Then
        $aRet[0] = "NO ARTIST"
        $aRet[1] = "NO ALBUM"
    Else
        $aSS = StringSplit($sRDB, " / ", 1)
        If $aSS[0] < 2 Then
            $aRet[0] = __ReadDatabase($sDatabase, "DTITLE")
        Else
            $aRet[0] = $aSS[1]
            $aRet[1] = $aSS[2]
        EndIf
    EndIf
    $sRDB = __ReadDatabase($sDatabase, "DGENRE")
    If @error Then
        $aRet[2] = "NO GENRE"
    Else
        $aRet[2] = $sRDB
    EndIf
    $sRDB = __ReadDatabase($sDatabase, "DYEAR")
    If @error Then
        $aRet[3] = "NO YEAR"
    Else
        $aRet[3] = $sRDB
    EndIf
    $sRDB = __ReadDatabase($sDatabase, "EXTD")
    If @error Then
        $aRet[4] = "NO EXTD"
    Else
        $aRet[4] = $sRDB
    EndIf
    
    Return $aRet
EndFunc   ;==>_FreeDBRetCDInfos

;===============================================================================
;
; Function Name:   _FreeDBRetCDTracks
; Description::    Returns tracks, length of tracks and position of tracks of the CD in an 2D array
; Parameter(s):    $sDatabase - The Databasestring from e.g. _FreeDBRecvDB
; Requirement(s):  -
; Return Value(s): On Success returns an 0 based 2D array:
;           : $aRet[0][0] = First track name
;           : $aRet[0][1] = First track length
;           : $aRet[0][2] = First track position
;           : $aRet[n][0] = n track name
;           : ....
; Author(s):       GtaSpider
;
;===============================================================================
;


Func _FreeDBRetCDTracks($sDatabase)
    Local $aRet[1][1], $sRead, $iTotal
    $iTotal = __SendMCIString("status cd1 number of tracks wait")
    If @error Then Return SetError(1, 0, 0)
    ReDim $aRet[$iTotal][3]
    For $i = 1 To $iTotal
        $sRead = __ReadDatabase($sDatabase, "TTITLE" & $i - 1)
        If @error Or $sRead = '' Then Return SetError(2, 0, 0)
        $aRet[$i - 1][0] = $sRead
        $aMSF = __SplitMSF(__SendMCIString("status cd1 length track " & $i))
        If @error Then Return SetError(3, 0, 0)
        $aRet[$i - 1][1] = $aMSF[1] & ":" & StringTrimLeft("00", StringLen(Round(Number($aMSF[2] & "." & $aMSF[3])))) & Round(Number($aMSF[2] & "." & $aMSF[3]))
        $aMSF = __SplitMSF(__SendMCIString("status cd1 position track " & $i))
        If @error Then Return SetError(3, 1, 0)
        $aRet[$i - 1][2] = $aMSF[1] & ":" & StringTrimLeft("00", StringLen(Round(Number($aMSF[2] & "." & $aMSF[3])))) & Round(Number($aMSF[2] & "." & $aMSF[3]))
    Next
    Return $aRet
EndFunc   ;==>_FreeDBRetCDTracks




Func __CDDBGetTrack($iTrack)
    Local $sRet = __SendMCIString("status cd1 position track " & $iTrack), $aMSF
    If @error Then Return SetError(1, 0, 0)
    $aMSF = __SplitMSF($sRet)
    If @error Then Return SetError(2, @extended, 0)
    Return ($aMSF[1] * 75 * 60) + ($aMSF[2] * 75) + $aMSF[3]
EndFunc   ;==>__CDDBGetTrack

Func __CDDBGetLeadOut()
    Local $sRet = __SendMCIString("status cd1 length wait"), $aMSF
    If @error Then Return SetError(1, 0, 0)
    $aMSF = __SplitMSF($sRet)
    If @error Then Return SetError(2, @extended, 0)
    Return ($aMSF[1] * 60) + $aMSF[2] + 2
EndFunc   ;==>__CDDBGetLeadOut

Func __CDDBSum($iSum)
    Local $aSS = StringSplit($iSum, ""), $iRet
    For $i = 1 To $aSS[0]
        $iRet += Number($aSS[$i])
    Next
    Return $iRet
EndFunc   ;==>__CDDBSum

Func __CDDBGetCDID($iTotal)
    Local $iChecksum
    For $i = 1 To $iTotal
        $sRet = __SendMCIString("status cd1 position track " & $i)
        $aMSF = __SplitMSF($sRet)
        If @error Then Return SetError(1, @extended, 0)
        $iChecksum += __CDDBSum($aMSF[1] * 60 + $aMSF[2])
    Next
    $aMSF = __SplitMSF(__SendMCIString("status cd1 length wait"))
    If @error Then Return SetError(1, @extended, 0)
    $leadout = ($aMSF[1] * 60 * 75 + ($aMSF[2]) * 75 + $aMSF[3])
    $tottime = ($leadout / 75) - ($iTotal / 75)
    $iChecksum = BitOR(BitShift(Mod($iChecksum, 0xff), -24), BitShift($tottime, -8), $iTotal)
    Return StringLower(Hex($iChecksum, 8))
EndFunc   ;==>__CDDBGetCDID

Func __SplitMSF($sMSF)
    Local $aSS = StringSplit($sMSF, ":")
    If @error Or $aSS[0] <> 3 Then Return SetError(1, @error, 0)
    Return $aSS
EndFunc   ;==>__SplitMSF

Func __ReadDatabase($sDatabase, $sKey)
    Local $aRet = StringRegExp($sDatabase, $sKey & "=(.*?)\r\n", 3)
    If @error Or IsArray($aRet) = False Then Return SetError(1, @error, 0)
    Return $aRet[0]
EndFunc   ;==>__ReadDatabase

Func __SendMCIString($sString, $iBuf = 255)
    Local $aRet = DllCall($hWinmmDLL, "int", "mciSendString", "str", $sString, "str", "str", "int", $iBuf, "long", 0)
    If @error Then Return SetError(@error, 0, 0)
    Return $aRet[2]
EndFunc   ;==>__SendMCIString

Func __TCPRecv($hSocket, $iSleep = 50, $iTimeOut = 20000, $iBuffersize = 1024, $iForceBinary = 0)
    Local $sRecv, $sRet, $iErr = 0, $hTi
    $hTi = TimerInit()
    While TimerDiff($hTi) <= $iTimeOut
        $sRecv = TCPRecv($hSocket, $iBuffersize, $iForceBinary)
        $iErr = @error
        If $iErr Then ExitLoop
        While StringLen($sRecv)
            $sRet &= $sRecv
            $sRecv = TCPRecv($hSocket, $iBuffersize, $iForceBinary)
            $iErr = @error
            If (Not StringLen($sRecv)) Or $iErr Then ExitLoop 2
            If TimerDiff($hTi) > $iTimeOut Then ExitLoop
        WEnd
        Sleep($iSleep)
    WEnd
    If TimerDiff($hTi) > $iTimeOut Then Return SetError(1, 0, "Timeout")
    If $iErr Then Return SetError($iErr, 0, 0)
    Return $sRet
EndFunc   ;==>__TCPRecv


Func OnAutoItExit()
    __SendMCIString("close cd1")
    DllClose($hWinmmDLL)
EndFunc   ;==>OnAutoItExitoÝ÷ ØLZ^jíÚºÚ"µÍÚ[ÛYH  ][ÝÐÑ]LÉ][ÝÂÑ^[HÜÑ]LÈHHÝTÜYÌÍØQÐÑH]QÙ]]J  ][ÝÐÑÓI][ÝÊBÌÍÜÐÛÛXÜÝ[ÈH ÌÎNÉÌÎNÂÜ    ÌÍÚHHHÈ ÌÍØQÐÑÌBIÌÍÜÐÛÛXÜÝ[È [ÏHÝ[Õ   ÌÍØQÐÑÉÌÍÚWJH  [È ][Ýß  ][ÝÂ^Ý[Õ[TYÚ
    ÌÍÜÐÛÛXÜÝ[ËJBÕRPÜX]J ][ÝÐÚÛÜÙHÛH]I][ÝËMLMKLKLKLKL
NÉÌÍÕÔ×ÑVÕÓÓÒSÕÂÌÍÚÛÛXÑ]HHÕRPÝÜX]PÛÛXÊ ][ÝÉ][ÝËLL
LBÕRPÝÙ]]JLK ÌÍÜÐÛÛXÜÝ[Ë    ÌÍØQÐÑÌWJBÌÍÚ]ÐÚÑYQHÕRPÝÜX]P]Û  ][ÝÐÚÈYQ][ÝË
KLJHÈÝ[HH ÌÍÐ×ÑQTÒUÓÌÍÚXÕ^HÕRPÝÜX]SX[
    ÌÎNÔXÙHÚÛÜÙHÛHÙHÑ]È[ÛXÚÈÛ   ][ÝÐÚÈYQ][ÝÈÈXÙZ]H[ÜX][ÛÈÙHÑÌÎNËLÍKLÌ

BÕRTÙ]Ý]J
BÚ[HBTÝÚ]ÚÕRQÙ]ÙÊ
BBPØÙH    ÌÍÚ]ÐÚÑYQBBIÌÍÜÓÈHÕRPÝXY
    ÌÍÚÛÛXÑ]JBBBQÕRPÝ[]J    ÌÍÚÛÛXÑ]JBBBQÕRPÝ[]J    ÌÍÚ]ÐÚÑYQBBBQÕRPÝÙ]]J  ÌÍÚXÕ^  ][ÝÔXÙHØZ][[HHÈÙ]]YHÙ ][ÝÈ  [È ÌÍÜÓÈ  [È ][ÝÈ[Ù[H]YHÈYQÈX^HZÙHHÛÝHÙÙXÛÛË][ÝÊBBBIÌÍÚÙ×ÔÙÜÜÈHÕRPÝÜX]TÙÜÜÊLLLÌM
NÔÝYHH    ÌÍÔ×ÓPTUQQHHHBBQÕRPÝÙ]ÛÛÜLK
BBBQØ[
    ][ÝÕ^[YK  ][ÝË  ][ÝÚ[ ][ÝË  ][ÝÔÙ]Ú[ÝÕ[YI][ÝË   ][ÝÚÛ    ][ÝËÕRPÝÙ][JLJK    ][ÝÝÜÝ][ÝË    ][ÝÉ][ÝË    ][ÝÝÜÝ][ÝË    ][ÝÉ][ÝÊBBBQÕRPÝÙ]ÜÊ   ÌÍÚXÕ^LKLÌ
JBBBQ^]ÛÜBPØÙHHÈÉÌÍÑÕRWÑUSÐÓÔÑHHLÂBBQ^]Q[ÝÚ]ÚÑ[ÛØ[    ÌÍÚTÙÈHYX[XJ   ][Ý×ÔÙ]ÙÉ][ÝËL
BÌÍÚHH[Y[]

BÌÍÜÔ]YHHÐÑÜX]T]YJ   ÌÍÜÓÊBYÜÜ
Ý  ÌÍÜÔ]YJH[^]ÙÐÞ
M   ][ÝÑÜ][ÝË  ][ÝÙÜÛÙH   ][ÝÈ  [ÈÜBÛÛÛÛUÜ]J ÌÍÜÔ]YH [ÈÔBÌÍÜÑ]XÙHHÑYQXÝ ÌÍÜÔ]YJBYÜÜ
Ý  ÌÍÜÑ]XÙJH[^]ÙÐÞ
M   ][ÝÑÜ][ÝË  ][ÝÌÜÛÙH   ][ÝÈ  [ÈÜ   [ÈÔ   [È ÌÍÜÑ]XÙJBYÝ[Ò[Ý ÌÍÜÑ]XÙK   ][ÝÌLHÝ[[^XÝX]ÚÉ][ÝÊH[QÕRPÜX]J    ][ÝÓ[ÜH[ÝÛHÝ[ ][ÝËN
JBIÌÍÚÝHÕRPÝÜX]SÝY]Ê   ][ÝÑÝ[YX]ÚÉ][ÝËLLML
BQÕRPÝÙ[ÙÊLKLQKN
BIÌÍØTÔÈHÝ[ÔÜ]
    ÌÍÜÑ]XÙKÔJBQÜ    ÌÍÚHHÈ  ÌÍØTÔÖÌHHBQÕRPÝÜX]SÝY]Ò][J   ÌÍØTÔÖÉÌÍÚWK   ÌÍÚÝBBRY    ÌÍÚHH[ÕRPÝÙ]Ý]JLKMNÉÌÍÑÕRWÑÐÕTÂS^IÌÍÚ]ÓÒÈHÕRPÝÜX]P]Û  ][ÝÓÒÉ][ÝËLMKMKJBQÕRTÙ]Ý]J
BUÚ[HBBTÝÚ]ÚÕRQÙ]ÙÊ
BBBPØÙH   ÌÍÚ]ÓÒÂBBBIÌÍØTXYHÝ[ÔÜ]
Ý[Õ[TYÚ
ÕRPÝXY
ÕRPÝXY
    ÌÍÚÝJKJK    ][ÝÈ  ][ÝÊBBBBQÕRQ[]J
BBBBIÌÍØT]YHHÝ[ÔÜ]
    ÌÍÜÔ]YK ][ÝÈ  ][ÝÊBBBBIÌÍÜÔ]YHHÝ[ÔXÙJ    ÌÍÜÔ]YK ÌÍØT]YVÌ×K ÌÍØTXYÌJBBBBPÛÛÛÛUÜ]J  ÌÍÜÔ]YH [ÈÔBBBBIÌÍÜÑ]XÙHHÑYQXÝ ÌÍÜÔ]YJBBBBRYÜÜ
Ý  ÌÍÜÑ]XÙJH[^]ÙÐÞ
M   ][ÝÑÜ][ÝË  ][ÝÌÜÛÙH   ][ÝÈ  [ÈÜ   [ÈÔ   [È ÌÍÜÑ]XÙJBBBBQ^]ÛÜBBPØÙHHÈÉÌÍÑÕRWÑUSÐÓÔÑHHLÂBBBQ^]BQ[ÝÚ]ÚUÑ[[YÌÍØPÑ[ÜÈHÑYQ]Ñ[ÜÊ   ÌÍÜÑ]XÙJBÌÍØPÑXÚÜÈHÑYQ]ÑXÚÜÊ   ÌÍÜÑ]XÙJBÌÍÚHH[YY   ÌÍÚJBYXØXJ
BÕRQ[]J
BÕRPÜX]][ÝÒ[ÜX][ÛÈÙHÑÛÚÜÈ   ][ÝÈ  [ÈÝ[
    ÌÍÚHÈLJH    [È ][ÝÈÙXÛÛÉ][ÝË
LL
BÕRPÝÜX]SX[
    ][ÝÐÑ]N][ÝËL
L
BÕRPÝÜX]R[]
    ÌÍØPÑ[ÜÖÌWK
MKMLN
BÕRPÝÜX]SX[
    ][ÝÐÑÝ][ÝËÌ
L
BÕRPÝÜX]R[]
    ÌÍØPÑ[ÜÖÌK
MKMLN
BÕRPÝÜX]SX[
    ][ÝÐÑÙ[N][ÝË
L
L
BÕRPÝÜX]R[]
    ÌÍØPÑ[ÜÖÌK
MK
MLN
BÕRPÝÜX]SX[
    ][ÝÐÑYX][ÝË
Ì
L
BÕRPÝÜX]R[]
    ÌÍØPÑ[ÜÖÌ×K
MK
MLN
BÕRPÝÜX]SX[
    ][ÝÐÑ^][ÝËL
L
BÕRPÝÜX]R[]
    ÌÍØPÑ[ÜÖÍK
MKMLN
BÌÍÚÝHÕRPÝÜX]SÝY]Ê ][ÝÕ]_[ÝÜÚ][Û][ÝËLNJBÕRPÝÙ[ÙÊLKLQKL
BÕRPÝÙ[ÙÊLKLQKKÍJBÕRPÝÙ[ÙÊLKLQKÍJBÜ    ÌÍÚHHÈPÝ[
    ÌÍØPÑXÚÜÊHHBQÕRPÝÜX]SÝY]Ò][J    ÌÍØPÑXÚÜÖÉÌÍÚWVÌH   [È ][Ýß  ][ÝÈ  [È ÌÍØPÑXÚÜÖÉÌÍÚWVÌWH  [È ][Ýß  ][ÝÈ  [È ÌÍØPÑXÚÜÖÉÌÍÚWVÌK   ÌÍÚÝB^ÕRTÙ]Ý]J
BÚ[HÕRQÙ]ÙÊ
H   ÉÝÈLÂÑ[[ÈÔÙ]ÙÊ
BIÌÍÚTÙÈ
ÏHBQÕRPÝÙ]]J    ÌÍÚÙ×ÔÙÜÜË    ÌÍÚTÙÊB[[ÈÏOIÝ×ÔÙ]Ù

Your Spider


www.AutoIt.de - Moderator of the German AutoIt Froum

Share this post


Link to post
Share on other sites



Very Nice, works great! Just what I have been looking for. I'm a rank amateur at programming but I'd like to learn to use this to name ripped wav files.

-A440Hz


Are you experienced?

Share this post


Link to post
Share on other sites

Fantastic that someone shows interest in it :) Nice that i could help you.

Spider


www.AutoIt.de - Moderator of the German AutoIt Froum

Share this post


Link to post
Share on other sites

I missed this one ... thanks for sharing! :idea:

I'll check it out real soon! :(

:P


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

Damn Spider your posting a lot of neat stuff man! Keep it up!

Share this post


Link to post
Share on other sites

Damn Spider your posting a lot of neat stuff man! Keep it up!

Now that you can do it online... Do you happen to have a updated version that it can use the downloaded database as well ... ?

Share this post


Link to post
Share on other sites

Finally, I got around to checking out this great program, and it works a treat. Just what I need for my CDIni Database program ... some elements anyway.

Once again, thanks for sharing ........ now let's go twiddle some knobs.

You really deserve more recognition for this, than you seem to have got .... it's what every CD media player needs, if they want to display track detail, without the user having to type it all in first.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

@GtaSpider - I've finally given your program a good workout, by incorporating many elements of your example into my CDIni Database program.

My Report

1) Because 'CDDB.au3' keeps the 'winmm.dll' open the whole time my program runs, I had to modify it, so that it was only Global when I instigated a query.

2) You don't seem to support Various Artist discs ... not correctly anyway, as far as separating Track Artist from Track Title. That's no big deal, as I can accommodate that quite easily, but unfortunately there seems to be a buffer issue or something as well and no tracks get returned (details below).

3) I also noted that you misnamed the title of one of your functions. You've called it ' _RecvFreeDB', when it is actually '_FreeDBRecvDB'.

I tested a 14 track Various Artist CD, and I notice that after track 10 (9), no more data existed. However, when I queried FreeDB with another program (CDex), all the data up to track 14 was returned. While your program recovers data up to track 10 (9), the final missing portion causes it to error, and only Artist, Title & Genre keys are displayed in your ListView GUI ... all tracks, etc are blank.

I've tried to determine what is causing this, and can only presume it is a memory or buffer issue after all my tests. Nothing I changed seemed to make a difference, and my programming skills are pretty basic at best, so I'm now at a stalemate.

In case you haven't realised, each track value data is significantly longer when it contains both an artist name as well as the track name -

i.e. Kenny Rogers & Kim Carnes / Don't Fall In Love With A Dreamer

Also note the forward slash (/), that could be used by your program to separate the two elements of Track Artist and Track Title.

The CD I tested - 'Together Forever', had many long entries like the one above.

This is the total but incomplete output I captured for that album

210 rock d30d1b0e CD database entry follows (until terminating `.')

# xmcd

#

# Track frame offsets:

# 150

# 20917

# 41012

# 57107

# 74145

# 90002

# 106507

# 124175

# 140525

# 157217

# 172197

# 190512

# 207482

# 222615

#

# Disc length: 3357

#

# Revision: 1

# Processed by: cddbd v1.5.2PL0 Copyright © Steve Scherf et al.

# Submitted via: OrangeCD 4.3

# Normalized: r0:DSETVAR1

#

DISCID=d30d1b0e

DTITLE=Various / Together Forever

DYEAR=

DGENRE=Pop

TTITLE0=Jose Carreras & Sarah Brightman / Amigos Para Siempre

TTITLE1=Patty Smyth & Don Henley / Sometimes Love Just Ain't Enough

TTITLE2=Linda Ronstadt & Aaron Neville / Don't Know Much

TTITLE3=Roy Orbison & K.D. Lang / Crying

TTITLE4=Roberta Flack & Peabo Bryson / Tonight, I Celebrate My Love

TTITLE5=Kenny Rogers & Kim Carnes / Don't Fall In Love With A Dreamer

TTITLE6=Peaches & Herb / Reunited

TTITLE7=The Righteous Brothers / Unchained Melody

TTITLE8=Stevie Nicks & Don Henley / Leather And Lace

TTITLE9=Kool & The Gang / Cherish

Apart from this issue, your program works well incorporated into mine.

Thanks once again for providing this!

Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Well, I had to keep playing with the problem, and so I eventually discovered that a judiciously placed Msgbox, allowed all entries to appear. With a little experimentation, I replaced the Msgbox with a Sleep(6000), which seems to do the trick as well ... for now anyway. So it would appear as though it is a time and not a memory issue.

The sleep was added to this function in your 'CDDB.au3' (near the end)

Func _FreeDBRecvDB($sQuery, $fSecTry = False)
    Local $sIP, $hSocket, $sCDChcksum
    $sCDChcksum = StringRegExp($sQuery, "cddb query (.*?) ", 3)
    If @error Or (Not IsArray($sCDChcksum)) Then Return SetError(1, 0, 0)
    $sCDChcksum = $sCDChcksum[0]
    TCPStartup()
    ;$sIP = TCPNameToIP("freedb.freedb.org")
    $sIP = TCPNameToIP("mirror1.freedb.org")
    If @error Or (Not StringLen($sIP)) Then Return SetError(2, 0, 0)
    $hSocket = TCPConnect($sIP, 8880)
    If @error Then Return SetError(3, @error, 0)
    $sRecv = __TCPRecv($hSocket)
    If (Not StringInStr($sRecv, "201")) And (Not StringInStr($sRecv, "ready")) Then Return SetError(4, 0, $sRecv)
    TCPSend($hSocket, "cddb hello GtaSpider AutoIt AutoIt " & @AutoItVersion & @CRLF)
    $sRecv = __TCPRecv($hSocket)
    If Not StringInStr($sRecv, "200 Hello and welcome") Then Return SetError(5, 0, $sRecv)

    TCPSend($hSocket, "proto 5" & @CRLF)
    $sRecv = __TCPRecv($hSocket)
    If Not StringInStr($sRecv, "201 OK, CDDB protocol level now: 5") Then Return SetError(6, 0, $sRecv)
    
    TCPSend($hSocket, $sQuery & @CRLF)
    $sRecv = __TCPRecv($hSocket) ; genre CDID Artist / CDName, z.B. 200 rock b009520e Green Day / Dookie
    If StringInStr($sRecv, "211 Found inexact matches") And $fSecTry = False Then
        TCPCloseSocket($hSocket)
        TCPShutdown()
        Return _FreeDBRecvDB(StringReplace($sQuery, $sCDChcksum, StringLower(Hex(Number("0x" & $sCDChcksum) - 0x200, 8))), True)
    ElseIf StringInStr($sRecv, "211 Found inexact matches") And $fSecTry Then
        Return $sRecv
    EndIf
    If Not StringInStr($sRecv, "200") Then Return SetError(7, 0, $sRecv)
    $aSS = StringSplit($sRecv, " ")
    TCPSend($hSocket, "cddb read " & $aSS[2] & " " & $sCDChcksum & @CRLF)
    ;MsgBox(262144, "$sRecv", $sRecv)
    Sleep(6000)
    $sRecv = __TCPRecv($hSocket)
    If Not StringInStr($sRecv, "210") Then Return SetError(8, 0, $sRecv)
    Return $sRecv
EndFunc   ;==>_FreeDBRecvDB
Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

Ok, I've finally given this a good workout and improved my delay work-a-round and discovered other bugs in GtaSpider's code.

I've provided my versions of both CDDB.au3 and Example.au3 below.

I discovered that multiple entries for Enya's Watermark album (etc), were being recognized as an error by existing code, so after playing around with code a little, I modified some elements and duplicated a whole section to deal with that scenario.

With some slight modification, you could have the resulting details exported to your Windows Cdplayer.ini file.

Put a CD in your drive and run the example file while connected to the web.

CDDB.au3

Example.au3

Thanks again to GtaSpider!


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0