Skip to content

Commit 0433927

Browse files
committed
fantia: sort by id to workaround pinned post(s)
1 parent 9b48413 commit 0433927

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

scraper_fantia.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ def download_all(self):
9191
if f.is_file() and (m := re.match(r'^(\d+)\b', f.name)):
9292
existing_ids.append(m.group(1))
9393
existing_ids = list(dict.fromkeys(existing_ids))
94+
existing_ids = set(map(int, existing_ids))
95+
9496
print(f'{len(existing_ids)} ID(s) have already been downloaded.')
9597

9698
def fetch_all():
@@ -134,7 +136,7 @@ def fetch_gallery_page(self, page):
134136
r = self.fetch(url)
135137
r.encoding = 'utf-8'
136138
html = r.text
137-
return re.findall(r'\/posts\/(?P<id>[0-9]{1,8})"', html)
139+
return sorted(map(int, re.findall(r'\/posts\/(?P<id>[0-9]{1,8})"', html)), reverse=True)
138140

139141
def update_fanclub_info(self, d):
140142
self.fanclub_info = d

0 commit comments

Comments
 (0)