Skip to content

Instantly share code, notes, and snippets.

@tesu
Created July 26, 2019 03:17
Show Gist options
  • Save tesu/62c5c8c8ea0225615fd66e024664042c to your computer and use it in GitHub Desktop.
Save tesu/62c5c8c8ea0225615fd66e024664042c to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import re
import requests
import time
import subprocess
# cookie values
MEMBER_ID = ''
PASS_HASH = ''
# actual login values
LOGIN_USERNAME = ''
LOGIN_PASSWORD = ''
sleep = 1
page = 0
d = []
cookies = {
'ipb_member_id': MEMBER_ID,
'ipb_pass_hash': PASS_HASH,
's': 'f3fefd0f1b529496b358ce7912b0da55cd7809984dbd4ed66ecaab18891240516ab5653bb516af8a23dd53c5121d328c37e173530aa8ff8af889403f4869db2f'
}
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.87 Safari/537.36'
}
s = requests.Session()
r = s.get('https://exhentai.org/favorites.php', cookies=cookies, headers=headers)
while 'No unfiltered results' not in r.text:
if 'Your IP address has been temporarily banned' in r.text:
print(r.text.encode('ascii',errors='ignore').decode('ascii'), flush=True)
break
for l in re.finditer(r'https://exhentai\.org/g/(\d+)/([^/]+)/', r.text):
d.append([int(l.group(1)), l.group(2)])
page = page + 1
time.sleep(sleep)
r = s.get('https://exhentai.org/favorites.php?page='+str(page), cookies=cookies, headers=headers)
print(str(len(d)) + ' doujins fetched from favorites.', flush=True)
break
print('Stopped fetching doujins from favorites.', flush=True)
for first, second in d:
print('Fetching https://exhentai.org/g/{}/{}/'.format(first, second), flush=True)
subprocess.Popen(['gallery-dl', '-u', LOGIN_USERNAME, '-p', LOGIN_PASSWORD, 'https://exhentai.org/g/{}/{}/'.format(first, second)], shell=False)
time.sleep(sleep * 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment