Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
>>> URI = "http://api2.aupeo.com/v2/identification"
>>> h = httplib2.Http()
>>> h.add_credentials('jonas', '[secret]')
>>> headers = {'Content-Type': 'application/xml; charset=utf-8'}
>>>
>>> track_xml = xmlbuilder.builder(version='1.0', encoding='utf-8')
>>> with track_xml.track:
... with track_xml.artist:
... track_xml.name('Cueio Lim\xc3\xa3o')
... with track_xml.album:
... track_xml.title('Paraguayos')
...
>>> resp, content = h.request(URI, "POST", body=str(track_xml), headers=headers)
>>> print content
<?xml version="1.0" encoding="utf-8"?>
<tracks>
<track uri="/v2/tracks/13457421">
<similarity>0.943</similarity>
<title>Rake Me Back To Piau+¡</title>
<artist uri="/v2/artists/1018531">
<name>Cueio Lim+úo</name>
</artist>
<album uri="/v2/albums/1297982">
<title>Paraguayo</title>
</album>
</track>
<track uri="/v2/tracks/13456841">
<similarity>0.943</similarity>
<title>O Thirso</title>
<artist uri="/v2/artists/1018531">
<name>Cueio Lim+úo</name>
</artist>
<album uri="/v2/albums/1297982">
<title>Paraguayo</title>
</album>
</track>
...
</tracks>
>>> artist_xml = xmlbuilder.builder(version='1.0', encoding='utf-8')
>>> with artist_xml.artist:
... artist_xml.name('adonna')
...
>>> resp, content = h.request(URI, "POST", body=str(artist_xml), headers=headers)
>>> print content
<?xml version="1.0" encoding="utf-8"?>
<artists>
<artist uri="/v2/artists/64565">
<similarity>0.913</similarity>
<name>Madonna</name>
</artist>
<artist uri="/v2/artists/213194">
<similarity>0.913</similarity>
<name>Ladonna</name>
</artist>
...
</artists>
>>> album_xml = xmlbuilder.builder(version='1.0', encoding='utf-8')
>>> with album_xml.album:
... album_xml.title('Paaguayo')
...
>>> resp, content = h.request(URI, "POST", body=str(album_xml), headers=headers)
>>> print content
<?xml version="1.0" encoding="utf-8"?>
<albums>
<album uri="/v2/albums/1297982">
<similarity>0.802</similarity>
<title>Paraguayo</title>
<artist uri="/v2/artists/1018531">
<name>Cueio Lim+úo</name>
</artist>
</album>
<album uri="/v2/albums/425238">
<similarity>0.714</similarity>
<title>Paraguay</title>
</album>
<album uri="/v2/albums/426829">
<similarity>0.714</similarity>
<title>Paraguay</title>
<artist uri="/v2/artists/373732">
<name>Los Chiriguanos del Paraguay</name>
</artist>
</album>
...
</albums>
>>> album_xml = xmlbuilder.builder(version='1.0', encoding='utf-8')
>>> with album_xml.album:
... album_xml.title('Paraguayos')
... with album_xml.artist:
... album_xml.name('cueio limao')
...
>>> resp, content = h.request(URI, "POST", body=str(album_xml), headers=headers)
>>> print content
<?xml version="1.0" encoding="utf-8"?>
<albums>
<album uri="/v2/albums/1297982">
<similarity>0.943</similarity>
<title>Paraguayo</title>
<artist uri="/v2/artists/1018531">
<name>Cueio Lim+úo</name>
</artist>
</album>
</albums>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.