def _doAmazonSearch(artist, title): """ do an amazon search, and find the correct album by looking through the Tracks of all albums """ title = title.replace(' (from Aural Moon)', '') #print "Search for artist: %s and title: %s"%(artist, title) d = amazon.searchByArtist(artist) #print "Found %s"%len(d) if not d: return {} # continue title = title.strip().lower() album = None for b in d: if title in [x.lower() for x in b.Tracks.Track]: album = b break if album: data = { 'URL': '', 'ImageUrlLarge': '', 'ImageUrlMedium': '', 'Tracks': [], 'OurPrice': '', 'ProductName': '' } data['URL'] = str(album.URL) if 'ImageUrlLarge' in dir(album): data['ImageUrlLarge'] = str(album.ImageUrlLarge) if 'ImageUrlMedium' in dir(album): data['ImageUrlMedium'] = str(album.ImageUrlMedium) if 'ImageUrlSmall' in dir(album): data['ImageUrlSmall'] = str(album.ImageUrlSmall) if 'Tracks' in dir(album): data['Tracks'] = [str(x) for x in album.Tracks.Track] if 'OurPrice' in dir(album): data['OurPrice'] = str(album.OurPrice) if 'ProductName' in dir(album): data['ProductName'] = str(album.ProductName) return data else: return {}
def _doAmazonSearch(artist, title): """ do an amazon search, and find the correct album by looking through the Tracks of all albums """ title = title.replace(' (from Aural Moon)','') #print "Search for artist: %s and title: %s"%(artist, title) d = amazon.searchByArtist(artist) #print "Found %s"%len(d) if not d: return {} # continue title = title.strip().lower() album = None for b in d: if title in [x.lower() for x in b.Tracks.Track]: album = b break if album: data = {'URL':'', 'ImageUrlLarge':'', 'ImageUrlMedium':'', 'Tracks':[], 'OurPrice':'', 'ProductName':''} data['URL'] = str(album.URL) if 'ImageUrlLarge' in dir(album): data['ImageUrlLarge'] = str(album.ImageUrlLarge) if 'ImageUrlMedium' in dir(album): data['ImageUrlMedium'] = str(album.ImageUrlMedium) if 'ImageUrlSmall' in dir(album): data['ImageUrlSmall'] = str(album.ImageUrlSmall) if 'Tracks' in dir(album): data['Tracks'] = [str(x) for x in album.Tracks.Track] if 'OurPrice' in dir(album): data['OurPrice'] = str(album.OurPrice) if 'ProductName' in dir(album): data['ProductName'] = str(album.ProductName) return data else: return {}
def artist(self, irc, msg, args, optlist, artist): """[--url] [--{music,classical}] <artist> Returns a list of items by the given artist. If --url is specified, a link to amazon.com's page for the match will also be returned. The search defaults to using --music. """ url = False product = None for (option, _) in optlist: if option == 'url': url = True else: product = option product = product or 'music' attribs = { 'ProductName': 'title', 'Manufacturer': 'publisher', 'Artists': 'artist', 'Media': 'media', 'OurPrice': 'price', 'URL': 'url' } s = '%(title)s (%(media)s), by %(artist)s; published by ' \ '%(publisher)s; price: %(price)s%(url)s' channel = msg.args[0] region = self.registryValue('region', channel) bold = self.registryValue('bold', channel) try: items = amazon.searchByArtist(artist, product_line=product, locale=region) res = self._genResults(s, attribs, items, url, bold) if res: irc.reply(format('%L', res)) return except amazon.AmazonError, e: pass
def artist(self, irc, msg, args, optlist, artist): """[--url] [--{music,classical}] <artist> Returns a list of items by the given artist. If --url is specified, a link to amazon.com's page for the match will also be returned. The search defaults to using --music. """ url = False product = None for (option, _) in optlist: if option == 'url': url = True else: product = option product = product or 'music' attribs = {'ProductName' : 'title', 'Manufacturer' : 'publisher', 'Artists' : 'artist', 'Media' : 'media', 'OurPrice' : 'price', 'URL' : 'url' } s = '%(title)s (%(media)s), by %(artist)s; published by ' \ '%(publisher)s; price: %(price)s%(url)s' channel = msg.args[0] region = self.registryValue('region', channel) bold = self.registryValue('bold', channel) try: items = amazon.searchByArtist(artist, product_line=product, locale=region) res = self._genResults(s, attribs, items, url, bold) if res: irc.reply(format('%L', res)) return except amazon.AmazonError, e: pass