■ ■ ■ ■ ■ ■
changedetectionio/fetch_processor/image.py
| skipped 76 lines |
77 | 77 | | proxy_args = self.set_proxy_from_list(watch) |
78 | 78 | | fetcher = klass(proxy_override=proxy_args) |
79 | 79 | | |
80 | | - | fetcher.run(url, timeout, request_headers, request_body, request_method, ignore_status_codes) |
| 80 | + | fetcher.run( |
| 81 | + | ignore_status_codes=ignore_status_codes, |
| 82 | + | request_body=request_body, |
| 83 | + | request_headers=request_headers, |
| 84 | + | request_method=request_method, |
| 85 | + | current_css_filter=watch.get('css_filter'), |
| 86 | + | timeout=timeout, |
| 87 | + | url=url |
| 88 | + | ) |
| 89 | + | |
81 | 90 | | fetcher.quit() |
82 | 91 | | |
83 | 92 | | # if not image/foobar in mimetype |
| skipped 5 lines |
89 | 98 | | if 'image' in fetcher.headers['content-type']: |
90 | 99 | | self.contents = fetcher.raw_content |
91 | 100 | | else: |
92 | | - | # should be element if the filter is set, no? |
93 | | - | self.contents = fetcher.screenshot |
| 101 | + | self.contents = fetcher.element_screenshot if fetcher.element_screenshot else fetcher.screenshot |
94 | 102 | | |
95 | 103 | | # Used for visual-selector |
96 | 104 | | self.xpath_data = fetcher.xpath_data |
97 | 105 | | self.screenshot = fetcher.screenshot |
98 | 106 | | |
| 107 | + | now = time.time() |
99 | 108 | | image = Image.open(io.BytesIO(self.contents)) |
100 | 109 | | |
101 | 110 | | # @todo different choice? |
102 | 111 | | # https://github.com/JohannesBuchner/imagehash#references |
103 | 112 | | fetched_hash = str(imagehash.average_hash(image)) |
| 113 | + | print(uuid, "Time to image hash", time.time() - now) |
104 | 114 | | |
105 | 115 | | # The main thing that all this at the moment comes down to :) |
106 | 116 | | if watch['previous_md5'] != fetched_hash: |
| skipped 11 lines |