filter "private" kwdict entries
This commit is contained in:
@@ -119,7 +119,7 @@ class FlickrAlbumExtractor(FlickrExtractor):
|
|||||||
}),
|
}),
|
||||||
("https://www.flickr.com/photos/shona_s/albums", {
|
("https://www.flickr.com/photos/shona_s/albums", {
|
||||||
"url": "657d541470482e0d69deec33ab97a6d7d4af6fe4",
|
"url": "657d541470482e0d69deec33ab97a6d7d4af6fe4",
|
||||||
"keyword": "ef654bfbc4ce7b74ad74e7d772e5466285ffc581",
|
"keyword": "736a41a7d702f7fe00edc957ae201d84f745e654",
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ class XvideosUserExtractor(XvideosExtractor):
|
|||||||
test = (
|
test = (
|
||||||
("https://www.xvideos.com/profiles/pervertedcouple", {
|
("https://www.xvideos.com/profiles/pervertedcouple", {
|
||||||
"url": "a413f3e60d6d3a2de79bd44fa3b7a9c03db4336e",
|
"url": "a413f3e60d6d3a2de79bd44fa3b7a9c03db4336e",
|
||||||
"keyword": "ef941489354fd8f4754c8a87cffd5e2429a6387c",
|
"keyword": "a796760d34732adc7ec52a8feb057515209a2ca6",
|
||||||
}),
|
}),
|
||||||
("https://www.xvideos.com/profiles/niwehrwhernvh", {
|
("https://www.xvideos.com/profiles/niwehrwhernvh", {
|
||||||
"exception": exception.NotFoundError,
|
"exception": exception.NotFoundError,
|
||||||
|
|||||||
@@ -170,6 +170,11 @@ class Job():
|
|||||||
if self.ulog:
|
if self.ulog:
|
||||||
self.ulog.info(url)
|
self.ulog.info(url)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _filter(kwdict):
|
||||||
|
"""Return a copy of 'kwdict' without "private" entries"""
|
||||||
|
return {k: v for k, v in kwdict.items() if k[0] != "_"}
|
||||||
|
|
||||||
|
|
||||||
class DownloadJob(Job):
|
class DownloadJob(Job):
|
||||||
"""Download images into appropriate directory/filename locations"""
|
"""Download images into appropriate directory/filename locations"""
|
||||||
@@ -516,8 +521,9 @@ class TestJob(DownloadJob):
|
|||||||
|
|
||||||
def update_keyword(self, kwdict, to_list=True):
|
def update_keyword(self, kwdict, to_list=True):
|
||||||
"""Update the keyword hash"""
|
"""Update the keyword hash"""
|
||||||
|
kwdict = self._filter(kwdict)
|
||||||
if to_list:
|
if to_list:
|
||||||
self.list_keyword.append(kwdict.copy())
|
self.list_keyword.append(kwdict)
|
||||||
self.hash_keyword.update(
|
self.hash_keyword.update(
|
||||||
json.dumps(kwdict, sort_keys=True, default=str).encode())
|
json.dumps(kwdict, sort_keys=True, default=str).encode())
|
||||||
|
|
||||||
@@ -566,17 +572,17 @@ class DataJob(Job):
|
|||||||
)
|
)
|
||||||
self.file.write("\n")
|
self.file.write("\n")
|
||||||
|
|
||||||
def handle_url(self, url, keywords):
|
def handle_url(self, url, kwdict):
|
||||||
self.data.append((Message.Url, url, keywords.copy()))
|
self.data.append((Message.Url, url, self._filter(kwdict)))
|
||||||
|
|
||||||
def handle_urllist(self, urls, keywords):
|
def handle_urllist(self, urls, kwdict):
|
||||||
self.data.append((Message.Urllist, list(urls), keywords.copy()))
|
self.data.append((Message.Urllist, list(urls), self._filter(kwdict)))
|
||||||
|
|
||||||
def handle_directory(self, keywords):
|
def handle_directory(self, kwdict):
|
||||||
self.data.append((Message.Directory, keywords.copy()))
|
self.data.append((Message.Directory, self._filter(kwdict)))
|
||||||
|
|
||||||
def handle_queue(self, url, keywords):
|
def handle_queue(self, url, kwdict):
|
||||||
self.data.append((Message.Queue, url, keywords.copy()))
|
self.data.append((Message.Queue, url, self._filter(kwdict)))
|
||||||
|
|
||||||
def handle_finalize(self):
|
def handle_finalize(self):
|
||||||
self.file.close()
|
self.file.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user