コード例 #1
0
 def run_search(self):
     self.result = []
     try:
         try:
             tmp = amazon.searchByTitle(self.title, type='ItemAttributes', product_line='Video', locale=self.locale, page=1)
             self.result.append(tmp)
             if hasattr(tmp, 'TotalPages'):
                 pages = int(tmp.TotalPages)
                 page = 2
                 while page <= pages and page < 11:
                     tmp = amazon.searchByTitle(self.title, type='ItemAttributes', product_line='Video', locale=self.locale, page=page)
                     self.result.append(tmp)
                     page = page + 1
         except amazon.AmazonError:
             log.exception('Error retrieving results from amazon.')
         # if all digits then try to find an EAN / UPC
         if self.title.isdigit():
             if len(self.title) == 13:
                 try:
                     tmp = amazon.searchByEAN(self.title, type='ItemAttributes', product_line='Video', locale=self.locale)
                     self.result.append(tmp)
                 except amazon.AmazonError, e:
                     log.exception('Error retrieving results from amazon.')
             elif len(self.title) == 12:
                 try:
                     tmp = amazon.searchByUPC(self.title, type='ItemAttributes', product_line='Video', locale=self.locale)
                     self.result.append(tmp)
                 except amazon.AmazonError, e:
                     log.exception('Error retrieving results from amazon.')
コード例 #2
0
 def run_search(self):
     self.result = []
     try:
         amazon.setLicense('04GDDMMXX8X9CJ1B22G2')
         try:
             tmp = amazon.searchByTitle(self.title, type='ItemAttributes', product_line='Video', locale=self.locale, page=1)
             self.result.append(tmp)
             if hasattr(tmp, 'TotalPages'):
                 pages = int(tmp.TotalPages)
                 page = 2
                 while page <= pages and page < 11:
                     tmp = amazon.searchByTitle(self.title, type='ItemAttributes', product_line='Video', locale=self.locale, page=page)
                     self.result.append(tmp)
                     page = page + 1
         except amazon.AmazonError, e:
             log.error(e.Message)
         # if all digits then try to find an EAN / UPC
         if self.title.isdigit():
             if len(self.title) == 13:
                 try:
                     tmp = amazon.searchByEAN(self.title, type='ItemAttributes', product_line='Video', locale=self.locale)
                     self.result.append(tmp)
                 except amazon.AmazonError, e:
                     log.error(e.Message)
             elif len(self.title) == 12:
                 try:
                     tmp = amazon.searchByUPC(self.title, type='ItemAttributes', product_line='Video', locale=self.locale)
                     self.result.append(tmp)
                 except amazon.AmazonError, e:
                     log.error(e.Message)
コード例 #3
0
ファイル: plugin.py プロジェクト: D0MF/supybot-plugins-1
    def upc(self, irc, msg, args, optlist, upc):
        """[--url] <upc>

        Returns the item matching the given UPC number.  If --url is
        specified, a link to amazon.com's page for the item will also be
        returned.  Only items in the following categories may be found via upc
        search: music, classical, software, dvd, video, vhs, electronics,
        pc-hardware, and photo.
        """
        url = False
        for (option, _) in optlist:
            if option == 'url':
                url = True
        upc = upc.replace('-', '').replace(' ', '')
        attribs = {'ProductName' : 'title',
                   'Manufacturer' : 'manufacturer',
                   'OurPrice' : 'price',
                   'URL' : 'url'
                  }
        s = '%(title)s %(manufacturer)s; price: %(price)s%(url)s'
        channel = msg.args[0]
        region = self.registryValue('region', channel)
        bold = self.registryValue('bold', channel)
        try:
            item = amazon.searchByUPC(upc, locale=region)
            res = self._genResults(s, attribs, item, url, bold)
            if res:
                irc.reply(format('%L', res))
                return
        except amazon.AmazonError, e:
            pass
コード例 #4
0
    def upc(self, irc, msg, args, optlist, upc):
        """[--url] <upc>

        Returns the item matching the given UPC number.  If --url is
        specified, a link to amazon.com's page for the item will also be
        returned.  Only items in the following categories may be found via upc
        search: music, classical, software, dvd, video, vhs, electronics,
        pc-hardware, and photo.
        """
        url = False
        for (option, _) in optlist:
            if option == 'url':
                url = True
        upc = upc.replace('-', '').replace(' ', '')
        attribs = {
            'ProductName': 'title',
            'Manufacturer': 'manufacturer',
            'OurPrice': 'price',
            'URL': 'url'
        }
        s = '%(title)s %(manufacturer)s; price: %(price)s%(url)s'
        channel = msg.args[0]
        region = self.registryValue('region', channel)
        bold = self.registryValue('bold', channel)
        try:
            item = amazon.searchByUPC(upc, locale=region)
            res = self._genResults(s, attribs, item, url, bold)
            if res:
                irc.reply(format('%L', res))
                return
        except amazon.AmazonError, e:
            pass
コード例 #5
0
 def run_search(self):
     self.result = []
     try:
         try:
             tmp = amazon.searchByTitle(self.title,
                                        type='ItemAttributes',
                                        product_line='Video',
                                        locale=self.locale,
                                        page=1)
             self.result.append(tmp)
             if hasattr(tmp, 'TotalPages'):
                 pages = int(tmp.TotalPages)
                 page = 2
                 while page <= pages and page < 11:
                     tmp = amazon.searchByTitle(self.title,
                                                type='ItemAttributes',
                                                product_line='Video',
                                                locale=self.locale,
                                                page=page)
                     self.result.append(tmp)
                     page = page + 1
         except amazon.AmazonError:
             log.exception('Error retrieving results from amazon.')
         # if all digits then try to find an EAN / UPC
         if self.title.isdigit():
             if len(self.title) == 13:
                 try:
                     tmp = amazon.searchByEAN(self.title,
                                              type='ItemAttributes',
                                              product_line='Video',
                                              locale=self.locale)
                     self.result.append(tmp)
                 except amazon.AmazonError, e:
                     log.exception('Error retrieving results from amazon.')
             elif len(self.title) == 12:
                 try:
                     tmp = amazon.searchByUPC(self.title,
                                              type='ItemAttributes',
                                              product_line='Video',
                                              locale=self.locale)
                     self.result.append(tmp)
                 except amazon.AmazonError, e:
                     log.exception('Error retrieving results from amazon.')
コード例 #6
0
		
	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

					value = None