kijiji-manager icon indicating copy to clipboard operation
kijiji-manager copied to clipboard

Support Automated Reposting?

Open rockerguy1978 opened this issue 3 years ago • 6 comments

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!

rockerguy1978 avatar Apr 04 '21 19:04 rockerguy1978

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 avatar Apr 04 '21 20:04 jackm

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

jackm avatar Sep 22 '21 15:09 jackm

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: [email protected]
  password: yourkijijiaccountpassword
account2:
  email: [email protected]
  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

rockerguy1978 avatar Sep 22 '21 21:09 rockerguy1978

@rockerguy1978 is the above still working for you?

apple-cmd avatar Oct 13 '23 20:10 apple-cmd

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

rockerguy1978 avatar Oct 15 '23 15:10 rockerguy1978

@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

apple-cmd avatar Oct 18 '23 18:10 apple-cmd