예제 #1
0
 def amzSnarfer(self, irc, msg, match):
     r"http://www.amazon.com/exec/obidos/(?:tg/detail/-/|ASIN/)([^/]+)"
     if not self.registryValue('linkSnarfer', msg.args[0]):
         return
     match = match.group(1)
     attribs = {'ProductName' : 'title',
                'Manufacturer' : 'publisher',
                'Authors' : 'author',
                'MpaaRating' : 'mpaa',
                'Media' : 'media',
                'ReleaseDate' : 'date',
                'OurPrice' : 'price',
                'Artists' : 'artist',
               }
     s = '%(title)s; %(artist)s; %(author)s; %(mpaa)s; %(media)s; '\
         '%(date)s; %(publisher)s; price: %(price)s'
     channel = msg.args[0]
     region = self.registryValue('region', channel)
     bold = self.registryValue('bold', channel)
     try:
         item = amazon.searchByASIN(match, locale=region)
         res = self._genResults(s, attribs, item, False, bold)
         if res:
             res = format('%L', res)
             res = res.replace('; unknown', '')
             res = res.replace('; price: unknown', '')
             irc.reply(res, prefixNick=False)
             return
     except amazon.AmazonError, e:
         pass
예제 #2
0
    def asin(self, irc, msg, args, optlist, asin):
        """[--url] <asin>

        Returns the item matching the given ASIN number. If --url is
        specified, a link to amazon.com's page for the item will also be
        returned.
        """
        url = False
        for (option, _) in optlist:
            if option == 'url':
                url = True
        asin = asin.replace('-', '').replace(' ', '')
        attribs = {'ProductName' : 'title',
                   'OurPrice' : 'price',
                   'URL' : 'url'
                  }
        s = '%(title)s; price: %(price)s%(url)s'
        channel = msg.args[0]
        region = self.registryValue('region', channel)
        bold = self.registryValue('bold', channel)
        try:
            item = amazon.searchByASIN(asin, locale=region)
            res = self._genResults(s, attribs, item, url, bold)
            if res:
                irc.reply(format('%L', res))
                return
        except amazon.AmazonError, e:
            pass
 def run_get(self):
     self.result = None
     try:
         # get by ASIN
         try:
             self.result = amazon.searchByASIN(self.title, type='Large', locale=self.locale)
         except amazon.AmazonError, e:
             log.exception('Error retrieving results from amazon.')
     except IOError:
         log.exception('Error retrieving results from amazon.')
예제 #4
0
 def run_get(self):
     self.result = None
     try:
         # get by ASIN
         try:
             self.result = amazon.searchByASIN(self.title,
                                               type='Large',
                                               locale=self.locale)
         except amazon.AmazonError, e:
             log.exception('Error retrieving results from amazon.')
     except IOError:
         log.exception('Error retrieving results from amazon.')
 def run_get(self):
     self.result = None
     try:
         amazon.setLicense("04GDDMMXX8X9CJ1B22G2")
         # get by ASIN
         try:
             self.result = amazon.searchByASIN(self.title, type="Large", locale=self.locale)
         except amazon.AmazonError, e:
             self.debug.show(e.Message)
     except IOError:
         self.progress.dialog.hide()
         gutils.urllib_error(_("Connection error"), self.parent_window)
         self.suspend()
예제 #6
0
			title = fieldData
		elif (field.getAttribute ("name") == "authors"):
			authors = fieldData
		elif (field.getAttribute ("name") == "isbn"):
			isbn = fieldData
		elif (field.getAttribute ("name") == "upc"):
			upc = fieldData
		elif (field.getAttribute ("name") == "publisher"):
			publisher = fieldData

pythonBooks = None

if (isbn != None):
	isbn = replace (replace (isbn, "-", ""), " ", "");
	
	pythonBooks = amazon.searchByASIN (isbn, locale=searchLocale)

	if (pythonBooks[0] != None):
		book = pythonBooks[0]

# if (book == None and upc != None):
#	pythonBooks = amazon.searchByUPC (upc, locale=searchLocale)
#
#	if (pythonBooks[0] != None):
#		book = pythonBooks[0]

if (book == None and title != ""):
	query = "title:" + title
 
 	if (authors != ""):
 		query = query + " and author:" + authors
import sys, amazon

# Display author's name nicely.
def prettyName(arg):
    if type(arg) in (list, tuple):
        arg = ', '.join(arg[:-1]) + ' and ' + arg[-1]
    return arg

if __name__ == '__main__':

    # Get information.
    key, asin = sys.argv[1], sys.argv[2]
    amazon.setLicense(key)
    items = amazon.searchByASIN(asin)

    # Display information.
    for item in items:
        productName = item.ProductName
        ourPrice = item.OurPrice
        authors = prettyName(item.Authors.Author)
        print '%s: %s (%s)' % (authors, productName, ourPrice)
예제 #8
0
            title = fieldData
        elif (field.getAttribute("name") == "authors"):
            authors = fieldData
        elif (field.getAttribute("name") == "isbn"):
            isbn = fieldData
        elif (field.getAttribute("name") == "upc"):
            upc = fieldData
        elif (field.getAttribute("name") == "publisher"):
            publisher = fieldData

pythonBooks = None

if (isbn != None):
    isbn = replace(replace(isbn, "-", ""), " ", "")

    pythonBooks = amazon.searchByASIN(isbn, locale=searchLocale)

    if (pythonBooks[0] != None):
        book = pythonBooks[0]

# if (book == None and upc != None):
#	pythonBooks = amazon.searchByUPC (upc, locale=searchLocale)
#
#	if (pythonBooks[0] != None):
#		book = pythonBooks[0]

if (book == None and title != ""):
    query = "title:" + title

    if (authors != ""):
        query = query + " and author:" + authors
예제 #9
0
def get_name_by_asin(asin):
    return amazon.searchByASIN(asin)[0].ProductName
예제 #10
0
	if (searchLocale != "us"):
		searchMode = "books-" + searchLocale
		
	for searchField in fields:

		if (searchLocale != "" and searchField != ""): 
			collection = doc.createElement ("List")
			collection.setAttribute ("name", "Amazon Import")
			root.appendChild (collection)
		
			pythonBooks = None;
	
			if searchField == "authors":
				pythonBooks = amazon.searchByAuthor (query, locale=searchLocale, mode=searchMode)
			elif searchField == "asin":
				pythonBooks = amazon.searchByASIN (query, locale=searchLocale, mode=searchMode)
			elif searchField == "upc":
				pythonBooks = amazon.searchByUPC (query, locale=searchLocale, mode=searchMode)
			else:
				pythonBooks = amazon.searchByKeyword (query, locale=searchLocale, mode=searchMode)

			for book in pythonBooks:
				bookElement = doc.createElement ("Book")
				bookElement.setAttribute ("title", book.ProductName)
			
				for key in fieldMap.keys():
					name = fieldMap[key]
				
					if name == None:
						name = key