[blogger] split 'search' extractor (#2930)

This commit is contained in:
Mike Fährmann
2022-09-19 20:45:58 +02:00
parent 64202dd012
commit eef50c1f28
3 changed files with 21 additions and 12 deletions

View File

@@ -100,7 +100,7 @@ Consider all sites to be NSFW unless otherwise known.
<tr> <tr>
<td>Blogger</td> <td>Blogger</td>
<td>https://www.blogger.com/</td> <td>https://www.blogger.com/</td>
<td>Blogs, Posts, Search Results</td> <td>Blogs, Labels, Posts, Search Results</td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>

View File

@@ -173,13 +173,28 @@ class BloggerBlogExtractor(BloggerExtractor):
class BloggerSearchExtractor(BloggerExtractor): class BloggerSearchExtractor(BloggerExtractor):
"""Extractor for search resuls and labels""" """Extractor for Blogger search resuls"""
subcategory = "search" subcategory = "search"
pattern = BASE_PATTERN + r"/search(?:/?\?q=([^/?#]+)|/label/([^/?#]+))" pattern = BASE_PATTERN + r"/search/?\?q=([^&#]+)"
test = ( test = (
("https://julianbphotography.blogspot.com/search?q=400mm", { ("https://julianbphotography.blogspot.com/search?q=400mm", {
"count": "< 10" "count": "< 10"
}), }),
)
def __init__(self, match):
BloggerExtractor.__init__(self, match)
self.query = text.unquote(match.group(3))
def posts(self, blog):
return self.api.blog_search(blog["id"], self.query)
class BloggerLabelExtractor(BloggerExtractor):
"""Extractor for Blogger posts by label"""
subcategory = "label"
pattern = BASE_PATTERN + r"/search/label/([^/?#]+)"
test = (
("https://dmmagazine.blogspot.com/search/label/D%26D", { ("https://dmmagazine.blogspot.com/search/label/D%26D", {
"range": "1-25", "range": "1-25",
"count": 25, "count": 25,
@@ -188,16 +203,10 @@ class BloggerSearchExtractor(BloggerExtractor):
def __init__(self, match): def __init__(self, match):
BloggerExtractor.__init__(self, match) BloggerExtractor.__init__(self, match)
query = match.group(3) self.label = text.unquote(match.group(3))
if query:
self.query, self.label = query, None
else:
self.query, self.label = None, match.group(4)
def posts(self, blog): def posts(self, blog):
if self.query: return self.api.blog_posts(blog["id"], self.label)
return self.api.blog_search(blog["id"], text.unquote(self.query))
return self.api.blog_posts(blog["id"], text.unquote(self.label))
class BloggerAPI(): class BloggerAPI():

View File

@@ -6,4 +6,4 @@
# it under the terms of the GNU General Public License version 2 as # it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation. # published by the Free Software Foundation.
__version__ = "1.23.1" __version__ = "1.23.2-dev"