├── README.md
└── socImport.bash
/README.md:
--------------------------------------------------------------------------------
1 | # socImport
2 | Send Twitter/Instagram/Facebook posts to Day One Journal
3 |
4 | Create a DropBox account (if you don't have one) and create a folder called Apps/Day One/Incoming .
5 |
6 | Use these free IFTTT recipes to send your social media posts to a folder in DropBox...
7 |
Facebook Photo Posts - https://ifttt.com/recipes/244050-day-one-import-facebook-photo-posts
8 |
Facebook Text Posts - https://ifttt.com/recipes/242576-day-one-facebook-to-text-in-dropbox
9 |
Twitter Posts - https://ifttt.com/recipes/242574-day-one-tweets-to-text-in-dropbox
10 |
Instagram Posts - https://ifttt.com/recipes/242577-day-one-instagram-to-text-in-dropbox
11 |
12 | Then, save the socImport.bash script to a folder on your Mac; I suggest in a folder called /Users/yourname/socImport .
13 |
Make sure it's executable by you.
14 |
15 | Now set up a cron job on your Mac, by using the command "crontab -e".
16 |
(If you have never used cron before, Google some instructions.)
17 |
I have the cron job run even-numbered hours, during the hours I'm usually awake. You may want to have it run more or less than that. Here's my example:
18 |
00 8,10,12,14,16,18,20,22 * * * /Users/suzy/socImport/socImport.bash
19 |
20 | Whenever your Mac is on, and it hits one of those times, the script will run, taking the text files dropped into your Incoming folder by the If This Then That recipes and importing them into Day One.
21 |
22 | Enjoy! :)
23 |
--------------------------------------------------------------------------------
/socImport.bash:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # socImport.bash by Susan Pitman
3 | # Pulls files from a directory in DropBox
4 | # called Apps/Day One/Incoming into
5 | # Day One journal posts.
6 | # 1/18/15 Script created
7 | # 1/19/15 Added Facebook photo post import
8 | # 3/19/15 Updated the thisDir variable (thanks apographon!)
9 |
10 | thisUser="suzy" # Change to the user on your computer that has DropBox mounted.
11 | socDir="/Users/${thisUser}/Dropbox/Apps/Day One/Incoming"
12 | thisDir="/Users/${thisUser}/socImport" # Directory where this script is running from
13 |
14 | if ls "${socDir}"/*.txt > /dev/null 2>&1 ; then
15 | ls "${socDir}"/*.txt > ${thisDir}/txtlist.socImport
16 | ls "${socDir}"/completed >/dev/null 2>&1 || mkdir "${socDir}"/completed 2> /dev/null
17 | while read thisFile ; do
18 | #printf "\n${thisFile}\n"
19 | dayLine=`head -1 "${thisFile}"`
20 | thisMon=`echo ${dayLine} | cut -d" " -f1`
21 | thisMonth=`date -v "${thisMon}" +%m`
22 | thisDay=`echo ${dayLine} | cut -d" " -f2 | cut -d"," -f1`
23 | thisYear=`echo ${dayLine} | cut -d" " -f3`
24 | thisTime=`echo ${dayLine} | cut -d" " -f5`
25 | postDate="${thisMonth}/${thisDay}/${thisYear} ${thisTime}"
26 | case `basename "${thisFile}" | cut -d"-" -f1` in
27 | "facebook")
28 | #echo "This is a Facebook post."
29 | postText=`tail -n +2 "${thisFile}"`
30 | #printf "${postText}\n\n"
31 | printf "Facebook Post \n${postText} \n \nImported from Facebook.\n" | /usr/local/bin/dayone -d="${postDate}" new > /dev/null && mv "${thisFile}" "${socDir}"/completed
32 | ;;
33 | "facebookphoto")
34 | echo "This is a Facebook photo post."
35 | postText=`tail -n +3 "${thisFile}"`
36 | postLink=`tail -n +2 "${thisFile}" | head -1`
37 | #photoLink=`curl -s ${postLink}`
38 | photoLink=`curl -s ${postLink} | grep "^ \n${postText} \n \nImported from Facebook.\n" | /usr/local/bin/dayone -d="${postDate}" -p="${thisDir}/photo.jpg" new > /dev/null && mv "${thisFile}" "${socDir}"/completed && rm "${thisDir}/photo.jpg"
42 | ;;
43 | "inst")
44 | #echo "This is an Instagram post."
45 | postText=`tail -n +3 "${thisFile}"`
46 | postLink=`tail -n +2 "${thisFile}" | head -1`
47 | photoLink=`curl -s ${postLink} | grep "^ /dev/null && mv "${thisFile}" "${socDir}"/completed && rm "${thisDir}/photo.jpg"
51 | ;;
52 | "twit")
53 | #echo "This is a twitter post."
54 | postLink=`tail -n +2 "${thisFile}" | head -1`
55 | postText=`tail -n +3 "${thisFile}"`
56 | #printf "${postText}\n\n"
57 | printf "Twitter Post \n${postText} \n \n
View Post
Imported from Twitter.\n" | /usr/local/bin/dayone -d="${postDate}" new > /dev/null && mv "${thisFile}" "${socDir}"/completed
58 | ;;
59 | esac
60 | #printf "About to do another...\n"
61 | sleep 5
62 | done < ${thisDir}/txtlist.socImport
63 | fi
64 |
--------------------------------------------------------------------------------