Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix favorites next button detection #73

Open
wants to merge 1 commit into
base: python
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions furaffinity-dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
# Create output directory if it doesn't exist
if args.output != '.':
os.makedirs(args.output, exist_ok=True)

if args.metadir == None:
args.metadir = args.output
else:
Expand Down Expand Up @@ -205,25 +205,20 @@ def download(path):
download(img.find('a').attrs.get('href'))
sleep(args.interval)

if args.category != "favorites":
next_button = s.find('button', class_='button standard', string="Next")
if next_button is None or next_button.parent is None:
print('Unable to find next button')
break
next_button = s.find('button', class_='button standard', string="Next")
if next_button is None or next_button.parent is None:
print('Unable to find next button')
break

if args.category != "favorites":
page_num = next_button.parent.attrs['action'].split('/')[-2]

print('Downloading page', page_num, page_url)
else:
next_button = s.find('a', class_='button mobile-button right', string="Next")
if next_button is None:
print('Unable to find next button')
break

# unlike galleries that are sequentially numbered, favorites use a different scheme.
# the "page_num" is instead: [set of numbers]/next (the trailing /next is required)
next_page_link = next_button.attrs['href']

next_page_link = next_button.parent.attrs['action']
next_fav_num = re.search(r'\/\d+', next_page_link)

if next_fav_num == None:
Expand Down