From 7ef58901303e9fa0744678b9899652021a631622 Mon Sep 17 00:00:00 2001 From: Krapace <63866978+Krapace@users.noreply.github.com> Date: Tue, 24 Jan 2023 10:11:00 +0100 Subject: [PATCH 1/2] Update fonction apod --- TweetBoxBot.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/TweetBoxBot.py b/TweetBoxBot.py index f2ba066..7ec7eac 100644 --- a/TweetBoxBot.py +++ b/TweetBoxBot.py @@ -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()) From a53686fa6e5521fc869d785dfd93e34968713da2 Mon Sep 17 00:00:00 2001 From: Krapace <63866978+Krapace@users.noreply.github.com> Date: Tue, 24 Jan 2023 10:12:58 +0100 Subject: [PATCH 2/2] Update TweetBoxBot.py --- TweetBoxBot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TweetBoxBot.py b/TweetBoxBot.py index 7ec7eac..d2d6aa9 100644 --- a/TweetBoxBot.py +++ b/TweetBoxBot.py @@ -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