Skip to content

Commit

Permalink
[architizer] add 'project' extractor (#1369)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Mar 16, 2021
1 parent 3378b39 commit 71523aa
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/supportedsites.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ Consider all sites to be NSFW unless otherwise known.
<td>Galleries</td>
<td></td>
</tr>
<tr>
<td>Architizer</td>
<td>https://architizer.com/</td>
<td>Projects</td>
<td></td>
</tr>
<tr>
<td>ArtStation</td>
<td>https://www.artstation.com/</td>
Expand Down
1 change: 1 addition & 0 deletions gallery_dl/extractor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"8kun",
"8muses",
"adultempire",
"architizer",
"artstation",
"aryion",
"bcy",
Expand Down
74 changes: 74 additions & 0 deletions gallery_dl/extractor/architizer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# -*- coding: utf-8 -*-

# Copyright 2021 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.

"""Extractors for https://architizer.com/"""

from .common import GalleryExtractor
from .. import text


class ArchitizerProjectExtractor(GalleryExtractor):
"""Extractor for project pages on architizer.com"""
category = "architizer"
subcategory = "project"
root = "https://architizer.com"
directory_fmt = ("{category}", "{firm}", "{title}")
filename_fmt = "{filename}.{extension}"
archive_fmt = "{gid}_{num}"
pattern = r"(?:https?://)?architizer\.com/projects/([^/?#]+)"
test = ("https://architizer.com/projects/house-lo/", {
"pattern": r"https://architizer-prod\.imgix\.net/media/mediadata"
r"/uploads/.+\.jpg$",
"keyword": {
"count": 27,
"description": str,
"firm": "Atelier Lina Bellovicova",
"gid": "225496",
"location": "Czechia",
"num": int,
"size": "1000 sqft - 3000 sqft",
"slug": "house-lo",
"status": "Built",
"subcategory": "project",
"title": "House LO",
"type": "Residential › Private House",
"year": "2018",
},
})

def __init__(self, match):
url = "{}/projects/{}/".format(self.root, match.group(1))
GalleryExtractor.__init__(self, match, url)

def metadata(self, page):
extr = text.extract_from(page)
return {
"title" : extr("data-name='", "'"),
"slug" : extr("data-slug='", "'"),
"gid" : extr("data-gid='", "'").rpartition(".")[2],
"firm" : extr("data-firm-leaders-str='", "'"),
"location" : extr("<h2>", "<").strip(),
"type" : text.unescape(text.remove_html(extr(
'<div class="title">Type</div>', '<br'))),
"status" : text.remove_html(extr(
'<div class="title">STATUS</div>', '</')),
"year" : text.remove_html(extr(
'<div class="title">YEAR</div>', '</')),
"size" : text.remove_html(extr(
'<div class="title">SIZE</div>', '</')),
"description": text.unescape(extr(
'<span class="copy js-copy">', '</span></div>')
.replace("<br />", "\n")),
}

def images(self, page):
return [
(url, None)
for url in text.extract_iter(
page, "property='og:image:secure_url' content='", "?")
]

0 comments on commit 71523aa

Please sign in to comment.