├── _config.yml ├── iss_tracker_file_gen.pyc ├── README.md ├── iss_tracker.py └── iss_tracker_file_gen.py /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /iss_tracker_file_gen.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mehulj94/ISS-Tracker-Raspberry-Pi/HEAD/iss_tracker_file_gen.pyc -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #ISS Tracker and Tweet bot 2 | This twitter bot will check for the ISS sightings in your city and tweet a day before the sighting! 3 | Just add the cron job and leave the rest of the job for Raspberry Pi. 4 | 5 | For Setting this Bot for your city follow this instructions: 6 | 7 | --> VISIT http://spotthestation.nasa.gov/sightings/ 8 | 9 | --> Select the country and the city and click on Next 10 | 11 | --> Click on RSS and paste the link in iss_tracker_file_gen.py 12 | -------------------------------------------------------------------------------- /iss_tracker.py: -------------------------------------------------------------------------------- 1 | import tweepy 2 | import datetime 3 | import iss_tracker_file_gen 4 | 5 | ckey = '' #Consumer Key from Twitter 6 | csecret = '' #Consumer secret from Twitter 7 | atoken = '' #Access Key from Twitter 8 | asecret = '' #Access secret from Twitter 9 | 10 | ISS_data = iss_tracker_file_gen.iss_date_tweet_dict 11 | 12 | First_Key = ISS_data.iterkeys().next() 13 | Next_Iss_visit = datetime.datetime.strptime(First_Key , '%Y-%m-%d').date() 14 | Today = datetime.date.today() 15 | 16 | time_to_iss_visit = abs(Next_Iss_visit - Today) 17 | days = time_to_iss_visit.days 18 | 19 | if days < 2: 20 | auth = tweepy.OAuthHandler(ckey,csecret) 21 | auth.set_access_token(atoken,asecret) 22 | api = tweepy.API(auth) 23 | 24 | api.update_status(status = ISS_data.itervalues().next().encode('ascii','ignore')) 25 | #print ISS_data.itervalues().next().encode('ascii','ignore') 26 | 27 | # else: 28 | # print 'Days left for Iss visit is: '+ str(days) 29 | # print ISS_data 30 | #Uncomment above if you want to see output on command line 31 | -------------------------------------------------------------------------------- /iss_tracker_file_gen.py: -------------------------------------------------------------------------------- 1 | import codecs 2 | import datetime 3 | import urllib2 4 | from xml.etree import ElementTree as etree 5 | 6 | #VISIT http://spotthestation.nasa.gov/sightings/ 7 | #Select the country and the city and click on Next 8 | #Click on RSS and paste the link here: 9 | iss_tracker_link ="http://spotthestation.nasa.gov/sightings/xml_files/Angola_None_Luanda.xml" #example link 10 | 11 | read_iss_link = urllib2.urlopen(iss_tracker_link).read() 12 | 13 | iss_root = etree.fromstring(read_iss_link) 14 | item = iss_root.findall('channel/item') 15 | 16 | iss_desc = [] 17 | iss_date_tweet_dict = {} 18 | 19 | for entry in item: 20 | desc = entry.findtext('description') 21 | iss_desc.append(desc) 22 | 23 | for entry in iss_desc: 24 | 25 | entry = entry.replace("
","") 26 | entry = entry.replace("\n\t\t\t\t","") 27 | entry = entry.replace("Date: ","") 28 | 29 | loc_maxm = entry.find("Maximum") 30 | loc_time = entry.find("Time") 31 | loc_duration = entry.find("Duration") 32 | 33 | tweet_date = str(datetime.datetime.strptime(entry[:loc_time], "%A %b %d, %Y ").date()) 34 | 35 | #Change the hashtag to your city! 36 | iss_date_tweet_dict[tweet_date] = "The International Space Station is passing overhead on " + entry[:loc_time] + "at "+ entry[loc_time+6:loc_duration] + "for" + entry[loc_duration+9:loc_maxm-1] + ". #HashTag" 37 | 38 | #IGNORE THIS! 39 | # save_iss_dates = open('iss_overhead_pass.py','w') 40 | # save_iss_dates.write(str(iss_date_tweet_dict)) 41 | # save_iss_dates.close() --------------------------------------------------------------------------------