Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions TweetBoxBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# #
# **************************************************** #

import urllib, urlparse, json, random, os, time, sys
import urljoin, urllib.parse, json, random, os, time, sys, urllib, urllib.request

from twython import Twython

Expand Down Expand Up @@ -342,23 +342,22 @@ def movie():
return content, media;


# Get Astronomy Picture Of the Day (NASA)
# Get Astronomy Picture Of the Day (NASA)
def apod():
datas = json.loads(urllib.urlopen("https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY").read())
datas = json.loads(urllib.request.urlopen("https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY").read())
picture = datas['hdurl']
title = datas['title']
date = datas['date']

filename, file_ext = os.path.splitext(os.path.basename(urlparse.urlsplit(picture).path))
urllib.urlretrieve(picture, TMP_FILE+file_ext)
filename, file_ext = os.path.splitext(os.path.basename(urllib.parse.urlsplit(picture).path))

urllib.request.urlretrieve(picture, TMP_FILE+file_ext)

content = "NASA APOD of "+date+" - "+title+" #nasa @apod"
content = "NASA APOD of "+date+" - "+title+" @apod"
media = TMP_FILE+file_ext

return content, media;



# Get some number fact with numbersapi.com
def numbers():
datas = json.loads(urllib.urlopen("http://numbersapi.com/random/trivia?json").read())
Expand Down