Skip to content

Commit

Permalink
[feat] download 4k images
Browse files Browse the repository at this point in the history
  • Loading branch information
findix committed May 12, 2022
1 parent d7fda3d commit c919b3b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/ArtStationDownloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Copyright 2018 Sean Feng([email protected])
"""

__version__ = "0.2.0"
__version__ = "0.2.1"
# $Source$

import argparse
Expand Down
27 changes: 11 additions & 16 deletions src/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def __init__(self, log_print=None):
self.session.proxies.update(proxys)

def download_file(self, url, file_path, file_name):
url = url.replace("/large/", "/4k/")
file_full_path = os.path.join(file_path, file_name)
if os.path.exists(file_full_path):
self.log("[Exist][image][{}]".format(file_full_path))
Expand Down Expand Up @@ -114,11 +115,7 @@ def get_projects(self, username):
page = 0
while True:
page += 1
url = (
"https://{}.artstation.com/rss?page={}".format(
username, page
)
)
url = "https://{}.artstation.com/rss?page={}".format(username, page)
r = self.session.get(url)
if not r.ok:
err = "[Error] [{} {}] ".format(r.status_code, r.reason)
Expand All @@ -129,26 +126,24 @@ def get_projects(self, username):
else:
self.log(err + "Unknown error")
break
j = BeautifulSoup(r.text, "lxml-xml").rss.channel
channel = BeautifulSoup(r.text, "lxml-xml").rss.channel
links = channel.select("item > link")
if len(links) == 0:
break
if page == 1:
self.log("\n==========[{}] BEGIN==========".format(username))
data_fragment = j.select("item > link")
if len(data_fragment) == 0:
break
data += data_fragment
self.log(
"\n==========Get page {}==========".format(
page
)
)
data += links
self.log("\n==========Get page {}==========".format(page))
return data

def download_by_username(self, username):
data = self.get_projects(username)
if len(data) != 0:
future_list = []
for project in data:
future = self.executor.submit(self.download_project, project.string.split("/")[-1])
future = self.executor.submit(
self.download_project, project.string.split("/")[-1]
)
future_list.append(future)
futures.wait(future_list)

Expand Down

0 comments on commit c919b3b

Please sign in to comment.