104 response_json = loads(resp.text)
106 if not response_json:
109 for result
in response_json.get(
'results', []):
110 title = result[
'label']
111 url = result[
'url'].replace(
'file://' + mount_prefix, dl_prefix)
112 content =
'{}'.
format(result[
'snippet'])
115 item = {
'url': url,
'title': title,
'content': content,
'template':
'files.html'}
118 item[
'size'] = int(result[
'size'])
120 for parameter
in [
'filename',
'abstract',
'author',
'mtype',
'time']:
121 if result[parameter]:
122 item[parameter] = result[parameter]
125 if 'mtype' in result
and '/' in result[
'mtype']:
126 (mtype, subtype) = result[
'mtype'].split(
'/')
127 item[
'mtype'] = mtype
128 item[
'subtype'] = subtype
130 if mtype
in [
'audio',
'video']:
131 item[
'embedded'] = embedded_url.format(
132 ttype=mtype, url=quote(url.encode(
'utf8'),
'/:'), mtype=result[
'mtype']
135 if mtype
in [
'image']
and subtype
in [
'bmp',
'gif',
'jpeg',
'png']:
136 item[
'thumbnail'] = url
140 if 'nres' in response_json:
141 results.append({
'number_of_results': response_json[
'nres']})