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

Support Automated Reposting? #6

Open
ghost opened this issue Apr 4, 2021 · 6 comments
Open

Support Automated Reposting? #6

ghost opened this issue Apr 4, 2021 · 6 comments
Labels
enhancement New feature or request

Comments

@ghost
Copy link

ghost commented Apr 4, 2021

Hi,

Great project so far! I just set this up and was able to repost all my ads for the two Kijiji accounts that I manage.

Are there plans to support the ability to automate reposting? I was posting ads a couple of times a week and it was completely hands-off. I previously was running the https://github.com/ArthurG/Kijiji-Repost-Headless project as a service with some systemd timers to automate launching the service at certain dates/times...

I imagine supporting a scheduling feature in the GUI would be more involved but more user friendly. Is that something that is likely to be developed in the future?

Alternatively, is it possible to create an API that can be called with a web request at the /repost_all URL? I.E. send the creds of the account with a repost function? I suspect this could be possible right now, but haven't dove into the code too much. If that's possible, I think creating some documentation on that would be helpful to others!

@jackm jackm added the enhancement New feature or request label Apr 4, 2021
@jackm
Copy link
Owner

jackm commented Apr 4, 2021

This is on the TODO list. I intend to add a scriptable version of this project so that all features can be called via the command line only.
Organizing and integrating this feature properly is still something I am working on.

@jackm
Copy link
Owner

jackm commented Sep 22, 2021

I have noticed that there is a third-party project that uses this project as a dependency in order to automate ad reposting. I have not used it myself but it may be useful to some.

See https://github.com/Leyka/KijijiAutoRepost

@ghost
Copy link
Author

ghost commented Sep 22, 2021

Hi @jackm,

Thanks for sharing that resource.

I ended up putting a solution for myself together. I make a HTTP request to the repost_all URL. The scripts runs as a service on a systemd timer on Ubuntu. Here it is if you or anyone else is interested:

Script to make HTTP request to repost ads (repost_trigger.py):

import yaml
import time
import creds
import requests
from bs4 import BeautifulSoup

def initial_login(http_session, payload):
    """
    Logs in
    Takes, CSRF_token
    Updates payload with CSRF token for additional request
    """
    login_url = "http://192.168.1.25:5000/login"
    response = http_session.post(login_url, data=payload)
    html_string = response.text
    soup = BeautifulSoup(html_string, 'html')
    token = soup.find('input', {'name':'csrf_token'})['value']
    payload['csrf_token'] = token


def final_login_and_repost_ads(http_session, payload):
    login_url = "http://192.168.1.25:5000/login"
    http_session.post(login_url, data=payload)


def repost_ads(http_session, payload):
    repost_url = "http://192.168.1.25:5000/repost_all"
    repost_ads = http_session.get(repost_url, data=payload)


def pushover_message(message):

    url = "https://api.pushover.net/1/messages.json"

    payload={'token': creds.app_id,
    'user': creds.user_id,
    'message': message,
    'title': 'Kijiji Reposter'}

    requests.request("POST", url, data=payload)

if __name__ == "__main__":

    try:
        pushover_message('Kijiji Reposter Started')
        print('pushover message sent!!!!!!!!!!!!!!!!!!!!!!!!!!')
        yaml_file = open('accounts.yaml')
        accounts = yaml.load(yaml_file, Loader=yaml.FullLoader)

        for k, v in accounts.items():

            payload = {
            "email": v['email'],
            "password": v['password']
            }

            http_session = requests.Session()

            initial_login(http_session, payload)
            final_login_and_repost_ads(http_session, payload)
            repost_ads(http_session, payload)
            time.sleep(240)

        pushover_message('Kijiji Ads Reposted')



    except Exception as e:
        pushover_message(f"""Kijiji reposter ran into issues:

{e}

Check journalctl logs for more details""")

Example of accounts.yaml file:

account1:
  email: 1yourkijijiaccount@account.com
  password: yourkijijiaccountpassword
account2:
  email: 2yourkijijiaccount@account.com
  password: yourkijijiaccountpassword

Service file kijiji_manager_repost_trigger.service

[Unit]
Description=Kijiji Manager Repost Trigger
After=network.target

[Service]
WorkingDirectory=/home/ubuntu/scripts/kijiji_repost_trigger
Environment="PATH=/home/ubuntu/scripts/kijiji_repost_trigger/.venv/bin"
ExecStart=/home/ubuntu/scripts/kijiji_repost_trigger/.venv/bin/python3 -m repost_trigger
TimeoutSec=300

[Install]
WantedBy=multi-user.target

Systemd Timer File:

[Unit]
Description=Kijijireposter timer

[Timer]
Unit=kijiji_manager_repost_trigger.service
# OnCalendar=*-*-* 18:00:00 Everyday at 18:00
OnCalendar=Fri 18:00:00
OnCalendar=Sun 09:00:00
OnCalendar=Tue 18:00:00
Persistent=true

[Install]
WantedBy=multi-user.target

@apple-cmd
Copy link

@rockerguy1978 is the above still working for you?

@ghost
Copy link
Author

ghost commented Oct 15, 2023

@rockerguy1978 is the above still working for you?

Hi @apple-cmd, the script works no issue. However, I am also having the same issues documented in #62. My ads are deleted after reposting, unfortunately.

@apple-cmd
Copy link

@rockerguy1978 I think someone wrote a little script there to change the titles automatically
how can I incorporate your script for the auto reposting into this git that I cloned on my machine - I just followed the install instructions in OS and run localhost

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants