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)
 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.')
Beispiel #3
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.')