Skip to content

Commit

Permalink
[bluesky] simplify 'pattern'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Feb 8, 2024
1 parent da292de commit 86ce35d
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions gallery_dl/extractor/bluesky.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from ..cache import cache, memcache

BASE_PATTERN = r"(?:https?://)?bsky\.app"
USER_PATTERN = BASE_PATTERN + r"/profile/([^/?#]+)"


class BlueskyExtractor(Extractor):
Expand Down Expand Up @@ -70,7 +71,7 @@ def posts(self):

class BlueskyUserExtractor(BlueskyExtractor):
subcategory = "user"
pattern = BASE_PATTERN + r"/profile/([^/?#]+)$"
pattern = USER_PATTERN + r"$"
example = "https://bsky.app/profile/HANDLE"

def initialize(self):
Expand All @@ -88,7 +89,7 @@ def items(self):

class BlueskyPostsExtractor(BlueskyExtractor):
subcategory = "posts"
pattern = BASE_PATTERN + r"/profile/([^/?#]+)/posts"
pattern = USER_PATTERN + r"/posts"
example = "https://bsky.app/profile/HANDLE/posts"

def posts(self):
Expand All @@ -97,7 +98,7 @@ def posts(self):

class BlueskyRepliesExtractor(BlueskyExtractor):
subcategory = "replies"
pattern = BASE_PATTERN + r"/profile/([^/?#]+)/replies"
pattern = USER_PATTERN + r"/replies"
example = "https://bsky.app/profile/HANDLE/replies"

def posts(self):
Expand All @@ -106,7 +107,7 @@ def posts(self):

class BlueskyMediaExtractor(BlueskyExtractor):
subcategory = "media"
pattern = BASE_PATTERN + r"/profile/([^/?#]+)/media"
pattern = USER_PATTERN + r"/media"
example = "https://bsky.app/profile/HANDLE/media"

def posts(self):
Expand All @@ -115,7 +116,7 @@ def posts(self):

class BlueskyLikesExtractor(BlueskyExtractor):
subcategory = "likes"
pattern = BASE_PATTERN + r"/profile/([^/?#]+)/likes"
pattern = USER_PATTERN + r"/likes"
example = "https://bsky.app/profile/HANDLE/likes"

def posts(self):
Expand All @@ -124,7 +125,7 @@ def posts(self):

class BlueskyFeedExtractor(BlueskyExtractor):
subcategory = "feed"
pattern = BASE_PATTERN + r"/profile/([^/?#]+)/feed/([^/?#]+)"
pattern = USER_PATTERN + r"/feed/([^/?#]+)"
example = "https://bsky.app/profile/HANDLE/feed/NAME"

def __init__(self, match):
Expand All @@ -137,7 +138,7 @@ def posts(self):

class BlueskyListExtractor(BlueskyExtractor):
subcategory = "list"
pattern = BASE_PATTERN + r"/profile/([^/?#]+)/lists/([^/?#]+)"
pattern = USER_PATTERN + r"/lists/([^/?#]+)"
example = "https://bsky.app/profile/HANDLE/lists/ID"

def __init__(self, match):
Expand All @@ -150,7 +151,7 @@ def posts(self):

class BlueskyPostExtractor(BlueskyExtractor):
subcategory = "post"
pattern = BASE_PATTERN + r"/profile/([^/?#]+)/post/([^/?#]+)"
pattern = USER_PATTERN + r"/post/([^/?#]+)"
example = "https://bsky.app/profile/HANDLE/post/ID"

def __init__(self, match):
Expand Down

0 comments on commit 86ce35d

Please sign in to comment.