Don't fail on 502 errors
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user