Pulls Images from Pixiv and Tweets them
Switch branches/tags
Nothing to show
Clone or download
geoffreyn Update tweet_pic.py
Remove unnecessary double loading of configuration
Latest commit 457f127 Sep 29, 2015


Pixiv Twitter Bot @key_images

This is a bot that retrieves images from Pixiv and posts them to twitter.

Adapted from CutePetsBmore.


On twitter:

  1. Create the twitter account that will be used to post tweets
  2. Log into this new account and navigate to http://apps.twitter.com
  3. Create a new app with permission to post
  4. Generate credentials (consumer keys and access tokens)

In code:

  1. Configure credentials.py by adding the keys generated by twitter
  2. Install dependencies pip install -r requirements.txt
  3. Modify search_terms.py to include desired search terms
    1. Currently only searches by tag for the word key, and hardcodes the pagination limit
  4. Tweet a singe image: python tweet_pic.py

Schedule regular tweeting with crontab (Linux):

  1. From the command line, edit the crontab file: crontab -e
  2. Schedule the script to run every x hours using a line similar to: 0 */x * * * /usr/bin/python /path/to/tweet_pic.py >> /path/to/log.log 2>&1


Image storage

Images are saved to the LOCAL_IMG_PATH by their ID

Avoidance of duplicate tweets

The script tweet_pet.py attempts to avoid reposting tweets about the same animals. This is done by tracking recent tweets in a buffer file created by the script. The size of the buffer file can be adjusted by changing the value of the NUM_RECENT_TWEETS in tweet_pet.py.

Addtional notes:

  • I intended this to run on a Raspberry Pi running Raspbian. The python script posts a new tweet each time it is called. Regularly scheduled posting is handled by cron.