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):
|
def data(self, request=None, timeout=ox.cache.cache_timeout):
|
||||||
data = ox.web.imdb.Imdb(self.imdb, timeout=timeout)
|
data = ox.web.imdb.Imdb(self.imdb, timeout=timeout)
|
||||||
data = self.apply_patch(data)
|
data = self.apply_patch(data)
|
||||||
def fix_links(t):
|
|
||||||
def quote_string(string):
|
def quote_string(string):
|
||||||
return quote(string).replace('_', '%09').replace('%20', '_')
|
return quote(string).replace('_', '%09').replace('%20', '_')
|
||||||
|
|
||||||
def fix_names(m):
|
def fix_names(m):
|
||||||
return '<a href="/name=%s">%s</a>' % (
|
return '<a href="/name=%s">%s</a>' % (
|
||||||
quote_string(m.group(2).encode('utf-8')), m.group(2)
|
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):
|
def fix_titles(m):
|
||||||
return '<a href="/title=%s">%s</a>' % (
|
return '<a href="/title=%s">%s</a>' % (
|
||||||
quote_string(m.group(2).encode('utf-8')), m.group(2)
|
quote_string(m.group(2).encode('utf-8')), m.group(2)
|
||||||
)
|
)
|
||||||
t = re.sub('<a href="(/title/.*?/)">(.*?)</a>', fix_titles, t)
|
|
||||||
|
|
||||||
|
def fix_links(t):
|
||||||
|
t = re.sub('<a href="(/name/.*?)">(.*?)</a>', fix_names, t)
|
||||||
|
t = re.sub('<a href="(/title/.*?)">(.*?)</a>', fix_titles, t)
|
||||||
return t
|
return t
|
||||||
|
|
||||||
if 'trivia' in data:
|
if 'trivia' in data:
|
||||||
|
|
|
@ -15,7 +15,7 @@ def getId(request, data):
|
||||||
if movie:
|
if movie:
|
||||||
response['data'] = movie.json()
|
response['data'] = movie.json()
|
||||||
else:
|
else:
|
||||||
response['status'] = {'text':'not found', 'code': 404}
|
response['status'] = {'text': 'not found', 'code': 404}
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(getId)
|
actions.register(getId)
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ def getData(request, data):
|
||||||
data = i.data(request)
|
data = i.data(request)
|
||||||
response['data'] = data
|
response['data'] = data
|
||||||
else:
|
else:
|
||||||
response['status'] = {'text':'not found', 'code': 404}
|
response['status'] = {'text': 'not found', 'code': 404}
|
||||||
|
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(getData)
|
actions.register(getData)
|
||||||
|
|
Loading…
Reference in a new issue