diff --git a/ArtNet/web/link_generator.py b/ArtNet/web/link_generator.py index b1d4b84..0d06a39 100644 --- a/ArtNet/web/link_generator.py +++ b/ArtNet/web/link_generator.py @@ -1,8 +1,9 @@ -import re +import logging import requests -import lxml.html from urllib.parse import urlparse +from PyQt5.QtWidgets import QMessageBox + DOMAIN_UNKNOWN = -1 @@ -43,6 +44,10 @@ class DomainIdentifier: class DomainLinkGenerator: + """ + Base class for classes that generate a link to the file on their domain given a sample of a filename pattern and + implement a method to scrape the available metadata. + """ def __init__(self, domain: DomainIdentifier): self.__identifier = domain @@ -167,7 +172,15 @@ class LinkGenerator: for g in self.__link_generators: if g.get_identifier() == domain or g.get_domain_name() == url_domain: try: - return g.scrape_tags(url=url, headers=headers, file_name=file_name) + try: + return g.scrape_tags(url=url, headers=headers, file_name=file_name) + except requests.exceptions.ConnectionError as e: + logging.warning(f"Encountered connection error when trying to scrape tags from \"{url}\".\n" + f"See also:\n{e}") + QMessageBox.warning(None, "Connection Error", + f"The http connection to \"{url}\" ran into an error. Check your network.\n" + f"\n{e}") + break except NotImplementedError: pass return None