Skip to content

Commit

Permalink
[unsplash] update collections URL pattern (fixes #1627)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Jun 15, 2021
1 parent 9ed1370 commit d8908ca
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions gallery_dl/extractor/unsplash.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,16 @@ def photos(self):
class UnsplashCollectionExtractor(UnsplashExtractor):
"""Extractor for an unsplash collection"""
subcategory = "collection"
pattern = BASE_PATTERN + r"/collections/(\d+)"
test = ("https://unsplash.com/collections/3178572/winter", {
"pattern": r"https://images\.unsplash\.com/(photo-\d+-\w+"
r"|reserve/[^/?#]+)\?ixid=\w+&ixlib=rb-1\.2\.1$",
"range": "1-30",
"count": 30,
})
pattern = BASE_PATTERN + r"/collections/([^/?#]+)"
test = (
("https://unsplash.com/collections/3178572/winter", {
"pattern": r"https://images\.unsplash\.com/(photo-\d+-\w+"
r"|reserve/[^/?#]+)\?ixid=\w+&ixlib=rb-1\.2\.1$",

This comment has been minimized.

Copy link
@rautamiekka

rautamiekka Jun 16, 2021

Contributor

rb-1\.2\.1
Is that a good idea instead of rb-[0-9]+(?:\.[0-9]+)* ?

This comment has been minimized.

Copy link
@mikf

mikf Jun 16, 2021

Author Owner

That's just the test regex for image URLs.
And yes, I do think rb-1\.2\.1 is better than rb-[0-9]+(?:\.[0-9]+)* here, because it is more specific and faster at detecting potential changes, which is what those tests are for.

The actual relevant change in this commit was (\d+) -> ([^/?#]+) in pattern in line 175.

"range": "1-30",
"count": 30,
}),
("https://unsplash.com/collections/_8qJQ2bCMWE/2021.05"),
)

def photos(self):
url = "{}/napi/collections/{}/photos".format(self.root, self.item)
Expand Down

0 comments on commit d8908ca

Please sign in to comment.