add a simplified version of 'parse_qs'
This version only returns a dict of plain string to string key-value pairs and ignores multiple values for the same query variable.
This commit is contained in:
parent
3b21e0703c
commit
f7cdfd4c25
@ -10,7 +10,6 @@
|
||||
|
||||
from .common import Extractor, Message
|
||||
from .. import text, util, exception
|
||||
import urllib.parse
|
||||
|
||||
|
||||
class FlickrExtractor(Extractor):
|
||||
@ -225,10 +224,7 @@ class FlickrSearchExtractor(FlickrExtractor):
|
||||
|
||||
def __init__(self, match):
|
||||
FlickrExtractor.__init__(self, match)
|
||||
self.search = {
|
||||
key: vlist[0]
|
||||
for key, vlist in urllib.parse.parse_qs(match.group(1)).items()
|
||||
}
|
||||
self.search = text.parse_query(match.group(1))
|
||||
if "text" not in self.search:
|
||||
self.search["text"] = ""
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
from .common import Extractor, Message
|
||||
from .. import text, exception
|
||||
from ..cache import cache
|
||||
import urllib.parse
|
||||
import re
|
||||
|
||||
|
||||
@ -141,7 +140,7 @@ class PixivUserExtractor(PixivExtractor):
|
||||
PixivExtractor.__init__(self)
|
||||
self.user_id, tag = match.groups()
|
||||
if tag:
|
||||
self.tag = urllib.parse.unquote(tag).lower()
|
||||
self.tag = text.unquote(tag).lower()
|
||||
self.works = self._tagged_works
|
||||
|
||||
def works(self):
|
||||
@ -267,7 +266,7 @@ class PixivRankingExtractor(PixivExtractor):
|
||||
test = [
|
||||
(("https://www.pixiv.net/ranking.php"
|
||||
"?mode=daily&content=illust&date=20170818"), {
|
||||
"url": "7fdffbecfbd420b1d202fa417d79317240be30bc",
|
||||
"url": "b073c74e3a6633dbdc9ba4122448f66e5211c771",
|
||||
}),
|
||||
("https://www.pixiv.net/ranking.php", None),
|
||||
]
|
||||
@ -277,10 +276,7 @@ class PixivRankingExtractor(PixivExtractor):
|
||||
self._iter = None
|
||||
self._first = None
|
||||
|
||||
query = {
|
||||
key: vlist[0]
|
||||
for key, vlist in urllib.parse.parse_qs(match.group(1)).items()
|
||||
}
|
||||
query = text.parse_query(match.group(1))
|
||||
self.mode = query.get("mode", "daily")
|
||||
self.content = query.get("content", "all")
|
||||
self.date = query.get("date")
|
||||
|
@ -130,6 +130,11 @@ def extract_iter(txt, begin, end, pos=0):
|
||||
yield value
|
||||
|
||||
|
||||
def parse_query(qs):
|
||||
"""Parse a query string into key-value pairs"""
|
||||
return {key: vlist[0] for key, vlist in urllib.parse.parse_qs(qs).items()}
|
||||
|
||||
|
||||
if os.name == "nt":
|
||||
clean_path = clean_path_windows
|
||||
else:
|
||||
|
@ -58,7 +58,7 @@ skip = [
|
||||
"exhentai", "kissmanga", "mangafox", "dynastyscans", "nijie",
|
||||
"archivedmoe", "archiveofsins", "thebarchive",
|
||||
# temporary issues
|
||||
"imgtrex", # 504
|
||||
"mangapark",
|
||||
]
|
||||
# enable selective testing for direct calls
|
||||
if __name__ == '__main__' and len(sys.argv) > 1:
|
||||
|
Loading…
x
Reference in New Issue
Block a user