mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 19:41:11 +00:00
Images may already be absolute paths
This commit is contained in:
parent
8eec3eca5b
commit
95fce963d1
1 changed files with 6 additions and 0 deletions
|
@ -1,4 +1,6 @@
|
||||||
""" inventaire data connector """
|
""" inventaire data connector """
|
||||||
|
import re
|
||||||
|
|
||||||
from bookwyrm import models
|
from bookwyrm import models
|
||||||
from .abstract_connector import AbstractConnector, SearchResult, Mapping
|
from .abstract_connector import AbstractConnector, SearchResult, Mapping
|
||||||
from .abstract_connector import get_data
|
from .abstract_connector import get_data
|
||||||
|
@ -148,11 +150,15 @@ class Connector(AbstractConnector):
|
||||||
"""format the relative cover url into an absolute one:
|
"""format the relative cover url into an absolute one:
|
||||||
{"url": "/img/entities/e794783f01b9d4f897a1ea9820b96e00d346994f"}
|
{"url": "/img/entities/e794783f01b9d4f897a1ea9820b96e00d346994f"}
|
||||||
"""
|
"""
|
||||||
|
# covers may or may not be a list
|
||||||
if isinstance(cover_blob, list) and len(cover_blob) > 0:
|
if isinstance(cover_blob, list) and len(cover_blob) > 0:
|
||||||
cover_blob = cover_blob[0]
|
cover_blob = cover_blob[0]
|
||||||
cover_id = cover_blob.get("url")
|
cover_id = cover_blob.get("url")
|
||||||
if not cover_id:
|
if not cover_id:
|
||||||
return None
|
return None
|
||||||
|
# cover may or may not be an absolute url already
|
||||||
|
if re.match(r"^http", cover_id):
|
||||||
|
return cover_id
|
||||||
return "%s%s" % (self.covers_url, cover_id)
|
return "%s%s" % (self.covers_url, cover_id)
|
||||||
|
|
||||||
def resolve_keys(self, keys):
|
def resolve_keys(self, keys):
|
||||||
|
|
Loading…
Reference in a new issue