fix trivia links
This commit is contained in:
parent
9a53675b20
commit
98795d3a25
2 changed files with 19 additions and 17 deletions
|
@ -131,21 +131,23 @@ class Imdb(models.Model):
|
|||
def data(self, request=None, timeout=ox.cache.cache_timeout):
|
||||
data = ox.web.imdb.Imdb(self.imdb, timeout=timeout)
|
||||
data = self.apply_patch(data)
|
||||
|
||||
def quote_string(string):
|
||||
return quote(string).replace('_', '%09').replace('%20', '_')
|
||||
|
||||
def fix_names(m):
|
||||
return '<a href="/name=%s">%s</a>' % (
|
||||
quote_string(m.group(2).encode('utf-8')), m.group(2)
|
||||
)
|
||||
|
||||
def fix_titles(m):
|
||||
return '<a href="/title=%s">%s</a>' % (
|
||||
quote_string(m.group(2).encode('utf-8')), m.group(2)
|
||||
)
|
||||
|
||||
def fix_links(t):
|
||||
def quote_string(string):
|
||||
return quote(string).replace('_', '%09').replace('%20', '_')
|
||||
def fix_names(m):
|
||||
return '<a href="/name=%s">%s</a>' % (
|
||||
quote_string(m.group(2).encode('utf-8')), m.group(2)
|
||||
)
|
||||
t = re.sub('<a href="(/name/.*?/)">(.*?)</a>', fix_names, t)
|
||||
|
||||
def fix_titles(m):
|
||||
return '<a href="/title=%s">%s</a>' % (
|
||||
quote_string(m.group(2).encode('utf-8')), m.group(2)
|
||||
)
|
||||
t = re.sub('<a href="(/title/.*?/)">(.*?)</a>', fix_titles, t)
|
||||
|
||||
t = re.sub('<a href="(/name/.*?)">(.*?)</a>', fix_names, t)
|
||||
t = re.sub('<a href="(/title/.*?)">(.*?)</a>', fix_titles, t)
|
||||
return t
|
||||
|
||||
if 'trivia' in data:
|
||||
|
|
|
@ -15,7 +15,7 @@ def getId(request, data):
|
|||
if movie:
|
||||
response['data'] = movie.json()
|
||||
else:
|
||||
response['status'] = {'text':'not found', 'code': 404}
|
||||
response['status'] = {'text': 'not found', 'code': 404}
|
||||
return render_to_json_response(response)
|
||||
actions.register(getId)
|
||||
|
||||
|
@ -35,7 +35,7 @@ def getData(request, data):
|
|||
data = i.data(request)
|
||||
response['data'] = data
|
||||
else:
|
||||
response['status'] = {'text':'not found', 'code': 404}
|
||||
response['status'] = {'text': 'not found', 'code': 404}
|
||||
|
||||
return render_to_json_response(response)
|
||||
actions.register(getData)
|
||||
|
|
Loading…
Reference in a new issue