Skip to content

Commit 54852fd

Browse files
committed
Merge branch 'master' of https://github.com/PawelPleskaczynski/apod-api into PawelPleskaczynski-master
2 parents 52b0c8d + 8cc3230 commit 54852fd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

utility.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ def _get_thumbs(data):
4646

4747
return video_thumb
4848

49+
# function that returns only last URL if there are multiple URLs stacked together
50+
def _get_last_url(data):
51+
regex = re.compile("(?:.(?!http[s]?://))+$")
52+
return regex.findall(data)[0]
4953

5054
def _get_apod_chars(dt, thumbs):
5155
media_type = 'image'
@@ -83,11 +87,11 @@ def _get_apod_chars(dt, thumbs):
8387
props['copyright'] = copyright_text
8488
props['media_type'] = media_type
8589
if data:
86-
props['url'] = data
90+
props['url'] = _get_last_url(data)
8791
props['date'] = dt.isoformat()
8892

8993
if hd_data:
90-
props['hdurl'] = hd_data
94+
props['hdurl'] = _get_last_url(hd_data)
9195

9296
if thumbs and media_type == "video":
9397
if thumbs.lower() == "true":

0 commit comments

Comments
 (0)