• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1799
  • Last Modified:

How to get Album art on amazon.com

I have a program where i used to get the album art for my mp3´s but now it only gives me "(400) bad request" from the remote server.
I cant find how to make it work again.
Please help.

Public Function Amazon(ByVal Artist As String, ByRef Album As String, ByVal Year As String, ByRef ListV As ListView, ByRef ImageL As ImageList)
        'clear the images
        ImageL.Images.Clear()
        ListV.Items.Clear()
        Dim Code = "XXXXXXXXXXXXXXXXX"
        Dim n As System.Xml.XmlNamespaceManager = New System.Xml.XmlNamespaceManager(xDoc.NameTable)
        n.AddNamespace("a", "http://webservices.amazon.com/AWSECommerceService/2005-10-05")
        xDoc.Load("http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=" & Code & "&Operation=ItemSearch&SearchIndex=Music&ItemPage=1&ResponseGroup=ItemAttributes,Images&Keywords=" + Replace((Artist + " " + Album), " ", "%20"))
        Dim results = xDoc.SelectNodes("a:ItemSearchResponse/a:Items/a:Item[a:LargeImage/a:URL]", n) 'Only want results with large images
        'Dim coverart.SetCountEstimate(results.Count)
        Dim tempnumber As Integer = 0
        For Each Node As System.Xml.XmlNode In results
            Dim TitleNode = Node.SelectSingleNode("a:ItemAttributes/a:Title", n).InnerText 'Can Title ever not exist? Assume it always exists.
            Dim ArtistNode = Node.SelectSingleNode("a:ItemAttributes/a:Artist", n)
            Dim ArtistTemp = Nothing
            If ArtistNode Is Nothing Then 'No artist is supplied check for Creator
                ArtistNode = Node.SelectSingleNode("a:ItemAttributes/a:Creator", n)
                If ArtistNode Is Nothing Then 'No artist is supplied jump to next node 
                    ArtistTemp = "bajs"
                    ' Continue For
                Else
                    ArtistTemp = ArtistNode.InnerText.ToString
                End If
            Else
                ArtistTemp = ArtistNode.InnerText.ToString
            End If
            If UCase(ArtistTemp) <> UCase(Artist) Or UCase(TitleNode.ToString) <> UCase(Album) Then
                Continue For
            End If

            Dim width = -1
            Dim height = -1
            Dim widthNode = Node.SelectSingleNode("a:LargeImage/a:Width", n)
            Dim heightNode = Node.SelectSingleNode("a:LargeImage/a:Height", n)
            If widthNode.InnerText.Length > 0 And heightNode.InnerText.Length > 0 Then
                width = Integer.Parse(widthNode.InnerText)
                height = Integer.Parse(heightNode.InnerText)
            End If
            Dim fullsize = Node.SelectSingleNode("a:LargeImage/a:URL", n).InnerText
            Dim thumbnail = fullsize 'Unless a Medium image is present, in which case use that instead
            Dim thumbNode = Node.SelectSingleNode("a:MediumImage/a:URL", n)
            If thumbNode.InnerText.Length > 0 Then
                thumbnail = thumbNode.InnerText
            End If
            ListV.Items.Add(ArtistTemp & " - " & TitleNode.ToString, tempnumber) '& thumbnail.ToString)
            ListV.Items(tempnumber).Tag = fullsize
            'WEB CLIENT IS NEEDED TO DO THE DOWNLOAD

            Dim MyWebClient As New System.Net.WebClient



            'BYTE ARRAY HOLDS THE DATA

            Dim ImageInBytes() As Byte = MyWebClient.DownloadData(fullsize)



            'CREATE A MEMORY STREAM USING THE BYTES

            Dim ImageStream As New IO.MemoryStream(ImageInBytes)



            'CREATE A BITMAP FROM THE MEMORY STREAM

            Dim Imaget As New System.Drawing.Bitmap(ImageStream)
            ImageL.Images.Add(tempnumber, Imaget)

            'this does the same but in one row
            'CoverArt_2008.Form1.PictureBox1.Image = New System.Drawing.Bitmap(New IO.MemoryStream(New System.Net.WebClient().DownloadData(thumbnail)))



            tempnumber = tempnumber + 1
            'MsgBox("haha")
        Next Node
        Return True
    End Function




End Class

Open in new window

0
BlackWolfNo1
Asked:
BlackWolfNo1
  • 3
  • 2
1 Solution
 
HainKurtSr. System AnalystCommented:
0
 
HainKurtSr. System AnalystCommented:
looks like you need to change urls here

n.AddNamespace("a", "http://webservices.amazon.com/AWSECommerceService/2005-10-05")
xDoc.Load("http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=" & Code & "&Operation=ItemSearch&SearchIndex=Music&ItemPage=1&ResponseGroup=ItemAttributes,Images&Keywords=" + Replace((Artist + " " + Album), " ", "%20"))
0
 
BlackWolfNo1Author Commented:
0
 
HainKurtSr. System AnalystCommented:
I guess it was a beta program link, and they updated the link...
0
 
BlackWolfNo1Author Commented:
they changed something in august 2009
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Protect Your Employees from Wi-Fi Threats

As Wi-Fi growth and popularity continues to climb, not everyone understands the risks that come with connecting to public Wi-Fi or even offering Wi-Fi to employees, visitors and guests. Download the resource kit to make sure your safe wherever business takes you!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now