Giter Club home page Giter Club logo

cat-message's Introduction

cat-message

gets images/gifs/videos of cats from reddit, sends to mom via an Applescript.

get_cats.py

As the name of the file suggests, this script is for finding cat media posts on reddit and downloading these posts to the working directory. The script names each file cat.[relevant extension], and before writing this file, the script deletes each file named cat.*. There are a few shortcomings to this file as are outlined in the section titled Shortcomings. If the script runs into any errors/can't get the media type, a message is printed to stderr.

msg_cat.scpt

This is the Applescript for sending a cat file to the recipient of your choice. Since GitHub doesn't really deal with Applescripts very well, the entire script is copied below:

# to customize: change the things in all caps
# PATH_TO_REPOSITORY, RECIPIENT_PHONE_NUMBER, YOUR_APPLE_ID

# ginglis

on run argv
	# find the cat file
	set path_to_file to do shell script "find PATH_TO_REPOSITORY -mindepth 1 -name 'cat*'"

	# set it as a POSIX file
	set my_file to (path_to_file as POSIX file)

	set post_title to (item 1 of argv)

	# send stuff
	tell application "Messages"
		set theBuddy to buddy "RECIPIENT_PHONE_NUMBER" of service "E:YOUR_APPLE_ID"
		send post_title to theBuddy
		send my_file to theBuddy
	end tell
end run

As you can see from the comments, the three elements of the script to change in order to get it to work are PATH_TO_REPOSITORY, RECIPIENT_PHONE_NUMBER, and YOUR_APPLE_ID. Of course, in order to run this script, you must be using a Mac and have an Apple ID.

run.sh

This is a short and simple shell script I made just to consolidate the Python script and the Applescript to essentially one script. It simply runs get_cats.py, captures the output (the post title), and passes this output as an argument to the Applescript, which sends the post title in addition with the post media. I run this script on a cronjob that executes daily.

Subreddits

Checklist

  • Find and save images
  • Handle gyfcat
  • Handle imgur
  • Handle YouTube
  • Applescript to send iMessage
  • Include the post title in iMessage
  • Comment Code, clean up, document

Shortcomings

Unfortunately, requesting videos from reddit (sources that include v.redd.it) resulted in reddit detecting that a script was making too many requests to the site. Since posts of that format from these subreddits seems to be a rarity, I will not be attempting a workaround. Also, no implementation has been made for YouTube posts. My reasononing for not finding a workaround to these issues is that the rate of finding other media types is high enough to justify the script not working occasionally when it finds media from these sources. I use this once a day to send a cat to my mom, and if on one day it doesn't work, it's not a huge deal.

cat-message's People

Contributors

ginglis13 avatar pbui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cat-message's Issues

Gracefully handle "No results" responses

Right now, the script will occasionally yield no results. I'm looking for ways to handle this more gracefully that writing "No results" or an error message to /var/mail (where cron sends such messages). Any thoughts or help much appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.