code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def cleanup_error_artifacts(uuid, datastore): """Helper function to clean up error artifacts""" cleanup_files = ["last-error-screenshot.png", "last-error.txt"] for f in cleanup_files: full_path = os.path.join(datastore.datastore_path, uuid, f) if os.path.isfile(full_path): os.unl...
Helper function to clean up error artifacts
cleanup_error_artifacts
python
dgtlmoon/changedetection.io
changedetectionio/async_update_worker.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/async_update_worker.py
Apache-2.0
async def send_content_changed_notification(watch_uuid, notification_q, datastore): """Helper function to queue notifications using the new notification service""" try: from changedetectionio.notification_service import create_notification_service # Create notification service instance ...
Helper function to queue notifications using the new notification service
send_content_changed_notification
python
dgtlmoon/changedetection.io
changedetectionio/async_update_worker.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/async_update_worker.py
Apache-2.0
async def send_filter_failure_notification(watch_uuid, notification_q, datastore): """Helper function to send filter failure notifications using the new notification service""" try: from changedetectionio.notification_service import create_notification_service # Create notification serv...
Helper function to send filter failure notifications using the new notification service
send_filter_failure_notification
python
dgtlmoon/changedetection.io
changedetectionio/async_update_worker.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/async_update_worker.py
Apache-2.0
async def send_step_failure_notification(watch_uuid, step_n, notification_q, datastore): """Helper function to send step failure notifications using the new notification service""" try: from changedetectionio.notification_service import create_notification_service # Create notification ...
Helper function to send step failure notifications using the new notification service
send_step_failure_notification
python
dgtlmoon/changedetection.io
changedetectionio/async_update_worker.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/async_update_worker.py
Apache-2.0
def login_optionally_required(func): """ If password authentication is enabled, verify the user is logged in. To be used as a decorator for routes that should optionally require login. This version is blueprint-friendly as it uses current_app instead of directly accessing app. """ @wraps(func) ...
If password authentication is enabled, verify the user is logged in. To be used as a decorator for routes that should optionally require login. This version is blueprint-friendly as it uses current_app instead of directly accessing app.
login_optionally_required
python
dgtlmoon/changedetection.io
changedetectionio/auth_decorator.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/auth_decorator.py
Apache-2.0
def get_uuid_position(self, target_uuid): """ Find the position of a watch UUID in the priority queue. Optimized for large queues - O(n) complexity instead of O(n log n). Args: target_uuid: The UUID to search for Returns: dict: Contai...
Find the position of a watch UUID in the priority queue. Optimized for large queues - O(n) complexity instead of O(n log n). Args: target_uuid: The UUID to search for Returns: dict: Contains position info or None if not found ...
get_uuid_position
python
dgtlmoon/changedetection.io
changedetectionio/custom_queue.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/custom_queue.py
Apache-2.0
def get_queue_summary(self): """ Get a quick summary of queue state without expensive operations. O(n) complexity - fast even for large queues. Returns: dict: Queue summary statistics """ with self.mutex: queue_list = list(self.queue) ...
Get a quick summary of queue state without expensive operations. O(n) complexity - fast even for large queues. Returns: dict: Queue summary statistics
get_queue_summary
python
dgtlmoon/changedetection.io
changedetectionio/custom_queue.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/custom_queue.py
Apache-2.0
def get_uuid_position(self, target_uuid): """ Find the position of a watch UUID in the async priority queue. Optimized for large queues - O(n) complexity instead of O(n log n). Args: target_uuid: The UUID to search for Returns: dict: ...
Find the position of a watch UUID in the async priority queue. Optimized for large queues - O(n) complexity instead of O(n log n). Args: target_uuid: The UUID to search for Returns: dict: Contains position info or None if not found ...
get_uuid_position
python
dgtlmoon/changedetection.io
changedetectionio/custom_queue.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/custom_queue.py
Apache-2.0
def get_queue_summary(self): """ Get a quick summary of async queue state. O(n) complexity - fast even for large queues. """ queue_list = list(self._queue) total_items = len(queue_list) if total_items == 0: return { 'total_item...
Get a quick summary of async queue state. O(n) complexity - fast even for large queues.
get_queue_summary
python
dgtlmoon/changedetection.io
changedetectionio/custom_queue.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/custom_queue.py
Apache-2.0
def customSequenceMatcher( before: List[str], after: List[str], include_equal: bool = False, include_removed: bool = True, include_added: bool = True, include_replaced: bool = True, include_change_type_prefix: bool = True, html_colour: bool = False ) -> Iterator[List[str]]: """ C...
Compare two sequences and yield differences based on specified parameters. Args: before (List[str]): Original sequence after (List[str]): Modified sequence include_equal (bool): Include unchanged parts include_removed (bool): Include removed parts include_added (bool): ...
customSequenceMatcher
python
dgtlmoon/changedetection.io
changedetectionio/diff.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/diff.py
Apache-2.0
def render_diff( previous_version_file_contents: str, newest_version_file_contents: str, include_equal: bool = False, include_removed: bool = True, include_added: bool = True, include_replaced: bool = True, line_feed_sep: str = "\n", include_change_type_prefix: bool = True, patch_for...
Render the difference between two file contents. Args: previous_version_file_contents (str): Original file contents newest_version_file_contents (str): Modified file contents include_equal (bool): Include unchanged parts include_removed (bool): Include removed parts inc...
render_diff
python
dgtlmoon/changedetection.io
changedetectionio/diff.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/diff.py
Apache-2.0
def get_socketio_path(): """Generate the correct Socket.IO path prefix for the client""" # If behind a proxy with a sub-path, we need to respect that path prefix = "" if os.getenv('USE_X_SETTINGS') and 'X-Forwarded-Prefix' in request.headers: prefix = request.headers['X-Forwarded-Prefix'] #...
Generate the correct Socket.IO path prefix for the client
get_socketio_path
python
dgtlmoon/changedetection.io
changedetectionio/flask_app.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/flask_app.py
Apache-2.0
def _jinja2_filter_format_number_locale(value: float) -> str: "Formats for example 4000.10 to the local locale default of 4,000.10" # Format the number with two decimal places (locale format string will return 6 decimal) formatted_value = locale.format_string("%.2f", value, grouping=True) return format...
Formats for example 4000.10 to the local locale default of 4,000.10
_jinja2_filter_format_number_locale
python
dgtlmoon/changedetection.io
changedetectionio/flask_app.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/flask_app.py
Apache-2.0
def _get_worker_status_info(): """Get detailed worker status information for display""" status = worker_handler.get_worker_status() running_uuids = worker_handler.get_running_uuids() return { 'count': status['worker_count'], 'type': status['worker_type'], 'active_workers': l...
Get detailed worker status information for display
_get_worker_status_info
python
dgtlmoon/changedetection.io
changedetectionio/flask_app.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/flask_app.py
Apache-2.0
def process_formdata(self, valuelist): """ Processes the raw input from the form and stores it as a string. """ if valuelist: time_str = valuelist[0] # Simple validation for HH:MM format if not time_str or len(time_str.split(":")) != 2: ...
Processes the raw input from the form and stores it as a string.
process_formdata
python
dgtlmoon/changedetection.io
changedetectionio/forms.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/forms.py
Apache-2.0
def memory_cleanup(app=None): """ Perform comprehensive memory cleanup operations and log memory usage at each step with nicely formatted numbers. Args: app: Optional Flask app instance for clearing Flask-specific caches Returns: str: Status message """ # Get cu...
Perform comprehensive memory cleanup operations and log memory usage at each step with nicely formatted numbers. Args: app: Optional Flask app instance for clearing Flask-specific caches Returns: str: Status message
memory_cleanup
python
dgtlmoon/changedetection.io
changedetectionio/gc_cleanup.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/gc_cleanup.py
Apache-2.0
def element_removal(selectors: List[str], html_content): """Removes elements that match a list of CSS or XPath selectors.""" modified_html = html_content css_selectors = [] xpath_selectors = [] for selector in selectors: if selector.startswith(('xpath:', 'xpath1:', '//')): # Han...
Removes elements that match a list of CSS or XPath selectors.
element_removal
python
dgtlmoon/changedetection.io
changedetectionio/html_tools.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/html_tools.py
Apache-2.0
def workarounds_for_obfuscations(content): """ Some sites are using sneaky tactics to make prices and other information un-renderable by Inscriptis This could go into its own Pip package in the future, for faster updates """ # HomeDepot.com style <span>$<!-- -->90<!-- -->.<!-- -->74</span> # ht...
Some sites are using sneaky tactics to make prices and other information un-renderable by Inscriptis This could go into its own Pip package in the future, for faster updates
workarounds_for_obfuscations
python
dgtlmoon/changedetection.io
changedetectionio/html_tools.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/html_tools.py
Apache-2.0
def queue_notification_for_watch(self, n_object, watch): """ Queue a notification for a watch with full diff rendering and template variables """ from changedetectionio import diff from changedetectionio.notification import default_notification_format_for_watch dates = [...
Queue a notification for a watch with full diff rendering and template variables
queue_notification_for_watch
python
dgtlmoon/changedetection.io
changedetectionio/notification_service.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/notification_service.py
Apache-2.0
def _check_cascading_vars(self, var_name, watch): """ Check notification variables in cascading priority: Individual watch settings > Tag settings > Global settings """ from changedetectionio.notification import ( default_notification_format_for_watch, def...
Check notification variables in cascading priority: Individual watch settings > Tag settings > Global settings
_check_cascading_vars
python
dgtlmoon/changedetection.io
changedetectionio/notification_service.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/notification_service.py
Apache-2.0
def send_content_changed_notification(self, watch_uuid): """ Send notification when content changes are detected """ n_object = {} watch = self.datastore.data['watching'].get(watch_uuid) if not watch: return watch_history = watch.history dates...
Send notification when content changes are detected
send_content_changed_notification
python
dgtlmoon/changedetection.io
changedetectionio/notification_service.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/notification_service.py
Apache-2.0
def send_filter_failure_notification(self, watch_uuid): """ Send notification when CSS/XPath filters fail consecutively """ threshold = self.datastore.data['settings']['application'].get('filter_failure_notification_threshold_attempts') watch = self.datastore.data['watching'].get...
Send notification when CSS/XPath filters fail consecutively
send_filter_failure_notification
python
dgtlmoon/changedetection.io
changedetectionio/notification_service.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/notification_service.py
Apache-2.0
def send_step_failure_notification(self, watch_uuid, step_n): """ Send notification when browser steps fail consecutively """ watch = self.datastore.data['watching'].get(watch_uuid, False) if not watch: return threshold = self.datastore.data['settings']['appli...
Send notification when browser steps fail consecutively
send_step_failure_notification
python
dgtlmoon/changedetection.io
changedetectionio/notification_service.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/notification_service.py
Apache-2.0
def collect_ui_edit_stats_extras(watch): """Collect and combine HTML content from all plugins that implement ui_edit_stats_extras""" extras_content = [] # Get all plugins that implement the ui_edit_stats_extras hook results = plugin_manager.hook.ui_edit_stats_extras(watch=watch) # If we ha...
Collect and combine HTML content from all plugins that implement ui_edit_stats_extras
collect_ui_edit_stats_extras
python
dgtlmoon/changedetection.io
changedetectionio/pluggy_interface.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/pluggy_interface.py
Apache-2.0
def rehydrate_entity(self, uuid, entity, processor_override=None): """Set the dict back to the dict Watch object""" entity['uuid'] = uuid if processor_override: watch_class = get_custom_watch_obj_for_processor(processor_override) entity['processor']=processor_override ...
Set the dict back to the dict Watch object
rehydrate_entity
python
dgtlmoon/changedetection.io
changedetectionio/store.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/store.py
Apache-2.0
def get_preferred_proxy_for_watch(self, uuid): """ Returns the preferred proxy by ID key :param uuid: UUID :return: proxy "key" id """ if self.proxy_list is None: return None # If it's a valid one watch = self.data['watching'].get(uuid) ...
Returns the preferred proxy by ID key :param uuid: UUID :return: proxy "key" id
get_preferred_proxy_for_watch
python
dgtlmoon/changedetection.io
changedetectionio/store.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/store.py
Apache-2.0
def get_all_tags_for_watch(self, uuid): """This should be in Watch model but Watch doesn't have access to datastore, not sure how to solve that yet""" watch = self.data['watching'].get(uuid) # Should return a dict of full tag info linked by UUID if watch: return dictfilt(sel...
This should be in Watch model but Watch doesn't have access to datastore, not sure how to solve that yet
get_all_tags_for_watch
python
dgtlmoon/changedetection.io
changedetectionio/store.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/store.py
Apache-2.0
def am_i_inside_time( day_of_week: str, time_str: str, timezone_str: str, duration: int = 15, ) -> bool: """ Determines if the current time falls within a specified time range. Parameters: day_of_week (str): The day of the week (e.g., 'Monday'). time_str (str...
Determines if the current time falls within a specified time range. Parameters: day_of_week (str): The day of the week (e.g., 'Monday'). time_str (str): The start time in 'HH:MM' format. timezone_str (str): The timezone identifier (e.g., 'Europe/Berlin'). duration (int, optiona...
am_i_inside_time
python
dgtlmoon/changedetection.io
changedetectionio/time_handler.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/time_handler.py
Apache-2.0
def start_async_event_loop(): """Start a dedicated event loop for async workers in a separate thread""" global async_loop logger.info("Starting async event loop for workers") try: # Create a new event loop for this thread async_loop = asyncio.new_event_loop() # Set it as the...
Start a dedicated event loop for async workers in a separate thread
start_async_event_loop
python
dgtlmoon/changedetection.io
changedetectionio/worker_handler.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/worker_handler.py
Apache-2.0
def start_async_workers(n_workers, update_q, notification_q, app, datastore): """Start the async worker management system""" global async_loop_thread, async_loop, running_async_tasks, currently_processing_uuids # Clear any stale UUID tracking state currently_processing_uuids.clear() # Star...
Start the async worker management system
start_async_workers
python
dgtlmoon/changedetection.io
changedetectionio/worker_handler.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/worker_handler.py
Apache-2.0
async def start_single_async_worker(worker_id, update_q, notification_q, app, datastore): """Start a single async worker with auto-restart capability""" from changedetectionio.async_update_worker import async_update_worker # Check if we're in pytest environment - if so, be more gentle with logging ...
Start a single async worker with auto-restart capability
start_single_async_worker
python
dgtlmoon/changedetection.io
changedetectionio/worker_handler.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/worker_handler.py
Apache-2.0
def add_worker(update_q, notification_q, app, datastore): """Add a new async worker (for dynamic scaling)""" global running_async_tasks if not async_loop: logger.error("Async loop not running, cannot add worker") return False worker_id = len(running_async_tasks) logger....
Add a new async worker (for dynamic scaling)
add_worker
python
dgtlmoon/changedetection.io
changedetectionio/worker_handler.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/worker_handler.py
Apache-2.0
def remove_worker(): """Remove an async worker (for dynamic scaling)""" global running_async_tasks if not running_async_tasks: return False # Cancel the last worker task_future = running_async_tasks.pop() task_future.cancel() logger.info(f"Removed async worker, {len(run...
Remove an async worker (for dynamic scaling)
remove_worker
python
dgtlmoon/changedetection.io
changedetectionio/worker_handler.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/worker_handler.py
Apache-2.0
def set_uuid_processing(uuid, processing=True): """Mark a UUID as being processed or completed""" global currently_processing_uuids if processing: currently_processing_uuids.add(uuid) logger.debug(f"Started processing UUID: {uuid}") else: currently_processing_uuids.discard(uuid) ...
Mark a UUID as being processed or completed
set_uuid_processing
python
dgtlmoon/changedetection.io
changedetectionio/worker_handler.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/worker_handler.py
Apache-2.0
def queue_item_async_safe(update_q, item): """Queue an item for async queue processing""" if async_loop and not async_loop.is_closed(): try: # For async queue, schedule the put operation asyncio.run_coroutine_threadsafe(update_q.put(item), async_loop) except RuntimeError ...
Queue an item for async queue processing
queue_item_async_safe
python
dgtlmoon/changedetection.io
changedetectionio/worker_handler.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/worker_handler.py
Apache-2.0
def shutdown_workers(): """Shutdown all async workers fast and aggressively""" global async_loop, async_loop_thread, running_async_tasks # Check if we're in pytest environment - if so, be more gentle with logging import os in_pytest = "pytest" in os.sys.modules or "PYTEST_CURRENT_TEST" in os.en...
Shutdown all async workers fast and aggressively
shutdown_workers
python
dgtlmoon/changedetection.io
changedetectionio/worker_handler.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/worker_handler.py
Apache-2.0
def adjust_async_worker_count(new_count, update_q=None, notification_q=None, app=None, datastore=None): """ Dynamically adjust the number of async workers. Args: new_count: Target number of workers update_q, notification_q, app, datastore: Required for adding new workers Return...
Dynamically adjust the number of async workers. Args: new_count: Target number of workers update_q, notification_q, app, datastore: Required for adding new workers Returns: dict: Status of the adjustment operation
adjust_async_worker_count
python
dgtlmoon/changedetection.io
changedetectionio/worker_handler.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/worker_handler.py
Apache-2.0
def get_worker_status(): """Get status information about async workers""" return { 'worker_type': 'async', 'worker_count': get_worker_count(), 'running_uuids': get_running_uuids(), 'async_loop_running': async_loop is not None, }
Get status information about async workers
get_worker_status
python
dgtlmoon/changedetection.io
changedetectionio/worker_handler.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/worker_handler.py
Apache-2.0
def check_worker_health(expected_count, update_q=None, notification_q=None, app=None, datastore=None): """ Check if the expected number of async workers are running and restart any missing ones. Args: expected_count: Expected number of workers update_q, notification_q, app, datastore: R...
Check if the expected number of async workers are running and restart any missing ones. Args: expected_count: Expected number of workers update_q, notification_q, app, datastore: Required for restarting workers Returns: dict: Health check results
check_worker_health
python
dgtlmoon/changedetection.io
changedetectionio/worker_handler.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/worker_handler.py
Apache-2.0
def post(self): """ @api {post} /api/v1/import Import a list of watched URLs @apiDescription Accepts a line-feed separated list of URLs to import, additionally with ?tag_uuids=(tag id), ?tag=(name), ?proxy={key}, ?dedupe=true (default true) one URL per line. @apiExample {curl} Example u...
@api {post} /api/v1/import Import a list of watched URLs @apiDescription Accepts a line-feed separated list of URLs to import, additionally with ?tag_uuids=(tag id), ?tag=(name), ?proxy={key}, ?dedupe=true (default true) one URL per line. @apiExample {curl} Example usage: curl http...
post
python
dgtlmoon/changedetection.io
changedetectionio/api/Import.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/api/Import.py
Apache-2.0
def get(self): """ @api {get} /api/v1/notifications Return Notification URL List @apiDescription Return the Notification URL List from the configuration @apiExample {curl} Example usage: curl http://localhost:5000/api/v1/notifications -H"x-api-key:813031b16330fe25e3780cf0325d...
@api {get} /api/v1/notifications Return Notification URL List @apiDescription Return the Notification URL List from the configuration @apiExample {curl} Example usage: curl http://localhost:5000/api/v1/notifications -H"x-api-key:813031b16330fe25e3780cf0325daa45" HTTP/1.0...
get
python
dgtlmoon/changedetection.io
changedetectionio/api/Notifications.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/api/Notifications.py
Apache-2.0
def post(self): """ @api {post} /api/v1/notifications Create Notification URLs @apiDescription Add one or more notification URLs from the configuration @apiExample {curl} Example usage: curl http://localhost:5000/api/v1/notifications/batch -H"x-api-key:813031b16330fe25e3780cf...
@api {post} /api/v1/notifications Create Notification URLs @apiDescription Add one or more notification URLs from the configuration @apiExample {curl} Example usage: curl http://localhost:5000/api/v1/notifications/batch -H"x-api-key:813031b16330fe25e3780cf0325daa45" -H "Content-Type...
post
python
dgtlmoon/changedetection.io
changedetectionio/api/Notifications.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/api/Notifications.py
Apache-2.0
def put(self): """ @api {put} /api/v1/notifications Replace Notification URLs @apiDescription Replace all notification URLs with the provided list (can be empty) @apiExample {curl} Example usage: curl -X PUT http://localhost:5000/api/v1/notifications -H"x-api-key:813031b16330...
@api {put} /api/v1/notifications Replace Notification URLs @apiDescription Replace all notification URLs with the provided list (can be empty) @apiExample {curl} Example usage: curl -X PUT http://localhost:5000/api/v1/notifications -H"x-api-key:813031b16330fe25e3780cf0325daa45" -H "...
put
python
dgtlmoon/changedetection.io
changedetectionio/api/Notifications.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/api/Notifications.py
Apache-2.0
def delete(self): """ @api {delete} /api/v1/notifications Delete Notification URLs @apiDescription Deletes one or more notification URLs from the configuration @apiExample {curl} Example usage: curl http://localhost:5000/api/v1/notifications -X DELETE -H"x-api-key:813031b1633...
@api {delete} /api/v1/notifications Delete Notification URLs @apiDescription Deletes one or more notification URLs from the configuration @apiExample {curl} Example usage: curl http://localhost:5000/api/v1/notifications -X DELETE -H"x-api-key:813031b16330fe25e3780cf0325daa45" -H "Co...
delete
python
dgtlmoon/changedetection.io
changedetectionio/api/Notifications.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/api/Notifications.py
Apache-2.0
def get(self): """ @api {get} /api/v1/systeminfo Return system info @apiDescription Return some info about the current system state @apiExample {curl} Example usage: curl http://localhost:5000/api/v1/systeminfo -H"x-api-key:813031b16330fe25e3780cf0325daa45" HTTP/1...
@api {get} /api/v1/systeminfo Return system info @apiDescription Return some info about the current system state @apiExample {curl} Example usage: curl http://localhost:5000/api/v1/systeminfo -H"x-api-key:813031b16330fe25e3780cf0325daa45" HTTP/1.0 200 { ...
get
python
dgtlmoon/changedetection.io
changedetectionio/api/SystemInfo.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/api/SystemInfo.py
Apache-2.0
def get(self, uuid): """ @api {get} /api/v1/tag/:uuid Single tag - get data or toggle notification muting. @apiDescription Retrieve tag information and set notification_muted status @apiExample {curl} Example usage: curl http://localhost:5000/api/v1/tag/cc0cfffa-f449-477b-83e...
@api {get} /api/v1/tag/:uuid Single tag - get data or toggle notification muting. @apiDescription Retrieve tag information and set notification_muted status @apiExample {curl} Example usage: curl http://localhost:5000/api/v1/tag/cc0cfffa-f449-477b-83ea-0caafd1dc091 -H"x-api-key:8130...
get
python
dgtlmoon/changedetection.io
changedetectionio/api/Tags.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/api/Tags.py
Apache-2.0
def delete(self, uuid): """ @api {delete} /api/v1/tag/:uuid Delete a tag and remove it from all watches @apiExample {curl} Example usage: curl http://localhost:5000/api/v1/tag/cc0cfffa-f449-477b-83ea-0caafd1dc091 -X DELETE -H"x-api-key:813031b16330fe25e3780cf0325daa45" @apiPa...
@api {delete} /api/v1/tag/:uuid Delete a tag and remove it from all watches @apiExample {curl} Example usage: curl http://localhost:5000/api/v1/tag/cc0cfffa-f449-477b-83ea-0caafd1dc091 -X DELETE -H"x-api-key:813031b16330fe25e3780cf0325daa45" @apiParam {uuid} uuid Tag unique ID. ...
delete
python
dgtlmoon/changedetection.io
changedetectionio/api/Tags.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/api/Tags.py
Apache-2.0
def put(self, uuid): """ @api {put} /api/v1/tag/:uuid Update tag information @apiExample {curl} Example usage: Update (PUT) curl http://localhost:5000/api/v1/tag/cc0cfffa-f449-477b-83ea-0caafd1dc091 -X PUT -H"x-api-key:813031b16330fe25e3780cf0325daa45" -H "Content-Type: a...
@api {put} /api/v1/tag/:uuid Update tag information @apiExample {curl} Example usage: Update (PUT) curl http://localhost:5000/api/v1/tag/cc0cfffa-f449-477b-83ea-0caafd1dc091 -X PUT -H"x-api-key:813031b16330fe25e3780cf0325daa45" -H "Content-Type: application/json" -d '{"title": "...
put
python
dgtlmoon/changedetection.io
changedetectionio/api/Tags.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/api/Tags.py
Apache-2.0
def post(self): """ @api {post} /api/v1/watch Create a single tag @apiExample {curl} Example usage: curl http://localhost:5000/api/v1/watch -H"x-api-key:813031b16330fe25e3780cf0325daa45" -H "Content-Type: application/json" -d '{"name": "Work related"}' @apiName Create ...
@api {post} /api/v1/watch Create a single tag @apiExample {curl} Example usage: curl http://localhost:5000/api/v1/watch -H"x-api-key:813031b16330fe25e3780cf0325daa45" -H "Content-Type: application/json" -d '{"name": "Work related"}' @apiName Create @apiGroup Tag @api...
post
python
dgtlmoon/changedetection.io
changedetectionio/api/Tags.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/api/Tags.py
Apache-2.0
def get(self): """ @api {get} /api/v1/tags List tags @apiDescription Return list of available tags @apiExample {curl} Example usage: curl http://localhost:5000/api/v1/tags -H"x-api-key:813031b16330fe25e3780cf0325daa45" { "cc0cfffa-f449-477b-83ea-0c...
@api {get} /api/v1/tags List tags @apiDescription Return list of available tags @apiExample {curl} Example usage: curl http://localhost:5000/api/v1/tags -H"x-api-key:813031b16330fe25e3780cf0325daa45" { "cc0cfffa-f449-477b-83ea-0caafd1dc091": { ...
get
python
dgtlmoon/changedetection.io
changedetectionio/api/Tags.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/api/Tags.py
Apache-2.0
def get(self, uuid): """ @api {get} /api/v1/watch/:uuid Single watch - get data, recheck, pause, mute. @apiDescription Retrieve watch information and set muted/paused status @apiExample {curl} Example usage: curl http://localhost:5000/api/v1/watch/cc0cfffa-f449-477b-83ea-0caa...
@api {get} /api/v1/watch/:uuid Single watch - get data, recheck, pause, mute. @apiDescription Retrieve watch information and set muted/paused status @apiExample {curl} Example usage: curl http://localhost:5000/api/v1/watch/cc0cfffa-f449-477b-83ea-0caafd1dc091 -H"x-api-key:813031b16...
get
python
dgtlmoon/changedetection.io
changedetectionio/api/Watch.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/api/Watch.py
Apache-2.0
def delete(self, uuid): """ @api {delete} /api/v1/watch/:uuid Delete a watch and related history @apiExample {curl} Example usage: curl http://localhost:5000/api/v1/watch/cc0cfffa-f449-477b-83ea-0caafd1dc091 -X DELETE -H"x-api-key:813031b16330fe25e3780cf0325daa45" @apiParam {...
@api {delete} /api/v1/watch/:uuid Delete a watch and related history @apiExample {curl} Example usage: curl http://localhost:5000/api/v1/watch/cc0cfffa-f449-477b-83ea-0caafd1dc091 -X DELETE -H"x-api-key:813031b16330fe25e3780cf0325daa45" @apiParam {uuid} uuid Watch unique ID. ...
delete
python
dgtlmoon/changedetection.io
changedetectionio/api/Watch.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/api/Watch.py
Apache-2.0
def put(self, uuid): """ @api {put} /api/v1/watch/:uuid Update watch information @apiExample {curl} Example usage: Update (PUT) curl http://localhost:5000/api/v1/watch/cc0cfffa-f449-477b-83ea-0caafd1dc091 -X PUT -H"x-api-key:813031b16330fe25e3780cf0325daa45" -H "Content-T...
@api {put} /api/v1/watch/:uuid Update watch information @apiExample {curl} Example usage: Update (PUT) curl http://localhost:5000/api/v1/watch/cc0cfffa-f449-477b-83ea-0caafd1dc091 -X PUT -H"x-api-key:813031b16330fe25e3780cf0325daa45" -H "Content-Type: application/json" -d '{"url...
put
python
dgtlmoon/changedetection.io
changedetectionio/api/Watch.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/api/Watch.py
Apache-2.0
def get(self, uuid): """ @api {get} /api/v1/watch/<string:uuid>/history Get a list of all historical snapshots available for a watch @apiDescription Requires `uuid`, returns list @apiExample {curl} Example usage: curl http://localhost:5000/api/v1/watch/cc0cfffa-f449-477b-83ea...
@api {get} /api/v1/watch/<string:uuid>/history Get a list of all historical snapshots available for a watch @apiDescription Requires `uuid`, returns list @apiExample {curl} Example usage: curl http://localhost:5000/api/v1/watch/cc0cfffa-f449-477b-83ea-0caafd1dc091/history -H"x-api-k...
get
python
dgtlmoon/changedetection.io
changedetectionio/api/Watch.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/api/Watch.py
Apache-2.0
def get(self, uuid, timestamp): """ @api {get} /api/v1/watch/<string:uuid>/history/<int:timestamp> Get single snapshot from watch @apiDescription Requires watch `uuid` and `timestamp`. `timestamp` of "`latest`" for latest available snapshot, or <a href="#api-Watch_History-Get_list_of_available_s...
@api {get} /api/v1/watch/<string:uuid>/history/<int:timestamp> Get single snapshot from watch @apiDescription Requires watch `uuid` and `timestamp`. `timestamp` of "`latest`" for latest available snapshot, or <a href="#api-Watch_History-Get_list_of_available_stored_snapshots_for_watch">use the list ret...
get
python
dgtlmoon/changedetection.io
changedetectionio/api/Watch.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/api/Watch.py
Apache-2.0
def post(self): """ @api {post} /api/v1/watch Create a single watch @apiDescription Requires atleast `url` set, can accept the same structure as <a href="#api-Watch-Watch">get single watch information</a> to create. @apiExample {curl} Example usage: curl http://localhost:5000...
@api {post} /api/v1/watch Create a single watch @apiDescription Requires atleast `url` set, can accept the same structure as <a href="#api-Watch-Watch">get single watch information</a> to create. @apiExample {curl} Example usage: curl http://localhost:5000/api/v1/watch -H"x-api-key:...
post
python
dgtlmoon/changedetection.io
changedetectionio/api/Watch.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/api/Watch.py
Apache-2.0
async def action_remove_elements(self, selector, value): """Removes all elements matching the given selector from the DOM.""" if not selector: return await self.page.locator(selector).evaluate_all("els => els.forEach(el => el.remove())")
Removes all elements matching the given selector from the DOM.
action_remove_elements
python
dgtlmoon/changedetection.io
changedetectionio/blueprint/browser_steps/browser_steps.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/blueprint/browser_steps/browser_steps.py
Apache-2.0
async def action_make_all_child_elements_visible(self, selector, value): """Recursively makes all child elements inside the given selector fully visible.""" if not selector: return await self.page.locator(selector).locator("*").evaluate_all(""" els => els.for...
Recursively makes all child elements inside the given selector fully visible.
action_make_all_child_elements_visible
python
dgtlmoon/changedetection.io
changedetectionio/blueprint/browser_steps/browser_steps.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/blueprint/browser_steps/browser_steps.py
Apache-2.0
async def cleanup(self): """Properly clean up all resources to prevent memory leaks""" if self._is_cleaned_up: return logger.debug("Cleaning up browser steps resources") # Clean up page if hasattr(self, 'page') and self.page is not None: ...
Properly clean up all resources to prevent memory leaks
cleanup
python
dgtlmoon/changedetection.io
changedetectionio/blueprint/browser_steps/browser_steps.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/blueprint/browser_steps/browser_steps.py
Apache-2.0
async def get_current_state(self): """Return the screenshot and interactive elements mapping, generally always called after action_()""" import importlib.resources import json # because we for now only run browser steps in playwright mode (not puppeteer mode) from changedetection...
Return the screenshot and interactive elements mapping, generally always called after action_()
get_current_state
python
dgtlmoon/changedetection.io
changedetectionio/blueprint/browser_steps/browser_steps.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/blueprint/browser_steps/browser_steps.py
Apache-2.0
def run_async_in_browser_loop(coro): """Run async coroutine using the existing async worker event loop""" from changedetectionio import worker_handler # Use the existing async worker event loop instead of creating a new one if worker_handler.USE_ASYNC_WORKERS and worker_handler.async_loop and not w...
Run async coroutine using the existing async worker event loop
run_async_in_browser_loop
python
dgtlmoon/changedetection.io
changedetectionio/blueprint/browser_steps/__init__.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/blueprint/browser_steps/__init__.py
Apache-2.0
def _watch_has_tag_options_set(watch): """This should be fixed better so that Tag is some proper Model, a tag is just a Watch also""" for tag_uuid, tag in datastore.data['settings']['application'].get('tags', {}).items(): if tag_uuid in watch.get('tags', []) and (tag.get('include_filters') o...
This should be fixed better so that Tag is some proper Model, a tag is just a Watch also
_watch_has_tag_options_set
python
dgtlmoon/changedetection.io
changedetectionio/blueprint/ui/edit.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/blueprint/ui/edit.py
Apache-2.0
def watch_get_preview_rendered(uuid): '''For when viewing the "preview" of the rendered text from inside of Edit''' from flask import jsonify from changedetectionio.processors.text_json_diff import prepare_filter_prevew result = prepare_filter_prevew(watch_uuid=uuid, form_data=request.fo...
For when viewing the "preview" of the rendered text from inside of Edit
watch_get_preview_rendered
python
dgtlmoon/changedetection.io
changedetectionio/blueprint/ui/edit.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/blueprint/ui/edit.py
Apache-2.0
def form_share_put_watch(uuid): """Given a watch UUID, upload the info and return a share-link the share-link can be imported/added""" import requests import json from copy import deepcopy # more for testing if uuid == 'first': uuid = list(datastor...
Given a watch UUID, upload the info and return a share-link the share-link can be imported/added
form_share_put_watch
python
dgtlmoon/changedetection.io
changedetectionio/blueprint/ui/__init__.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/blueprint/ui/__init__.py
Apache-2.0
def verify_condition_single_rule(watch_uuid): """Verify a single condition rule against the current snapshot""" from changedetectionio.processors.text_json_diff import prepare_filter_prevew from flask import request, jsonify from copy import deepcopy ephemeral_data = {} ...
Verify a single condition rule against the current snapshot
verify_condition_single_rule
python
dgtlmoon/changedetection.io
changedetectionio/conditions/blueprint.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/conditions/blueprint.py
Apache-2.0
def convert_to_jsonlogic(logic_operator: str, rule_dict: list): """ Convert a structured rule dict into a JSON Logic rule. :param rule_dict: Dictionary containing conditions. :return: JSON Logic rule as a dictionary. """ json_logic_conditions = [] for condition in rule_dict: oper...
Convert a structured rule dict into a JSON Logic rule. :param rule_dict: Dictionary containing conditions. :return: JSON Logic rule as a dictionary.
convert_to_jsonlogic
python
dgtlmoon/changedetection.io
changedetectionio/conditions/__init__.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/conditions/__init__.py
Apache-2.0
def execute_ruleset_against_all_plugins(current_watch_uuid: str, application_datastruct, ephemeral_data={} ): """ Build our data and options by calling our plugins then pass it to jsonlogic and see if the conditions pass :param ruleset: JSON Logic rule dictionary. :param extracted_data: Dictionary cont...
Build our data and options by calling our plugins then pass it to jsonlogic and see if the conditions pass :param ruleset: JSON Logic rule dictionary. :param extracted_data: Dictionary containing the facts. <-- maybe the app struct+uuid :return: Dictionary of plugin results.
execute_ruleset_against_all_plugins
python
dgtlmoon/changedetection.io
changedetectionio/conditions/__init__.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/conditions/__init__.py
Apache-2.0
def collect_ui_edit_stats_extras(watch): """Collect and combine HTML content from all plugins that implement ui_edit_stats_extras""" extras_content = [] for plugin in plugin_manager.get_plugins(): try: content = plugin.ui_edit_stats_extras(watch=watch) if content: ...
Collect and combine HTML content from all plugins that implement ui_edit_stats_extras
collect_ui_edit_stats_extras
python
dgtlmoon/changedetection.io
changedetectionio/conditions/__init__.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/conditions/__init__.py
Apache-2.0
def ui_edit_stats_extras(watch): """Add Levenshtein stats to the UI using the global plugin system""" """Generate the HTML for Levenshtein stats - shared by both plugin systems""" if len(watch.history.keys()) < 2: return "<p>Not enough history to calculate Levenshtein metrics</p>" try: ...
Add Levenshtein stats to the UI using the global plugin system
ui_edit_stats_extras
python
dgtlmoon/changedetection.io
changedetectionio/conditions/plugins/levenshtein_plugin.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/conditions/plugins/levenshtein_plugin.py
Apache-2.0
def add_data(current_watch_uuid, application_datastruct, ephemeral_data): """Add word count data for conditions""" result = {} watch = application_datastruct['watching'].get(current_watch_uuid) if watch and 'text' in ephemeral_data: word_count = count_words_in_history(watch, ephemeral_data[...
Add word count data for conditions
add_data
python
dgtlmoon/changedetection.io
changedetectionio/conditions/plugins/wordcount_plugin.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/conditions/plugins/wordcount_plugin.py
Apache-2.0
def _generate_stats_html(watch): """Generate the HTML content for the stats tab""" word_count = count_words_in_history(watch) html = f""" <div class="word-count-stats"> <h4>Content Analysis</h4> <table class="pure-table"> <tbody> <tr> ...
Generate the HTML content for the stats tab
_generate_stats_html
python
dgtlmoon/changedetection.io
changedetectionio/conditions/plugins/wordcount_plugin.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/conditions/plugins/wordcount_plugin.py
Apache-2.0
def manage_user_agent(headers, current_ua=''): """ Basic setting of user-agent NOTE!!!!!! The service that does the actual Chrome fetching should handle any anti-robot techniques THERE ARE MANY WAYS THAT IT CAN BE DETECTED AS A ROBOT!! This does not take care of - Scraping of 'navigator' (platf...
Basic setting of user-agent NOTE!!!!!! The service that does the actual Chrome fetching should handle any anti-robot techniques THERE ARE MANY WAYS THAT IT CAN BE DETECTED AS A ROBOT!! This does not take care of - Scraping of 'navigator' (platform, productSub, vendor, oscpu etc etc) browser object...
manage_user_agent
python
dgtlmoon/changedetection.io
changedetectionio/content_fetchers/base.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/content_fetchers/base.py
Apache-2.0
def _run_sync(self, url, timeout, request_headers, request_body, request_method, ignore_status_codes=False, current_include_filters=None, is_binary=False, empty_pages_are_a_change=False): """Synchronous v...
Synchronous version of run - the original requests implementation
_run_sync
python
dgtlmoon/changedetection.io
changedetectionio/content_fetchers/requests.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/content_fetchers/requests.py
Apache-2.0
async def run(self, url, timeout, request_headers, request_body, request_method, ignore_status_codes=False, current_include_filters=None, is_binary=False, empty_pages_are_a_change=False): """Async wrapper...
Async wrapper that runs the synchronous requests code in a thread pool
run
python
dgtlmoon/changedetection.io
changedetectionio/content_fetchers/requests.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/content_fetchers/requests.py
Apache-2.0
def get_fetch_backend(self): """ Like just using the `fetch_backend` key but there could be some logic :return: """ # Maybe also if is_image etc? # This is because chrome/playwright wont render the PDF in the browser and we will just fetch it and use pdf2html to see the t...
Like just using the `fetch_backend` key but there could be some logic :return:
get_fetch_backend
python
dgtlmoon/changedetection.io
changedetectionio/model/Watch.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/model/Watch.py
Apache-2.0
def history(self): """History index is just a text file as a list {watch-uuid}/history.txt contains a list like {epoch-time},{filename}\n We read in this list as the history information """ tmp_history = {} # In the case we are only us...
History index is just a text file as a list {watch-uuid}/history.txt contains a list like {epoch-time},{filename} We read in this list as the history information
history
python
dgtlmoon/changedetection.io
changedetectionio/model/Watch.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/model/Watch.py
Apache-2.0
def get_from_version_based_on_last_viewed(self): """Unfortunately for now timestamp is stored as string key""" keys = list(self.history.keys()) if not keys: return None if len(keys) == 1: return keys[0] last_viewed = int(self.get('last_viewed')) ...
Unfortunately for now timestamp is stored as string key
get_from_version_based_on_last_viewed
python
dgtlmoon/changedetection.io
changedetectionio/model/Watch.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/model/Watch.py
Apache-2.0
def get_error_text(self): """Return the text saved from a previous request that resulted in a non-200 error""" fname = os.path.join(self.watch_data_dir, "last-error.txt") if os.path.isfile(fname): with open(fname, 'r') as f: return f.read() return False
Return the text saved from a previous request that resulted in a non-200 error
get_error_text
python
dgtlmoon/changedetection.io
changedetectionio/model/Watch.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/model/Watch.py
Apache-2.0
def get_error_snapshot(self): """Return path to the screenshot that resulted in a non-200 error""" fname = os.path.join(self.watch_data_dir, "last-error-screenshot.png") if os.path.isfile(fname): return fname return False
Return path to the screenshot that resulted in a non-200 error
get_error_snapshot
python
dgtlmoon/changedetection.io
changedetectionio/model/Watch.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/model/Watch.py
Apache-2.0
def get_browsersteps_available_screenshots(self): "For knowing which screenshots are available to show the user in BrowserSteps UI" available = [] for f in Path(self.watch_data_dir).glob('step_before-*.jpeg'): step_n=re.search(r'step_before-(\d+)', f.name) if step_n: ...
For knowing which screenshots are available to show the user in BrowserSteps UI
get_browsersteps_available_screenshots
python
dgtlmoon/changedetection.io
changedetectionio/model/Watch.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/model/Watch.py
Apache-2.0
def compile_error_texts(self, has_proxies=None): """Compile error texts for this watch. Accepts has_proxies parameter to ensure it works even outside app context""" from flask import url_for from markupsafe import Markup output = [] # Initialize as list since we're using append...
Compile error texts for this watch. Accepts has_proxies parameter to ensure it works even outside app context
compile_error_texts
python
dgtlmoon/changedetection.io
changedetectionio/model/Watch.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/model/Watch.py
Apache-2.0
def find_sub_packages(package_name): """ Find all sub-packages within the given package. :param package_name: The name of the base package to scan for sub-packages. :return: A list of sub-package names. """ package = importlib.import_module(package_name) return [name for _, name, is_pkg in ...
Find all sub-packages within the given package. :param package_name: The name of the base package to scan for sub-packages. :return: A list of sub-package names.
find_sub_packages
python
dgtlmoon/changedetection.io
changedetectionio/processors/__init__.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/processors/__init__.py
Apache-2.0
def find_processors(): """ Find all subclasses of DifferenceDetectionProcessor in the specified package. :param package_name: The name of the package to scan for processor modules. :return: A list of (module, class) tuples. """ package_name = "changedetectionio.processors" # Name of the curren...
Find all subclasses of DifferenceDetectionProcessor in the specified package. :param package_name: The name of the package to scan for processor modules. :return: A list of (module, class) tuples.
find_processors
python
dgtlmoon/changedetection.io
changedetectionio/processors/__init__.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/processors/__init__.py
Apache-2.0
def available_processors(): """ Get a list of processors by name and description for the UI elements :return: A list :) """ processor_classes = find_processors() available = [] for package, processor_class in processor_classes: available.append((processor_class, package.name)) ...
Get a list of processors by name and description for the UI elements :return: A list :)
available_processors
python
dgtlmoon/changedetection.io
changedetectionio/processors/__init__.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/processors/__init__.py
Apache-2.0
def get_itemprop_availability(html_content) -> Restock: """ Kind of funny/cool way to find price/availability in one many different possibilities. Use 'extruct' to find any possible RDFa/microdata/json-ld data, make a JSON string from the output then search it. """ from jsonpath_ng import parse ...
Kind of funny/cool way to find price/availability in one many different possibilities. Use 'extruct' to find any possible RDFa/microdata/json-ld data, make a JSON string from the output then search it.
get_itemprop_availability
python
dgtlmoon/changedetection.io
changedetectionio/processors/restock_diff/processor.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/processors/restock_diff/processor.py
Apache-2.0
def prepare_filter_prevew(datastore, watch_uuid, form_data): '''Used by @app.route("/edit/<string:uuid>/preview-rendered", methods=['POST'])''' from changedetectionio import forms, html_tools from changedetectionio.model.Watch import model as watch_model from concurrent.futures import ProcessPoolExecuto...
Used by @app.route("/edit/<string:uuid>/preview-rendered", methods=['POST'])
prepare_filter_prevew
python
dgtlmoon/changedetection.io
changedetectionio/processors/text_json_diff/__init__.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/processors/text_json_diff/__init__.py
Apache-2.0
def register_watch_operation_handlers(socketio, datastore): """Register Socket.IO event handlers for watch operations""" @socketio.on('watch_operation') def handle_watch_operation(data): """Handle watch operations like pause, mute, recheck via Socket.IO""" try: op = data.get...
Register Socket.IO event handlers for watch operations
register_watch_operation_handlers
python
dgtlmoon/changedetection.io
changedetectionio/realtime/events.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/realtime/events.py
Apache-2.0
def handle_watch_operation(data): """Handle watch operations like pause, mute, recheck via Socket.IO""" try: op = data.get('op') uuid = data.get('uuid') logger.debug(f"Socket.IO: Received watch operation '{op}' for UUID {uuid}") i...
Handle watch operations like pause, mute, recheck via Socket.IO
handle_watch_operation
python
dgtlmoon/changedetection.io
changedetectionio/realtime/events.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/realtime/events.py
Apache-2.0
def polling_emit_running_or_queued_watches_threaded(self): """Threading version of polling for Windows compatibility""" import time import threading logger.info("Queue update thread started (threading mode)") # Import here to avoid circular imports from changedet...
Threading version of polling for Windows compatibility
polling_emit_running_or_queued_watches_threaded
python
dgtlmoon/changedetection.io
changedetectionio/realtime/socket_server.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/realtime/socket_server.py
Apache-2.0
def handle_watch_update(socketio, **kwargs): """Handle watch update signal from blinker""" try: watch = kwargs.get('watch') datastore = kwargs.get('datastore') # Emit the watch update to all connected clients from changedetectionio.flask_app import update_q from changede...
Handle watch update signal from blinker
handle_watch_update
python
dgtlmoon/changedetection.io
changedetectionio/realtime/socket_server.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/realtime/socket_server.py
Apache-2.0
def init_socketio(app, datastore): """Initialize SocketIO with the main Flask app""" import platform import sys # Platform-specific async_mode selection for better stability system = platform.system().lower() python_version = sys.version_info # Check for SocketIO mode configuration...
Initialize SocketIO with the main Flask app
init_socketio
python
dgtlmoon/changedetection.io
changedetectionio/realtime/socket_server.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/realtime/socket_server.py
Apache-2.0
def shutdown(): """Shutdown the SocketIO server fast and aggressively""" try: logger.info("Socket.IO: Fast shutdown initiated...") # For threading mode, give the thread a very short time to exit gracefully if hasattr(socketio, 'polling_emitter_thread'): ...
Shutdown the SocketIO server fast and aggressively
shutdown
python
dgtlmoon/changedetection.io
changedetectionio/realtime/socket_server.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/realtime/socket_server.py
Apache-2.0
def test_conditions_with_text_and_number(client, live_server): """Test that both text and number conditions work together with AND logic.""" set_original_response("50") test_url = url_for('test_endpoint', _external=True) # Add our URL to the import page res = client.post( url_for...
Test that both text and number conditions work together with AND logic.
test_conditions_with_text_and_number
python
dgtlmoon/changedetection.io
changedetectionio/tests/test_conditions.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/tests/test_conditions.py
Apache-2.0
def test_render_anchor_tag_content_true(client, live_server, measure_memory_usage): """Testing that the link changes are detected when render_anchor_tag_content setting is set to true""" sleep_time_for_fetch_thread = 3 # Give the endpoint time to spin up time.sleep(1) # set original html text ...
Testing that the link changes are detected when render_anchor_tag_content setting is set to true
test_render_anchor_tag_content_true
python
dgtlmoon/changedetection.io
changedetectionio/tests/test_ignorehyperlinks.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/tests/test_ignorehyperlinks.py
Apache-2.0
def test_import_custom_xlsx(client, live_server, measure_memory_usage): """Test can upload a excel spreadsheet and the watches are created correctly""" dirname = os.path.dirname(__file__) filename = os.path.join(dirname, 'import/spreadsheet.xlsx') with open(filename, 'rb') as f: data= { ...
Test can upload a excel spreadsheet and the watches are created correctly
test_import_custom_xlsx
python
dgtlmoon/changedetection.io
changedetectionio/tests/test_import.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/tests/test_import.py
Apache-2.0
def test_import_watchete_xlsx(client, live_server, measure_memory_usage): """Test can upload a excel spreadsheet and the watches are created correctly""" dirname = os.path.dirname(__file__) filename = os.path.join(dirname, 'import/spreadsheet.xlsx') with open(filename, 'rb') as f: data= {...
Test can upload a excel spreadsheet and the watches are created correctly
test_import_watchete_xlsx
python
dgtlmoon/changedetection.io
changedetectionio/tests/test_import.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/tests/test_import.py
Apache-2.0
def test_rss_bad_chars_breaking(client, live_server): """This should absolutely trigger the RSS builder to go into worst state mode - source: prefix means no html conversion (which kinda filters out the bad stuff) - Binary data - Very long so that the saving is performed by Brotli (and decoded back to ...
This should absolutely trigger the RSS builder to go into worst state mode - source: prefix means no html conversion (which kinda filters out the bad stuff) - Binary data - Very long so that the saving is performed by Brotli (and decoded back to bytes) Otherwise feedgen should support regular unicode ...
test_rss_bad_chars_breaking
python
dgtlmoon/changedetection.io
changedetectionio/tests/test_rss.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/tests/test_rss.py
Apache-2.0
def wait_for_notification_endpoint_output(): '''Apprise can take a few seconds to fire''' #@todo - could check the apprise object directly instead of looking for this file from os.path import isfile for i in range(1, 20): time.sleep(1) if isfile("test-datastore/notification.txt"): ...
Apprise can take a few seconds to fire
wait_for_notification_endpoint_output
python
dgtlmoon/changedetection.io
changedetectionio/tests/util.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/tests/util.py
Apache-2.0
def wait_for_all_checks(client=None): """ Waits until the queue is empty and workers are idle. Much faster than the original with adaptive timing. """ from changedetectionio.flask_app import update_q as global_update_q from changedetectionio import worker_handler logger = logging.getLogger(...
Waits until the queue is empty and workers are idle. Much faster than the original with adaptive timing.
wait_for_all_checks
python
dgtlmoon/changedetection.io
changedetectionio/tests/util.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/tests/util.py
Apache-2.0
def test_get_auth(url, expected_auth): """Test authentication extraction with various URL formats.""" parsed_url = apprise_parse_url(url) assert _get_auth(parsed_url) == expected_auth
Test authentication extraction with various URL formats.
test_get_auth
python
dgtlmoon/changedetection.io
changedetectionio/tests/apprise/test_apprise_custom_api_call.py
https://github.com/dgtlmoon/changedetection.io/blob/master/changedetectionio/tests/apprise/test_apprise_custom_api_call.py
Apache-2.0