From 0f94fa9015615baae379bc035d905844a2043432 Mon Sep 17 00:00:00 2001
From: Allen <64094914+allendema@users.noreply.github.com>
Date: Tue, 29 Oct 2024 12:44:27 +0100
Subject: [PATCH] [tumblr] search extractor minimal styling changes
---
docs/supportedsites.md | 2 +-
gallery_dl/extractor/tumblr.py | 16 ++++++----------
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/docs/supportedsites.md b/docs/supportedsites.md
index 2790476f..4f2c0a2e 100644
--- a/docs/supportedsites.md
+++ b/docs/supportedsites.md
@@ -886,7 +886,7 @@ Consider all listed sites to potentially be NSFW.
Tumblr |
https://www.tumblr.com/ |
- Days, Likes, Posts, Tag Searches, User Profiles |
+ Days, Likes, Posts, Search Results, Tag Searches, User Profiles |
OAuth |
diff --git a/gallery_dl/extractor/tumblr.py b/gallery_dl/extractor/tumblr.py
index 4a32879f..8fc46f63 100644
--- a/gallery_dl/extractor/tumblr.py
+++ b/gallery_dl/extractor/tumblr.py
@@ -22,8 +22,8 @@ BASE_PATTERN = (
r"([\w-]+\.tumblr\.com)))"
)
-POST_TYPES = frozenset((
- "text", "quote", "link", "answer", "video", "audio", "photo", "chat", "search"))
+POST_TYPES = frozenset(("text", "quote", "link", "answer", "video",
+ "audio", "photo", "chat", "search"))
class TumblrExtractor(Extractor):
@@ -38,7 +38,6 @@ class TumblrExtractor(Extractor):
Extractor.__init__(self, match)
name = match.group(2)
-
if name:
self.blog = name + ".tumblr.com"
else:
@@ -367,7 +366,6 @@ class TumblrLikesExtractor(TumblrExtractor):
class TumblrSearchExtractor(TumblrExtractor):
"""Extractor for a Tumblr search"""
subcategory = "search"
- """ https://www.tumblr.com/search/nathan%20fielder?src=suggested_tag """
pattern = BASE_PATTERN + r'/search/(.*?)(\?.*)?$'
example = "https://www.tumblr.com/search/QUERY"
@@ -381,7 +379,7 @@ class TumblrSearchExtractor(TumblrExtractor):
self.params = text.parse_query(parsed_url.query)
def search(self, query, params):
- """Retrieve published posts"""
+ """Retrieve search results"""
params["limit"] = 50
params["days"] = self.params.get("t") or 0
@@ -526,11 +524,9 @@ class TumblrAPI(oauth.OAuth1API):
raise exception.StopExtraction(data)
- def _pagination(self, full_endpoint, params, key="posts", cache=False):
- if not full_endpoint.endswith("?"):
- full_endpoint = full_endpoint + "?"
-
- endpoint = full_endpoint
+ def _pagination(self, endpoint, params, key="posts", cache=False):
+ if endpoint[-1] != "?":
+ endpoint += "?"
if self.api_key:
params["api_key"] = self.api_key