128def response(resp):
129 results = []
130
131 json = resp.json()
132
133 for result in json["items"]:
134
135 uploaded = result.get("uploaded", -1)
136
137 item = {
138
139 "url": _frontend_url() + result.get("url", ""),
140 "title": result.get("title", ""),
141 "publishedDate": parser.parse(time.ctime(uploaded / 1000)) if uploaded != -1 else None,
142 "iframe_src": _frontend_url() + '/embed' + result.get("url", ""),
143 "views": humanize_number(result["views"]),
144 }
145 length = result.get("duration")
146 if length:
147 item["length"] = datetime.timedelta(seconds=length)
148
149 if piped_filter == 'videos':
150 item["template"] = "videos.html"
151
152 item["content"] = result.get("shortDescription", "") or ""
153 item["thumbnail"] = result.get("thumbnail", "")
154
155 elif piped_filter == 'music_songs':
156 item["template"] = "default.html"
157 item["thumbnail"] = result.get("thumbnail", "")
158 item["content"] = result.get("uploaderName", "") or ""
159
160 results.append(item)
161
162 results.append(
163 {
164 "engine_data": json["nextpage"],
165 "key": "nextpage",
166 }
167 )
168 return results