[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to get Album art on amazon.com

Posted on 2009-12-27
6
Medium Priority
?
1,770 Views
Last Modified: 2014-11-12
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
Comment
Question by:BlackWolfNo1
  • 3
  • 2
5 Comments
 
LVL 61

Expert Comment

by:HainKurt
ID: 26127943
0
 
LVL 61

Accepted Solution

by:
HainKurt earned 2000 total points
ID: 26127954
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
 
LVL 61

Expert Comment

by:HainKurt
ID: 26129060
I guess it was a beta program link, and they updated the link...
0
 

Author Comment

by:BlackWolfNo1
ID: 26163162
they changed something in august 2009
0

Featured Post

A Cyber Security RX to Protect Your Organization

Join us on December 13th for a webinar to learn how medical providers can defend against malware with a cyber security "Rx" that supports a healthy technology adoption plan for every healthcare organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Often times it's very very easy to extend a volume on a Linux instance in AWS, but impossible to shrink it. I wanted to contribute to the experts-exchange community a way of providing a procedure that works on an AWS instance. It can also be used on…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question