| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
"""Extractors for https://www.wikifeet.com/""" |
| 8 |
|
| 9 |
from .common import GalleryExtractor |
| 10 |
from .. import text, util |
| 11 |
|
| 12 |
|
| 13 |
class WikifeetGalleryExtractor(GalleryExtractor): |
| 14 |
"""Extractor for image galleries from wikifeet.com""" |
| 15 |
category = "wikifeet" |
| 16 |
directory_fmt = ("{category}", "{celebrity}") |
| 17 |
filename_fmt = "{category}_{celeb}_{pid}.{extension}" |
| 18 |
archive_fmt = "{type}_{celeb}_{pid}" |
| 19 |
pattern = (r"(?:https?://)(?:(?:www\.)?wikifeetx?|" |
| 20 |
r"men\.wikifeet)\.com/([^/?#]+)") |
| 21 |
example = "https://www.wikifeet.com/CELEB" |
| 22 |
|
| 23 |
def __init__(self, match): |
| 24 |
self.root = text.root_from_url(match[0]) |
| 25 |
if "wikifeetx.com" in self.root: |
| 26 |
self.category = "wikifeetx" |
| 27 |
self.type = "men" if "://men." in self.root else "women" |
| 28 |
self.celeb = match[1] |
| 29 |
GalleryExtractor.__init__(self, match, self.root + "/" + self.celeb) |
| 30 |
|
| 31 |
def metadata(self, page): |
| 32 |
extr = text.extract_from(page) |
| 33 |
return { |
| 34 |
"celeb" : self.celeb, |
| 35 |
"type" : self.type, |
| 36 |
"birthplace": text.unescape(extr('"bplace":"', '"')), |
| 37 |
"birthday" : self.parse_datetime_iso(text.unescape(extr( |
| 38 |
'"bdate":"', '"'))[:10]), |
| 39 |
"shoesize" : text.unescape(extr('"ssize":', ',')), |
| 40 |
"rating" : text.parse_float(extr('"score":', ',')), |
| 41 |
"celebrity" : text.unescape(extr('"cname":"', '"')), |
| 42 |
} |
| 43 |
|
| 44 |
def images(self, page): |
| 45 |
tagmap = { |
| 46 |
"C": "Close-up", |
| 47 |
"T": "Toenails", |
| 48 |
"N": "Nylons", |
| 49 |
"A": "Arches", |
| 50 |
"S": "Soles", |
| 51 |
"B": "Barefoot", |
| 52 |
} |
| 53 |
|
| 54 |
gallery = text.extr(page, '"gallery":[', '],') |
| 55 |
base = f"https://pics.wikifeet.com/{self.celeb}-Feet-" |
| 56 |
return [ |
| 57 |
(f"{base}{data['pid']}.jpg", { |
| 58 |
"pid" : data["pid"], |
| 59 |
"width" : data["pw"], |
| 60 |
"height": data["ph"], |
| 61 |
"tags" : [ |
| 62 |
tagmap[tag] |
| 63 |
for tag in data["tags"] if tag in tagmap |
| 64 |
], |
| 65 |
}) |
| 66 |
for data in util.json_loads(f"[{gallery}]") |
| 67 |
] |