Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Call a script after a configurable amount of publishings #438

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

digitalbirdo
Copy link

ℹ️ Description

Add a configuration option to call a script after some publishings have been done.

I wanted to change my IP address every 10 publishings to avoid the captcha.

As this is my first ever pull-request, let me know if I have missed something.

📋 Changes Summary

Extension of the publishing config option:

publishing:
  delete_old_ads: "AFTER_PUBLISH" # one of: AFTER_PUBLISH, BEFORE_PUBLISH, NEVER
  delete_old_ads_by_title: true # only works if delete_old_ads is set to BEFORE_PUBLISH
  callout:
    intervall: 5 # number of publishings before the command is executed again
    command: "" # command which is executed e.g. VPN reconnect to get a new IP: "\"C:\Program Files\Windscribe\windscribe-cli.exe\" connect \"De\""
    sleep: 6 # number of seconds to sleep after the command has been executed

⚙️ Type of Change

Select the type(s) of change(s) included in this pull request:

  • 🐞 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

Before requesting a review, confirm the following:

  • I have reviewed my changes to ensure they meet the project's standards.
  • I have tested my changes and ensured that all tests pass (pdm run test).

I expect this is not related to my changes...
FAILED tests/unit/test_i18n.py::test_detect_locale[None-expected0] - AssertionError: For LANG=None, expected ('en', 'US', 'UTF-8') but got de_DE.UTF-8

  • I have verified that linting passes (pdm run lint).
  • I have run security scans and addressed any identified issues (pdm run audit).

Test is not happy with os.popen():
Starting a process with a shell, possible injection detected, security issue.

  • 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.

…hings

Beeing able to change the IP address after 10 publishings prevents the captcha
@digitalbirdo digitalbirdo changed the title Call a script after a configurable amount of publishings feat: Call a script after a configurable amount of publishings Feb 17, 2025
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Feb 17, 2025
@sebthom
Copy link
Contributor

sebthom commented Feb 21, 2025

Good idea.

Maybe the format can be changed to something like this:

publishing:
  delete_old_ads: "AFTER_PUBLISH"
  delete_old_ads_by_title: true
  after_publish:
    interval: 5 # number of publishings before the command is executed again
    command: "" # command which is executed e.g. VPN reconnect to get a new IP: "\"C:\Program Files\Windscribe\windscribe-cli.exe\" connect \"De\""
    sleep: 6 # number of seconds to sleep after the command has been executed

or:

publishing:
  delete_old_ads: "AFTER_PUBLISH"
  delete_old_ads_by_title: true
  after_publish:
  - interval: 1
    command: "my_command {{ad_id}}"
    sleep: 2
  - interval: 5
    command: "..."
    sleep: 6

or even:

publishing:
  delete_old_ads: "AFTER_PUBLISH"
  delete_old_ads_by_title: true

hooks:
  after_download:
  - command: "my_command {{ad_id}}"
    sleep: 2
  - command: "..."
    sleep: 6
    interval: 5
  after_download_all:
  - command: "..."
  before_publish:
  - command: "my_command {{ad_id}}"
    sleep: 2
  - command: "..."
    sleep: 6
    interval: 5
  after_publish:
  - command: "my_command {{ad_id}}"
    sleep: 2
  - command: "..."
    sleep: 6
    interval: 5
  after_publish_all:
  - command: "my_command {{ad_id}}"
  - command: "..."

@1cu @Heavenfighter

@Heavenfighter
Copy link
Contributor

I would prefer option one or option two, if there is a use case for more than one action. Option three is with the hooks is the most flexible way, but it also adds a complexity to config and code, even with little use cases (so i can't imagine what to start after downloading ads).
One comment to this feature PR generally, if the action reconnects to get an new ip, the login session would become invalid and the next action the bot will trigger, would result in an error since you get redirected to the login page.

@1cu
Copy link
Contributor

1cu commented Feb 27, 2025

I strongly prefer option 1. Let's start simple with one command after_publish and add new functionality if the need arises.

if the action reconnects to get an new ip, the login session would become invalid and the next action the bot will trigger, would result in an error since you get redirected to the login page.

The PR should add handling for this.

@digitalbirdo Could you please change your PR according to these requests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants