🤬
  • ■ ■ ■ ■ ■
    changedetectionio/fetch_processor/__init__.py
    skipped 2 lines
    3 3  class fetch_processor():
    4 4   contents = b''
    5 5   screenshot = None
    6  - history_artifact_suffix = 'txt'
    7 6   
    8 7   """
    9 8   base class for all fetch processors
    skipped 35 lines
  • ■ ■ ■ ■ ■ ■
    changedetectionio/fetch_processor/image.py
    skipped 79 lines
    80 80   
    81 81   update_obj["last_check_status"] = fetcher.get_last_status_code()
    82 82   
     83 + self.contents = fetcher.raw_content
     84 + 
    83 85   image = Image.open(io.BytesIO(fetcher.raw_content))
    84 86   
    85 87   # @todo different choice?
    skipped 10 lines
    96 98   # On the first run of a site, watch['previous_md5'] will be None, set it the current one.
    97 99   if not watch.get('previous_md5'):
    98 100   watch['previous_md5'] = fetched_hash
    99  - 
    100  - #self.contents = fetcher.screenshot
    101 101   
    102 102   return changed_detected, update_obj
    103 103   
  • ■ ■ ■ ■ ■
    changedetectionio/model/Watch.py
    skipped 145 lines
    146 146   bump = self.history
    147 147   return self.__newest_history_key
    148 148   
    149  - def save_history_artifact(self, contents: bytes, timestamp, suffix='txt'):
     149 + def save_history_artifact(self, contents: bytes, timestamp):
    150 150   import uuid
    151 151   import logging
     152 + import magic
     153 + import re
     154 + suffix = 'bin'
     155 + # detect extension type
     156 + mtype = magic.from_buffer(contents, mime=True)
     157 + if mtype:
     158 + r = re.search(r'image/(\w+)', mtype, re.IGNORECASE)
     159 + if r:
     160 + suffix = r.group(1)
    152 161   
    153 162   output_path = "{}/{}".format(self.__datastore_path, self['uuid'])
    154 163   
    skipped 99 lines
  • ■ ■ ■ ■
    changedetectionio/update_worker.py
    skipped 269 lines
    270 270   # For the FIRST time we check a site, or a change detected, save the snapshot.
    271 271   if changed_detected or not watch['last_checked']:
    272 272   # A change was detected
    273  - watch.save_history_artifact(contents=update_handler.contents, timestamp=str(round(time.time())), suffix=update_handler.history_artifact_suffix)
     273 + watch.save_history_artifact(contents=update_handler.contents, timestamp=str(round(time.time())))
    274 274   
    275 275   self.datastore.update_watch(uuid=uuid, update_obj=update_obj)
    276 276   
    skipped 36 lines
  • ■ ■ ■ ■ ■
    requirements.txt
    skipped 45 lines
    46 46   
    47 47  imagehash ~= 4.3.0
    48 48  pillow
     49 +python-magic
    49 50   
Please wait...
Page is in error, reload to recover