mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-03-12 02:31:45 +01:00
## ℹ️ Description This PR fixes intermittent login detection failures where the bot fails to detect existing login sessions and unnecessarily re-logins, potentially causing IP blocks. - Link to the related issue(s): Issue #701 - Describe the motivation and context for this change: Users reported that the bot sometimes fails to detect existing login sessions (50/50 behavior), especially for browser profiles that haven't been used for 20+ days. This appears to be a race condition where: 1. `web_open()` completes when `document.readyState == 'complete'` 2. But kleinanzeigen.de's client-side JavaScript hasn't yet rendered user profile elements 3. The login detection timeout (5s default) is too short for slow networks or sessions requiring server-side validation ## 📋 Changes Summary - **Add dedicated `login_detection` timeout** to `TimeoutConfig` (default: 10s, previously used generic 5s timeout) - **Apply timeout to both DOM checks** in `is_logged_in()`: `.mr-medium` and `#user-email` elements - **Add debug logging** to track which element detected login or if no login was found - **Regenerate JSON schema** to include new timeout configuration - **Effective total timeout**: ~22.5s (10s base × 1.0 multiplier × 1.5 backoff × 2 retries) vs previous ~11.25s ### Benefits: - Addresses race condition between page load completion and client-side rendering - Provides sufficient time for sessions requiring server-side validation (20+ days old) - User-configurable via `timeouts.login_detection` in `config.yaml` - Follows established pattern of dedicated timeouts (`sms_verification`, `gdpr_prompt`, etc.) ### ⚙️ Type of Change - [x] 🐞 Bug fix (non-breaking change which fixes an issue) - [ ] ✨ New feature (adds new functionality without breaking existing usage) - [ ] 💥 Breaking change (changes that might break existing user setups, scripts, or configurations) ## ✅ Checklist - [x] I have reviewed my changes to ensure they meet the project's standards. - [x] I have tested my changes and ensured that all tests pass (`pdm run test`). - [x] I have formatted the code (`pdm run format`). - [x] I have verified that linting passes (`pdm run lint`). - [x] I have updated documentation where necessary. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added a configurable login-detection timeout (default 10s, min 1s) to tune session detection. * **Bug Fixes** * More reliable login checks using a timeout-aware, two-step detection sequence. * Improved diagnostic logging for login attempts, retry behavior, detection outcomes, and timeout events. * **Documentation** * Added troubleshooting guidance explaining the login-detection timeout and when to adjust it. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
586 lines
16 KiB
JSON
586 lines
16 KiB
JSON
{
|
|
"$defs": {
|
|
"AdDefaults": {
|
|
"properties": {
|
|
"active": {
|
|
"default": true,
|
|
"title": "Active",
|
|
"type": "boolean"
|
|
},
|
|
"type": {
|
|
"default": "OFFER",
|
|
"enum": [
|
|
"OFFER",
|
|
"WANTED"
|
|
],
|
|
"title": "Type",
|
|
"type": "string"
|
|
},
|
|
"description": {
|
|
"anyOf": [
|
|
{
|
|
"$ref": "#/$defs/DescriptionAffixes"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"default": null
|
|
},
|
|
"description_prefix": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"default": null,
|
|
"description": "prefix for the ad description",
|
|
"title": "Description Prefix"
|
|
},
|
|
"description_suffix": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"default": null,
|
|
"description": " suffix for the ad description",
|
|
"title": "Description Suffix"
|
|
},
|
|
"price_type": {
|
|
"default": "NEGOTIABLE",
|
|
"enum": [
|
|
"FIXED",
|
|
"NEGOTIABLE",
|
|
"GIVE_AWAY",
|
|
"NOT_APPLICABLE"
|
|
],
|
|
"title": "Price Type",
|
|
"type": "string"
|
|
},
|
|
"shipping_type": {
|
|
"default": "SHIPPING",
|
|
"enum": [
|
|
"PICKUP",
|
|
"SHIPPING",
|
|
"NOT_APPLICABLE"
|
|
],
|
|
"title": "Shipping Type",
|
|
"type": "string"
|
|
},
|
|
"sell_directly": {
|
|
"default": false,
|
|
"description": "requires shipping_type SHIPPING to take effect",
|
|
"title": "Sell Directly",
|
|
"type": "boolean"
|
|
},
|
|
"images": {
|
|
"anyOf": [
|
|
{
|
|
"items": {
|
|
"type": "string"
|
|
},
|
|
"type": "array"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"default": null,
|
|
"title": "Images"
|
|
},
|
|
"contact": {
|
|
"$ref": "#/$defs/ContactDefaults"
|
|
},
|
|
"republication_interval": {
|
|
"default": 7,
|
|
"title": "Republication Interval",
|
|
"type": "integer"
|
|
}
|
|
},
|
|
"title": "AdDefaults",
|
|
"type": "object"
|
|
},
|
|
"BrowserConfig": {
|
|
"properties": {
|
|
"arguments": {
|
|
"description": "See https://peter.sh/experiments/chromium-command-line-switches/",
|
|
"items": {
|
|
"type": "string"
|
|
},
|
|
"title": "Arguments",
|
|
"type": "array"
|
|
},
|
|
"binary_location": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"default": null,
|
|
"description": "path to custom browser executable, if not specified will be looked up on PATH",
|
|
"title": "Binary Location"
|
|
},
|
|
"extensions": {
|
|
"description": "a list of .crx extension files to be loaded",
|
|
"items": {
|
|
"type": "string"
|
|
},
|
|
"title": "Extensions",
|
|
"type": "array"
|
|
},
|
|
"use_private_window": {
|
|
"default": true,
|
|
"title": "Use Private Window",
|
|
"type": "boolean"
|
|
},
|
|
"user_data_dir": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"default": ".temp/browser-profile",
|
|
"description": "See https://github.com/chromium/chromium/blob/main/docs/user_data_dir.md",
|
|
"title": "User Data Dir"
|
|
},
|
|
"profile_name": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"default": null,
|
|
"title": "Profile Name"
|
|
}
|
|
},
|
|
"title": "BrowserConfig",
|
|
"type": "object"
|
|
},
|
|
"CaptchaConfig": {
|
|
"properties": {
|
|
"auto_restart": {
|
|
"default": false,
|
|
"title": "Auto Restart",
|
|
"type": "boolean"
|
|
},
|
|
"restart_delay": {
|
|
"default": "6h",
|
|
"title": "Restart Delay",
|
|
"type": "string"
|
|
}
|
|
},
|
|
"title": "CaptchaConfig",
|
|
"type": "object"
|
|
},
|
|
"ContactDefaults": {
|
|
"properties": {
|
|
"name": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"default": null,
|
|
"title": "Name"
|
|
},
|
|
"street": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"default": null,
|
|
"title": "Street"
|
|
},
|
|
"zipcode": {
|
|
"anyOf": [
|
|
{
|
|
"type": "integer"
|
|
},
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"default": null,
|
|
"title": "Zipcode"
|
|
},
|
|
"phone": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"default": null,
|
|
"title": "Phone"
|
|
}
|
|
},
|
|
"title": "ContactDefaults",
|
|
"type": "object"
|
|
},
|
|
"DescriptionAffixes": {
|
|
"deprecated": true,
|
|
"properties": {
|
|
"prefix": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"default": null,
|
|
"title": "Prefix"
|
|
},
|
|
"suffix": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"default": null,
|
|
"title": "Suffix"
|
|
}
|
|
},
|
|
"title": "DescriptionAffixes",
|
|
"type": "object"
|
|
},
|
|
"DownloadConfig": {
|
|
"properties": {
|
|
"include_all_matching_shipping_options": {
|
|
"default": false,
|
|
"description": "if true, all shipping options matching the package size will be included",
|
|
"title": "Include All Matching Shipping Options",
|
|
"type": "boolean"
|
|
},
|
|
"excluded_shipping_options": {
|
|
"description": "list of shipping options to exclude, e.g. ['DHL_2', 'DHL_5']",
|
|
"items": {
|
|
"type": "string"
|
|
},
|
|
"title": "Excluded Shipping Options",
|
|
"type": "array"
|
|
},
|
|
"folder_name_max_length": {
|
|
"default": 100,
|
|
"description": "maximum length for folder names when downloading ads (default: 100)",
|
|
"maximum": 255,
|
|
"minimum": 10,
|
|
"title": "Folder Name Max Length",
|
|
"type": "integer"
|
|
},
|
|
"rename_existing_folders": {
|
|
"default": false,
|
|
"description": "if true, rename existing folders without titles to include titles (default: false)",
|
|
"title": "Rename Existing Folders",
|
|
"type": "boolean"
|
|
}
|
|
},
|
|
"title": "DownloadConfig",
|
|
"type": "object"
|
|
},
|
|
"LoginConfig": {
|
|
"properties": {
|
|
"username": {
|
|
"minLength": 1,
|
|
"title": "Username",
|
|
"type": "string"
|
|
},
|
|
"password": {
|
|
"minLength": 1,
|
|
"title": "Password",
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": [
|
|
"username",
|
|
"password"
|
|
],
|
|
"title": "LoginConfig",
|
|
"type": "object"
|
|
},
|
|
"PublishingConfig": {
|
|
"properties": {
|
|
"delete_old_ads": {
|
|
"anyOf": [
|
|
{
|
|
"enum": [
|
|
"BEFORE_PUBLISH",
|
|
"AFTER_PUBLISH",
|
|
"NEVER"
|
|
],
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"default": "AFTER_PUBLISH",
|
|
"title": "Delete Old Ads"
|
|
},
|
|
"delete_old_ads_by_title": {
|
|
"default": true,
|
|
"description": "only works if delete_old_ads is set to BEFORE_PUBLISH",
|
|
"title": "Delete Old Ads By Title",
|
|
"type": "boolean"
|
|
}
|
|
},
|
|
"title": "PublishingConfig",
|
|
"type": "object"
|
|
},
|
|
"TimeoutConfig": {
|
|
"properties": {
|
|
"multiplier": {
|
|
"default": 1.0,
|
|
"description": "Global multiplier applied to all timeout values.",
|
|
"minimum": 0.1,
|
|
"title": "Multiplier",
|
|
"type": "number"
|
|
},
|
|
"default": {
|
|
"type": "number",
|
|
"minimum": 0.0,
|
|
"default": 5.0,
|
|
"description": "Baseline timeout for DOM interactions.",
|
|
"title": "Default"
|
|
},
|
|
"page_load": {
|
|
"default": 15.0,
|
|
"description": "Page load timeout for web_open.",
|
|
"minimum": 1.0,
|
|
"title": "Page Load",
|
|
"type": "number"
|
|
},
|
|
"captcha_detection": {
|
|
"default": 2.0,
|
|
"description": "Timeout for captcha iframe detection.",
|
|
"minimum": 0.1,
|
|
"title": "Captcha Detection",
|
|
"type": "number"
|
|
},
|
|
"sms_verification": {
|
|
"default": 4.0,
|
|
"description": "Timeout for SMS verification prompts.",
|
|
"minimum": 0.1,
|
|
"title": "Sms Verification",
|
|
"type": "number"
|
|
},
|
|
"gdpr_prompt": {
|
|
"default": 10.0,
|
|
"description": "Timeout for GDPR/consent dialogs.",
|
|
"minimum": 1.0,
|
|
"title": "Gdpr Prompt",
|
|
"type": "number"
|
|
},
|
|
"login_detection": {
|
|
"default": 10.0,
|
|
"description": "Timeout for detecting existing login session via DOM elements.",
|
|
"minimum": 1.0,
|
|
"title": "Login Detection",
|
|
"type": "number"
|
|
},
|
|
"publishing_result": {
|
|
"default": 300.0,
|
|
"description": "Timeout for publishing result checks.",
|
|
"minimum": 10.0,
|
|
"title": "Publishing Result",
|
|
"type": "number"
|
|
},
|
|
"publishing_confirmation": {
|
|
"default": 20.0,
|
|
"description": "Timeout for publish confirmation redirect.",
|
|
"minimum": 1.0,
|
|
"title": "Publishing Confirmation",
|
|
"type": "number"
|
|
},
|
|
"image_upload": {
|
|
"default": 30.0,
|
|
"description": "Timeout for image upload and server-side processing.",
|
|
"minimum": 5.0,
|
|
"title": "Image Upload",
|
|
"type": "number"
|
|
},
|
|
"pagination_initial": {
|
|
"default": 10.0,
|
|
"description": "Timeout for initial pagination lookup.",
|
|
"minimum": 1.0,
|
|
"title": "Pagination Initial",
|
|
"type": "number"
|
|
},
|
|
"pagination_follow_up": {
|
|
"default": 5.0,
|
|
"description": "Timeout for subsequent pagination navigation.",
|
|
"minimum": 1.0,
|
|
"title": "Pagination Follow Up",
|
|
"type": "number"
|
|
},
|
|
"quick_dom": {
|
|
"default": 2.0,
|
|
"description": "Generic short timeout for transient UI.",
|
|
"minimum": 0.1,
|
|
"title": "Quick Dom",
|
|
"type": "number"
|
|
},
|
|
"update_check": {
|
|
"default": 10.0,
|
|
"description": "Timeout for GitHub update checks.",
|
|
"minimum": 1.0,
|
|
"title": "Update Check",
|
|
"type": "number"
|
|
},
|
|
"chrome_remote_probe": {
|
|
"default": 2.0,
|
|
"description": "Timeout for local remote-debugging probes.",
|
|
"minimum": 0.1,
|
|
"title": "Chrome Remote Probe",
|
|
"type": "number"
|
|
},
|
|
"chrome_remote_debugging": {
|
|
"default": 5.0,
|
|
"description": "Timeout for remote debugging API calls.",
|
|
"minimum": 1.0,
|
|
"title": "Chrome Remote Debugging",
|
|
"type": "number"
|
|
},
|
|
"chrome_binary_detection": {
|
|
"default": 10.0,
|
|
"description": "Timeout for chrome --version subprocesses.",
|
|
"minimum": 1.0,
|
|
"title": "Chrome Binary Detection",
|
|
"type": "number"
|
|
},
|
|
"retry_enabled": {
|
|
"default": true,
|
|
"description": "Enable built-in retry/backoff for DOM operations.",
|
|
"title": "Retry Enabled",
|
|
"type": "boolean"
|
|
},
|
|
"retry_max_attempts": {
|
|
"default": 2,
|
|
"description": "Max retry attempts when retry is enabled.",
|
|
"minimum": 1,
|
|
"title": "Retry Max Attempts",
|
|
"type": "integer"
|
|
},
|
|
"retry_backoff_factor": {
|
|
"default": 1.5,
|
|
"description": "Exponential factor applied per retry attempt.",
|
|
"minimum": 1.0,
|
|
"title": "Retry Backoff Factor",
|
|
"type": "number"
|
|
}
|
|
},
|
|
"title": "TimeoutConfig",
|
|
"type": "object"
|
|
},
|
|
"UpdateCheckConfig": {
|
|
"description": "Configuration for update checking functionality.\n\nAttributes:\n enabled: Whether update checking is enabled.\n channel: Which release channel to check ('latest' for stable, 'preview' for prereleases).\n interval: How often to check for updates (e.g. '7d', '1d').\n If the interval is invalid, too short (<1d), or too long (>30d),\n the bot will log a warning and use a default interval for this run:\n - 1d for 'preview' channel\n - 7d for 'latest' channel\n The config file is not changed automatically; please fix your config to avoid repeated warnings.",
|
|
"properties": {
|
|
"enabled": {
|
|
"default": true,
|
|
"title": "Enabled",
|
|
"type": "boolean"
|
|
},
|
|
"channel": {
|
|
"default": "latest",
|
|
"enum": [
|
|
"latest",
|
|
"preview"
|
|
],
|
|
"title": "Channel",
|
|
"type": "string"
|
|
},
|
|
"interval": {
|
|
"default": "7d",
|
|
"title": "Interval",
|
|
"type": "string"
|
|
}
|
|
},
|
|
"title": "UpdateCheckConfig",
|
|
"type": "object"
|
|
}
|
|
},
|
|
"properties": {
|
|
"ad_files": {
|
|
"description": "\nglob (wildcard) patterns to select ad configuration files\nif relative paths are specified, then they are relative to this configuration file\n",
|
|
"items": {
|
|
"type": "string"
|
|
},
|
|
"minItems": 1,
|
|
"title": "Ad Files",
|
|
"type": "array"
|
|
},
|
|
"ad_defaults": {
|
|
"$ref": "#/$defs/AdDefaults",
|
|
"description": "Default values for ads, can be overwritten in each ad configuration file"
|
|
},
|
|
"categories": {
|
|
"additionalProperties": {
|
|
"type": "string"
|
|
},
|
|
"description": "\nadditional name to category ID mappings, see default list at\nhttps://github.com/Second-Hand-Friends/kleinanzeigen-bot/blob/main/src/kleinanzeigen_bot/resources/categories.yaml\n\nExample:\n categories:\n Elektronik > Notebooks: 161/278\n Jobs > Praktika: 102/125\n ",
|
|
"title": "Categories",
|
|
"type": "object"
|
|
},
|
|
"download": {
|
|
"$ref": "#/$defs/DownloadConfig"
|
|
},
|
|
"publishing": {
|
|
"$ref": "#/$defs/PublishingConfig"
|
|
},
|
|
"browser": {
|
|
"$ref": "#/$defs/BrowserConfig",
|
|
"description": "Browser configuration"
|
|
},
|
|
"login": {
|
|
"$ref": "#/$defs/LoginConfig",
|
|
"description": "Login credentials"
|
|
},
|
|
"captcha": {
|
|
"$ref": "#/$defs/CaptchaConfig"
|
|
},
|
|
"update_check": {
|
|
"$ref": "#/$defs/UpdateCheckConfig",
|
|
"description": "Update check configuration"
|
|
},
|
|
"timeouts": {
|
|
"$ref": "#/$defs/TimeoutConfig",
|
|
"description": "Centralized timeout configuration."
|
|
}
|
|
},
|
|
"title": "Config",
|
|
"type": "object",
|
|
"description": "Auto-generated JSON Schema for Config"
|
|
}
|