(resp)
| 44 | |
| 45 | |
| 46 | def response(resp): |
| 47 | results = [] |
| 48 | dom = html.fromstring(resp.text) |
| 49 | results_dom = dom.xpath('//li[contains(@class, "video-listing-entry")]') |
| 50 | |
| 51 | if not results_dom: |
| 52 | return [] |
| 53 | |
| 54 | for result_dom in results_dom: |
| 55 | url = base_url + extract_text(result_dom.xpath(url_xpath)) |
| 56 | thumbnail = extract_text(result_dom.xpath(thumbnail_xpath)) |
| 57 | title = extract_text(result_dom.xpath(title_xpath)) |
| 58 | p_date = extract_text(result_dom.xpath(published_date)) |
| 59 | # fix offset date for line 644 webapp.py check |
| 60 | fixed_date = datetime.strptime(p_date, '%Y-%m-%dT%H:%M:%S%z') |
| 61 | earned = extract_text(result_dom.xpath(earned_xpath)) |
| 62 | views = extract_text(result_dom.xpath(views_xpath)) |
| 63 | rumbles = extract_text(result_dom.xpath(rumbles_xpath)) |
| 64 | author = extract_text(result_dom.xpath(author_xpath)) |
| 65 | length = extract_text(result_dom.xpath(length_xpath)) |
| 66 | if earned: |
| 67 | content = f"{views} views - {rumbles} rumbles - ${earned}" |
| 68 | else: |
| 69 | content = f"{views} views - {rumbles} rumbles" |
| 70 | |
| 71 | results.append({ |
| 72 | 'url': url, |
| 73 | 'title': title, |
| 74 | 'content': content, |
| 75 | 'author': author, |
| 76 | 'length': length, |
| 77 | 'template': 'videos.html', |
| 78 | 'publishedDate': fixed_date, |
| 79 | 'thumbnail': thumbnail, |
| 80 | }) |
| 81 | return results |
nothing calls this directly
no test coverage detected