Don't fail on 502 errors

This commit is contained in:
7x11x13
2021-05-06 06:16:30 -04:00
parent 825dd367a0
commit 06592b8932
2 changed files with 16 additions and 13 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ from configparser import ConfigParser
logging.basicConfig(level=os.environ.get('LOGLEVEL', 'INFO'))
logger = logging.getLogger(__name__)
__version__ = 'v0.0.2'
__version__ = 'v0.0.3'
if 'XDG_CONFIG_HOME' in os.environ:
config_dir = os.path.join(os.environ['XDG_CONFIG_HOME'], 'free-bandcamp-downloader')
+15 -12
View File
@@ -249,18 +249,21 @@ def main():
logger.info(f'Waiting for {expected_emails} emails from bandcamp')
while expected_emails > 0:
time.sleep(10)
for email in mail_session.get_email_list():
if email.guid not in checked_ids:
checked_ids.add(email.guid)
if email.sender == 'noreply@bandcamp.com' and 'download' in email.subject:
logger.info(f'Received email "{email.subject}"')
email = mail_session.get_email(email.guid)
match = link_regex.search(email.body)
if match:
download_url = match.group('url')
driver.get(download_url)
download_file()
expected_emails -= 1
try:
for email in mail_session.get_email_list():
if email.guid not in checked_ids:
checked_ids.add(email.guid)
if email.sender == 'noreply@bandcamp.com' and 'download' in email.subject:
logger.info(f'Received email "{email.subject}"')
email = mail_session.get_email(email.guid)
match = link_regex.search(email.body)
if match:
download_url = match.group('url')
driver.get(download_url)
download_file()
expected_emails -= 1
except Exception as e:
logger.error(e)
if __name__ == '__main__':
main()