[shimmie2] use 'self.groups' to access matched URL values
This commit is contained in:
@@ -99,20 +99,15 @@ class Shimmie2TagExtractor(Shimmie2Extractor):
|
|||||||
subcategory = "tag"
|
subcategory = "tag"
|
||||||
directory_fmt = ("{category}", "{search_tags}")
|
directory_fmt = ("{category}", "{search_tags}")
|
||||||
file_url_fmt = "{}/_images/{}/{}%20-%20{}.{}"
|
file_url_fmt = "{}/_images/{}/{}%20-%20{}.{}"
|
||||||
pattern = BASE_PATTERN + r"post/list/([^/?#]+)(?:/(\d+))?()"
|
pattern = BASE_PATTERN + r"post/list/([^/?#]+)(?:/(\d+))?"
|
||||||
example = "https://vidya.pics/post/list/TAG/1"
|
example = "https://vidya.pics/post/list/TAG/1"
|
||||||
|
|
||||||
def __init__(self, match):
|
|
||||||
Shimmie2Extractor.__init__(self, match)
|
|
||||||
lastindex = match.lastindex
|
|
||||||
self.tags = text.unquote(match.group(lastindex-2))
|
|
||||||
self.page = match.group(lastindex-1)
|
|
||||||
|
|
||||||
def metadata(self):
|
def metadata(self):
|
||||||
|
self.tags = text.unquote(self.groups[-2])
|
||||||
return {"search_tags": self.tags}
|
return {"search_tags": self.tags}
|
||||||
|
|
||||||
def posts(self):
|
def posts(self):
|
||||||
pnum = text.parse_int(self.page, 1)
|
pnum = text.parse_int(self.groups[-1], 1)
|
||||||
file_url_fmt = self.file_url_fmt.format
|
file_url_fmt = self.file_url_fmt.format
|
||||||
|
|
||||||
init = True
|
init = True
|
||||||
@@ -166,7 +161,7 @@ class Shimmie2TagExtractor(Shimmie2Extractor):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def _posts_giantessbooru(self):
|
def _posts_giantessbooru(self):
|
||||||
pnum = text.parse_int(self.page, 1)
|
pnum = text.parse_int(self.groups[-1], 1)
|
||||||
file_url_fmt = (self.root + "/index.php?q=/image/{}.jpg").format
|
file_url_fmt = (self.root + "/index.php?q=/image/{}.jpg").format
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
@@ -203,18 +198,15 @@ class Shimmie2PostExtractor(Shimmie2Extractor):
|
|||||||
pattern = BASE_PATTERN + r"post/view/(\d+)"
|
pattern = BASE_PATTERN + r"post/view/(\d+)"
|
||||||
example = "https://vidya.pics/post/view/12345"
|
example = "https://vidya.pics/post/view/12345"
|
||||||
|
|
||||||
def __init__(self, match):
|
|
||||||
Shimmie2Extractor.__init__(self, match)
|
|
||||||
self.post_id = match.group(match.lastindex)
|
|
||||||
|
|
||||||
def posts(self):
|
def posts(self):
|
||||||
url = "{}/post/view/{}".format(self.root, self.post_id)
|
post_id = self.groups[-1]
|
||||||
|
url = "{}/post/view/{}".format(self.root, post_id)
|
||||||
page = self.request(url).text
|
page = self.request(url).text
|
||||||
extr = text.extract_from(page)
|
extr = text.extract_from(page)
|
||||||
quote = self._quote_type(page)
|
quote = self._quote_type(page)
|
||||||
|
|
||||||
post = {
|
post = {
|
||||||
"id" : self.post_id,
|
"id" : post_id,
|
||||||
"tags" : extr(": ", "<").partition(" - ")[0].rstrip(")"),
|
"tags" : extr(": ", "<").partition(" - ")[0].rstrip(")"),
|
||||||
"md5" : extr("/_thumbs/", "/"),
|
"md5" : extr("/_thumbs/", "/"),
|
||||||
"file_url": self.root + (
|
"file_url": self.root + (
|
||||||
@@ -232,12 +224,12 @@ class Shimmie2PostExtractor(Shimmie2Extractor):
|
|||||||
return (post,)
|
return (post,)
|
||||||
|
|
||||||
def _posts_giantessbooru(self):
|
def _posts_giantessbooru(self):
|
||||||
url = "{}/index.php?q=/post/view/{}".format(
|
post_id = self.groups[-1]
|
||||||
self.root, self.post_id)
|
url = "{}/index.php?q=/post/view/{}".format(self.root, post_id)
|
||||||
extr = text.extract_from(self.request(url).text)
|
extr = text.extract_from(self.request(url).text)
|
||||||
|
|
||||||
return ({
|
return ({
|
||||||
"id" : self.post_id,
|
"id" : post_id,
|
||||||
"tags" : extr(": ", "<").partition(" - ")[0].rstrip(")"),
|
"tags" : extr(": ", "<").partition(" - ")[0].rstrip(")"),
|
||||||
"md5" : "",
|
"md5" : "",
|
||||||
"file_url": self.root + extr("id='main_image' src='.", "'"),
|
"file_url": self.root + extr("id='main_image' src='.", "'"),
|
||||||
|
|||||||
Reference in New Issue
Block a user