mirror of
				https://github.com/janeczku/calibre-web
				synced 2025-10-30 23:03:02 +00:00 
			
		
		
		
	Update with all amazon site that diverge in domain style
This commit is contained in:
		 Webysther Sperandio
					Webysther Sperandio
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							1eb9cd44dc
						
					
				
				
					commit
					fea8a9d40d
				
			
							
								
								
									
										22
									
								
								cps/db.py
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								cps/db.py
									
									
									
									
									
								
							| @@ -102,6 +102,16 @@ class Identifiers(Base): | |||||||
|     type = Column(String(collation='NOCASE'), nullable=False, default="isbn") |     type = Column(String(collation='NOCASE'), nullable=False, default="isbn") | ||||||
|     val = Column(String(collation='NOCASE'), nullable=False) |     val = Column(String(collation='NOCASE'), nullable=False) | ||||||
|     book = Column(Integer, ForeignKey('books.id'), nullable=False) |     book = Column(Integer, ForeignKey('books.id'), nullable=False) | ||||||
|  |     amazon = { | ||||||
|  |         "jp": "co.jp",  | ||||||
|  |         "uk": "co.uk",  | ||||||
|  |         "us": "com",  | ||||||
|  |         "au": "com.au",  | ||||||
|  |         "be": "com.be",  | ||||||
|  |         "br": "com.br",  | ||||||
|  |         "tr": "com.tr",  | ||||||
|  |         "mx": "com.mx", | ||||||
|  |     } | ||||||
|  |  | ||||||
|     def __init__(self, val, id_type, book): |     def __init__(self, val, id_type, book): | ||||||
|         super().__init__() |         super().__init__() | ||||||
| @@ -114,7 +124,11 @@ class Identifiers(Base): | |||||||
|         if format_type == 'amazon': |         if format_type == 'amazon': | ||||||
|             return "Amazon" |             return "Amazon" | ||||||
|         elif format_type.startswith("amazon_"): |         elif format_type.startswith("amazon_"): | ||||||
|             return "Amazon.{0}".format(format_type[7:].lower().replace("uk","co.uk")) |             label_amazon = "Amazon.{0}" | ||||||
|  |             country_code = format_type[7:].lower() | ||||||
|  |             if country_code not in self.amazon: | ||||||
|  |                 return label_amazon.format(country_code) | ||||||
|  |             return label_amazon.format(self.amazon[country_code]) | ||||||
|         elif format_type == "isbn": |         elif format_type == "isbn": | ||||||
|             return "ISBN" |             return "ISBN" | ||||||
|         elif format_type == "doi": |         elif format_type == "doi": | ||||||
| @@ -149,7 +163,11 @@ class Identifiers(Base): | |||||||
|         if format_type == "amazon" or format_type == "asin": |         if format_type == "amazon" or format_type == "asin": | ||||||
|             return "https://amazon.com/dp/{0}".format(self.val) |             return "https://amazon.com/dp/{0}".format(self.val) | ||||||
|         elif format_type.startswith('amazon_'): |         elif format_type.startswith('amazon_'): | ||||||
|             return "https://amazon.{0}/dp/{1}".format(format_type[7:].lower().replace("uk","co.uk"), self.val) |             link_amazon = "https://amazon.{0}/dp/{1}" | ||||||
|  |             country_code = format_type[7:].lower() | ||||||
|  |             if country_code not in self.amazon: | ||||||
|  |                 return link_amazon.format(country_code, self.val) | ||||||
|  |             return link_amazon.format(self.amazon[country_code], self.val) | ||||||
|         elif format_type == "isbn": |         elif format_type == "isbn": | ||||||
|             return "https://www.worldcat.org/isbn/{0}".format(self.val) |             return "https://www.worldcat.org/isbn/{0}".format(self.val) | ||||||
|         elif format_type == "doi": |         elif format_type == "doi": | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user