mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-03-12 10:31:50 +01:00
add --keep-old flag
This commit is contained in:
18
README.md
18
README.md
@@ -175,8 +175,8 @@ It is the spiritual successor to [Second-Hand-Friends/ebayKleinanzeigen](https:/
|
|||||||
|
|
||||||
## <a name="usage"></a>Usage
|
## <a name="usage"></a>Usage
|
||||||
|
|
||||||
```yaml
|
```
|
||||||
Usage: kleinanzeigen-bot COMMAND [-v|--verbose] [--config=<PATH>] [--logfile=<PATH>]
|
Usage: kleinanzeigen-bot COMMAND [OPTIONS]
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
publish - (re-)publishes ads
|
publish - (re-)publishes ads
|
||||||
@@ -184,6 +184,18 @@ Commands:
|
|||||||
--
|
--
|
||||||
help - displays this help (default command)
|
help - displays this help (default command)
|
||||||
version - displays the application version
|
version - displays the application version
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--ads=all|due|new - specifies which ads to (re-)publish (DEFAULT: due)
|
||||||
|
Possible values:
|
||||||
|
* all: (re-)publish all ads ignoring republication_interval
|
||||||
|
* due: publish all new ads and republish ads according the republication_interval
|
||||||
|
* new: only publish new ads (i.e. ads that have no id in the config file)
|
||||||
|
--force - alias for '--ads=all'
|
||||||
|
--keep-old - don't delete old ads on republication
|
||||||
|
--config=<PATH> - path to the config YAML or JSON file (DEFAULT: ./config.yaml)
|
||||||
|
--logfile=<PATH> - path to the logfile (DEFAULT: ./kleinanzeigen-bot.log)
|
||||||
|
-v, --verbose - enables verbose output - only useful when troubleshooting issues
|
||||||
```
|
```
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
@@ -299,7 +311,7 @@ created_on: # set automatically
|
|||||||
updated_on: # set automatically
|
updated_on: # set automatically
|
||||||
```
|
```
|
||||||
|
|
||||||
## <a name="development"></a> Development Notes
|
## <a name="development"></a>Development Notes
|
||||||
|
|
||||||
> Please read [CONTRIBUTING.md](CONTRIBUTING.md) before contributing code. Thank you!
|
> Please read [CONTRIBUTING.md](CONTRIBUTING.md) before contributing code. Thank you!
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ class KleinanzeigenBot(SeleniumMixin):
|
|||||||
|
|
||||||
self.command = "help"
|
self.command = "help"
|
||||||
self.ads_selector = "due"
|
self.ads_selector = "due"
|
||||||
|
self.delete_old_ads = True
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
if self.file_log:
|
if self.file_log:
|
||||||
@@ -108,6 +109,7 @@ class KleinanzeigenBot(SeleniumMixin):
|
|||||||
* due: publish all new ads and republish ads according the republication_interval
|
* due: publish all new ads and republish ads according the republication_interval
|
||||||
* new: only publish new ads (i.e. ads that have no id in the config file)
|
* new: only publish new ads (i.e. ads that have no id in the config file)
|
||||||
--force - alias for '--ads=all'
|
--force - alias for '--ads=all'
|
||||||
|
--keep-old - don't delete old ads on republication
|
||||||
--config=<PATH> - path to the config YAML or JSON file (DEFAULT: ./config.yaml)
|
--config=<PATH> - path to the config YAML or JSON file (DEFAULT: ./config.yaml)
|
||||||
--logfile=<PATH> - path to the logfile (DEFAULT: ./kleinanzeigen-bot.log)
|
--logfile=<PATH> - path to the logfile (DEFAULT: ./kleinanzeigen-bot.log)
|
||||||
-v, --verbose - enables verbose output - only useful when troubleshooting issues
|
-v, --verbose - enables verbose output - only useful when troubleshooting issues
|
||||||
@@ -115,7 +117,15 @@ class KleinanzeigenBot(SeleniumMixin):
|
|||||||
|
|
||||||
def parse_args(self, args:Iterable[str]) -> None:
|
def parse_args(self, args:Iterable[str]) -> None:
|
||||||
try:
|
try:
|
||||||
options, arguments = getopt.gnu_getopt(args[1:], "hv", ["help", "verbose", "ads=", "logfile=", "config="]) # pylint: disable=unused-variable
|
options, arguments = getopt.gnu_getopt(args[1:], "hv", [
|
||||||
|
"ads=",
|
||||||
|
"config=",
|
||||||
|
"force",
|
||||||
|
"help",
|
||||||
|
"keep-old",
|
||||||
|
"logfile=",
|
||||||
|
"verbose"
|
||||||
|
])
|
||||||
except getopt.error as ex:
|
except getopt.error as ex:
|
||||||
LOG.error(ex.msg)
|
LOG.error(ex.msg)
|
||||||
LOG.error("Use --help to display available options")
|
LOG.error("Use --help to display available options")
|
||||||
@@ -137,6 +147,8 @@ class KleinanzeigenBot(SeleniumMixin):
|
|||||||
self.ads_selector = value.strip().lower()
|
self.ads_selector = value.strip().lower()
|
||||||
case "--force":
|
case "--force":
|
||||||
self.ads_selector = "all"
|
self.ads_selector = "all"
|
||||||
|
case "--keep-old":
|
||||||
|
self.delete_old_ads = False
|
||||||
case "-v" | "--verbose":
|
case "-v" | "--verbose":
|
||||||
LOG.setLevel(logging.DEBUG)
|
LOG.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
@@ -361,7 +373,8 @@ class KleinanzeigenBot(SeleniumMixin):
|
|||||||
LOG.info("############################################")
|
LOG.info("############################################")
|
||||||
|
|
||||||
def publish_ad(self, ad_file, ad_cfg: dict[str, Any], ad_cfg_orig: dict[str, Any]) -> None:
|
def publish_ad(self, ad_file, ad_cfg: dict[str, Any], ad_cfg_orig: dict[str, Any]) -> None:
|
||||||
self.delete_ad(ad_cfg)
|
if self.delete_old_ads:
|
||||||
|
self.delete_ad(ad_cfg)
|
||||||
|
|
||||||
LOG.info("Publishing ad '%s'...", ad_cfg["title"])
|
LOG.info("Publishing ad '%s'...", ad_cfg["title"])
|
||||||
|
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ notes = [ "FIXME", "XXX", "TODO" ]
|
|||||||
|
|
||||||
[tool.pylint.design]
|
[tool.pylint.design]
|
||||||
max-attributes = 10
|
max-attributes = 10
|
||||||
max-branches = 20
|
max-branches = 30
|
||||||
max-locals = 30
|
max-locals = 30
|
||||||
max-returns = 10
|
max-returns = 10
|
||||||
max-statements = 90
|
max-statements = 90
|
||||||
|
|||||||
Reference in New Issue
Block a user