From 9e99b6e6045435867c23f00cdaad81021cc262a5 Mon Sep 17 00:00:00 2001 From: Julian Murgia Date: Thu, 6 Jul 2017 20:26:51 +0200 Subject: [PATCH] Added error management. --- feed2toot/main.py | 2 -- feed2toot/tootpost.py | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/feed2toot/main.py b/feed2toot/main.py index 9baf6a3..aca786d 100644 --- a/feed2toot/main.py +++ b/feed2toot/main.py @@ -65,7 +65,6 @@ class Main(object): """The main function.""" # regex_img_src to retrieve urls in tags regex_img_src = re.compile(r"]*?\s+)?href=[\"'](.*?)[\"']|]+src=\"([^\">]+)\"") - regex_strip_urls = re.compile(r"([a-z]+\.twitter\.com(\/\S+)?|https?:\/\/twitter\.com((\/\w+)?)+)") http = urllib3.PoolManager() clip = CliParse() @@ -150,7 +149,6 @@ class Main(object): images.append(resp) resp.release_conn() - severalwordsinhashtag = False # lets see if the rss feed has hashtag if 'tags' in entry: diff --git a/feed2toot/tootpost.py b/feed2toot/tootpost.py index 9ac95b0..54fcac8 100644 --- a/feed2toot/tootpost.py +++ b/feed2toot/tootpost.py @@ -48,8 +48,9 @@ class TootPost: medias_dicts = [] if len(self.img_list) > 0: for img in self.img_list: - medias_dicts.append(mastodon.media_post(img.data, - img.headers['content-type'])) + media_dict = mastodon.media_post(img.data, img.headers['content-type']) + if ('error' not in media_dict): + medias_dicts.append(media_dict) mastodon.status_post(self.toot, visibility=self.config.get(