|
|
@ -1,4 +1,5 @@
|
|
|
|
import datetime
|
|
|
|
import datetime
|
|
|
|
|
|
|
|
import unicodedata
|
|
|
|
|
|
|
|
|
|
|
|
import dateutil.parser
|
|
|
|
import dateutil.parser
|
|
|
|
import requests
|
|
|
|
import requests
|
|
|
@ -171,9 +172,15 @@ class Commands(object):
|
|
|
|
return clip
|
|
|
|
return clip
|
|
|
|
|
|
|
|
|
|
|
|
def query_cheese_com(self, query):
|
|
|
|
def query_cheese_com(self, query):
|
|
|
|
|
|
|
|
def remove_accents(s):
|
|
|
|
|
|
|
|
s = unicodedata.normalize('NFKD', s)
|
|
|
|
|
|
|
|
return ''.join([c for c in s if not unicodedata.combining(c)])
|
|
|
|
cc = CheeseCom()
|
|
|
|
cc = CheeseCom()
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
result = cc.query(query)
|
|
|
|
result = cc.query(query)
|
|
|
|
|
|
|
|
except CheeseComError:
|
|
|
|
|
|
|
|
result = cc.query(remove_accents(query))
|
|
|
|
except CheeseComError:
|
|
|
|
except CheeseComError:
|
|
|
|
raise CommandError('couldn\'t find exact match on cheese.com')
|
|
|
|
raise CommandError('couldn\'t find exact match on cheese.com')
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|