mirror of https://gitlab.com/bashrc2/epicyon
				
				
				
			Buy button logic
							parent
							
								
									9d844e641b
								
							
						
					
					
						commit
						78bc0937e2
					
				|  | @ -2118,23 +2118,29 @@ def get_buy_links(post_json_object: str, translate: {}, buy_sites: {}) -> {}: | ||||||
|         if 'html' not in item['mediaType']: |         if 'html' not in item['mediaType']: | ||||||
|             continue |             continue | ||||||
|         item_name = item['name'] |         item_name = item['name'] | ||||||
|  |         # The name should not be excessively long | ||||||
|  |         if len(item_name) > 32: | ||||||
|  |             continue | ||||||
|         # there should be no html in the name |         # there should be no html in the name | ||||||
|         if remove_html(item_name) != item_name: |         if remove_html(item_name) != item_name: | ||||||
|             continue |             continue | ||||||
|         # there should be no html in the link |         # there should be no html in the link | ||||||
|         if '<' in item['href'] or \ |         if '<' in item['href'] or \ | ||||||
|            '://' not in item['href']: |            '://' not in item['href'] or \ | ||||||
|  |            ' ' in item['href']: | ||||||
|             continue |             continue | ||||||
|         # does the name indicate buying? |         if buy_sites: | ||||||
|         for buy_str in buy_strings: |             # limited to an allowlist of buying sites | ||||||
|             if buy_str in item_name.lower(): |             for site, buy_domain in buy_sites.items(): | ||||||
|                 links[item_name] = item['href'] |                 if buy_domain in item['href']: | ||||||
|                 continue |                     links[site.title()] = item['href'] | ||||||
|         # is the link on an allowlist of sites? |                     continue | ||||||
|         for site, keyword in buy_sites.items(): |         else: | ||||||
|             if keyword in item['href']: |             # The name only needs to indicate that this is a buy link | ||||||
|                 links[site.title()] = item['href'] |             for buy_str in buy_strings: | ||||||
|                 continue |                 if buy_str in item_name.lower(): | ||||||
|  |                     links[item_name] = item['href'] | ||||||
|  |                     continue | ||||||
|     return links |     return links | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue