|
2 | 2 | import downloader |
3 | 3 | from error_printer import print_error |
4 | 4 | from translator import tr_ |
5 | | -from utils import Downloader, Soup, get_print, lazy, Session, try_n, File, clean_title, check_alive, File, get_ext, get_max_range |
| 5 | +from utils import Downloader, Soup, get_print, lazy, Session, try_n, File, clean_title, check_alive, get_ext, get_max_range |
6 | 6 | import dateutil.parser |
7 | 7 | import utils |
8 | 8 |
|
@@ -46,6 +46,14 @@ def init(self): |
46 | 46 | self.url = self.url_main |
47 | 47 | self.print_(self.url) |
48 | 48 |
|
| 49 | + @classmethod |
| 50 | + def fix_url(cls, url): #6516 |
| 51 | + if '.artstation.com' in url: |
| 52 | + sub = url.split('.artstation.com')[0].split('/')[-1] |
| 53 | + if sub != 'www': |
| 54 | + url = f'https://www.artstation.com/{sub}' |
| 55 | + return url |
| 56 | + |
49 | 57 | @lazy |
50 | 58 | def _id(self): |
51 | 59 | _id = get_id(self.url, self.cw) |
@@ -86,41 +94,25 @@ def get_imgs(id_, title, session, cw=None): |
86 | 94 | url = f'https://www.artstation.com/users/{id_}/quick.json' |
87 | 95 | j = downloader.read_json(url, referer, session=session) |
88 | 96 | uid = j['id'] |
89 | | - aids = [a['id'] for a in j['albums_with_community_projects']] |
90 | | - print_(f'albums: {aids}') |
91 | 97 |
|
92 | 98 | datas = [] |
93 | 99 | ids = set() |
94 | | - for aid in aids: |
95 | | - p = 1 |
96 | | - while p < 1000: |
97 | | - check_alive(cw) |
98 | | - url = f'https://www.artstation.com/users/{id_}/projects.json?album_id={aid}&page={p}&user_id={uid}' |
99 | | - print(url) |
100 | | - _e = None |
101 | | - for i in range(4): |
102 | | - try: |
103 | | - j = downloader.read_json(url, referer, session=session) |
104 | | - break |
105 | | - except Exception as e: |
106 | | - _e = e |
107 | | - print(e) |
108 | | - else: |
109 | | - if _e is not None: |
110 | | - raise _e |
111 | | - |
112 | | - data = j['data'] |
113 | | - if not data: |
114 | | - break |
115 | | - for d in data: |
116 | | - if d['id'] not in ids: |
117 | | - ids.add(d['id']) |
118 | | - datas.append(d) |
119 | | - if cw: |
120 | | - cw.setTitle(f'{tr_("페이지 읽는 중...")} {title} - {len(datas)}') |
121 | | - else: |
122 | | - print(len(datas)) |
123 | | - p += 1 |
| 100 | + for p in range(1, 1000): |
| 101 | + check_alive(cw) |
| 102 | + url = f'https://www.artstation.com/users/{id_}/projects.json??user_id={uid}&page={p}' #6516 |
| 103 | + j = try_n(4)(downloader.read_json)(url, referer, session=session) |
| 104 | + |
| 105 | + data = j['data'] |
| 106 | + if not data: |
| 107 | + break |
| 108 | + for d in data: |
| 109 | + if d['id'] not in ids: |
| 110 | + ids.add(d['id']) |
| 111 | + datas.append(d) |
| 112 | + if cw: |
| 113 | + cw.setTitle(f'{tr_("페이지 읽는 중...")} {title} - {len(datas)}') |
| 114 | + else: |
| 115 | + print(len(datas)) |
124 | 116 |
|
125 | 117 | datas = sorted(datas, key=lambda data: int(data['id']), reverse=True) |
126 | 118 |
|
@@ -234,7 +226,7 @@ def get_imgs_page(id_art, session, date=None, cw=None, names=None): |
234 | 226 |
|
235 | 227 | d = { |
236 | 228 | 'date': date, |
237 | | - 'name': name, |
| 229 | + 'name': clean_title(name), |
238 | 230 | 'page': page, |
239 | 231 | } |
240 | 232 | filename = utils.format('artstation', d, get_ext(url)) |
|
0 commit comments