Handle exceptions
This commit is contained in:
parent
27bb8bf0b8
commit
07f15a470a
|
@ -1,6 +1,11 @@
|
||||||
import json
|
import json
|
||||||
from mastodon import Mastodon, StreamListener
|
from mastodon import Mastodon, StreamListener
|
||||||
|
|
||||||
|
|
||||||
|
def print_status(status):
|
||||||
|
print("time: " + str(status["created_at"]))
|
||||||
|
print("from: @" + status["account"]["acct"])
|
||||||
|
|
||||||
with open("config.json", 'r') as f:
|
with open("config.json", 'r') as f:
|
||||||
config = json.load(f)
|
config = json.load(f)
|
||||||
|
|
||||||
|
@ -18,11 +23,17 @@ if config:
|
||||||
class TootListener(StreamListener):
|
class TootListener(StreamListener):
|
||||||
def on_update(self, status):
|
def on_update(self, status):
|
||||||
print("")
|
print("")
|
||||||
print(" -- new status in chaos.social -- ")
|
print(" -- new status in " + config["source"]["url"] + " -- ")
|
||||||
print(status)
|
print_status(status)
|
||||||
|
#print(status)
|
||||||
print("")
|
print("")
|
||||||
print(" -- search in fem.social -- ")
|
print(" -- search in " + config["drain"]["url"] + " -- ")
|
||||||
print(fem_social.search(status.url))
|
try:
|
||||||
|
search = fem_social.search(status.url)
|
||||||
|
for s in search["statuses"]:
|
||||||
|
print_status(s)
|
||||||
|
except:
|
||||||
|
print("failed")
|
||||||
|
|
||||||
tootListener = TootListener()
|
tootListener = TootListener()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue