1
0
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:
Mike Fährmann 2023-04-19 20:09:11 +02:00
parent 6f1e34ec69
commit faca32a850
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -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}