[booru] improve error handling

e.g. for posts without a valid 'file_url' (#1176)
This commit is contained in:
Mike Fährmann
2020-12-16 22:11:10 +01:00
parent 1f9121fecb
commit 8d2e4e5f13
5 changed files with 8 additions and 6 deletions

View File

@@ -1,5 +1,7 @@
# Changelog # Changelog
## Unreleased
## 1.16.0 - 2020-12-12 ## 1.16.0 - 2020-12-12
### Additions ### Additions
- [booru] implement generalized extractors for `*booru` and `moebooru` sites - [booru] implement generalized extractors for `*booru` and `moebooru` sites

View File

@@ -30,7 +30,11 @@ class BooruExtractor(Extractor):
for post in self.posts(): for post in self.posts():
try: try:
url = self._prepare_post(post, extended_tags) url = self._prepare_post(post, extended_tags)
except KeyError: if url[0] == "/":
url = self.root + url
except Exception:
self.log.debug("Unable to fetch download URL for post %s "
"(md5: %s)", post.get("id"), post.get("md5"))
continue continue
post.update(data) post.update(data)
text.nameext_from_url(url, post) text.nameext_from_url(url, post)

View File

@@ -25,8 +25,6 @@ class MoebooruExtractor(BooruExtractor):
def _prepare_post(self, post, extended_tags=False): def _prepare_post(self, post, extended_tags=False):
url = post["file_url"] url = post["file_url"]
if url[0] == "/":
url = self.root + url
if extended_tags: if extended_tags:
self._fetch_extended_tags(post) self._fetch_extended_tags(post)
post["date"] = text.parse_timestamp(post["created_at"]) post["date"] = text.parse_timestamp(post["created_at"])

View File

@@ -38,8 +38,6 @@ class SankakuExtractor(BooruExtractor):
def _prepare_post(self, post, extended_tags=False): def _prepare_post(self, post, extended_tags=False):
url = post["file_url"] url = post["file_url"]
if url[0] == "/":
url = self.root + url
if extended_tags: if extended_tags:
self._fetch_extended_tags(post) self._fetch_extended_tags(post)
post["date"] = text.parse_timestamp(post["created_at"]["s"]) post["date"] = text.parse_timestamp(post["created_at"]["s"])

View File

@@ -6,4 +6,4 @@
# it under the terms of the GNU General Public License version 2 as # it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation. # published by the Free Software Foundation.
__version__ = "1.16.0" __version__ = "1.16.1-dev"