mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-26 12:42:29 +01:00
[sankaku] sanitize 'date:…' tags (#1790)
This commit is contained in:
parent
6f1e34ec69
commit
faca32a850
@ -13,6 +13,7 @@ from .common import Message
|
||||
from .. import text, util, exception
|
||||
from ..cache import cache
|
||||
import collections
|
||||
import re
|
||||
|
||||
BASE_PATTERN = r"(?:https?://)?" \
|
||||
r"(?:(?:chan|beta|black|white)\.sankakucomplex\.com|sankaku\.app)" \
|
||||
@ -101,6 +102,11 @@ class SankakuTagExtractor(SankakuExtractor):
|
||||
# match arbitrary query parameters
|
||||
("https://chan.sankakucomplex.com"
|
||||
"/?tags=marie_rose&page=98&next=3874906&commit=Search"),
|
||||
# 'date:' tags (#1790)
|
||||
("https://chan.sankakucomplex.com/?tags=date:2023-03-20", {
|
||||
"range": "1",
|
||||
"count": 1,
|
||||
}),
|
||||
)
|
||||
|
||||
def __init__(self, match):
|
||||
@ -108,6 +114,15 @@ class SankakuTagExtractor(SankakuExtractor):
|
||||
query = text.parse_query(match.group(1))
|
||||
self.tags = text.unquote(query.get("tags", "").replace("+", " "))
|
||||
|
||||
if "date:" in self.tags:
|
||||
# rewrite 'date:' tags (#1790)
|
||||
self.tags = re.sub(
|
||||
r"date:(\d\d)[.-](\d\d)[.-](\d\d\d\d)",
|
||||
r"date:\3.\2.\1", self.tags)
|
||||
self.tags = re.sub(
|
||||
r"date:(\d\d\d\d)[.-](\d\d)[.-](\d\d)",
|
||||
r"date:\1.\2.\3", self.tags)
|
||||
|
||||
def metadata(self):
|
||||
return {"search_tags": self.tags}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user