diff --git a/default_conf.py b/default_conf.py index a4056f9..d8df088 100644 --- a/default_conf.py +++ b/default_conf.py @@ -44,6 +44,7 @@ count_hit_only_visitors = False # Multimedia extensions (not accounted as downloaded files) multimedia_files = ['png', 'jpg', 'jpeg', 'gif', 'ico', 'svg', 'css', 'js'] +multimedia_files_re = [] # Default resources path (will be symlinked in DISPLAY_OUTPUT) resources_path = ['resources'] diff --git a/iwla.py b/iwla.py index 5b13bb4..6f26656 100755 --- a/iwla.py +++ b/iwla.py @@ -159,6 +159,9 @@ class IWLA(object): self.excluded_domain_name = [] for domain_name in conf.excluded_domain_name: self.excluded_domain_name += [re.compile(domain_name)] + self.multimedia_files_re = [] + for file_re in conf.multimedia_files_re: + self.multimedia_files_re += [re.compile(file_re)] self.plugins = [(conf.PRE_HOOK_DIRECTORY , conf.pre_analysis_hooks), (conf.POST_HOOK_DIRECTORY , conf.post_analysis_hooks), (conf.DISPLAY_HOOK_DIRECTORY , conf.display_hooks)] @@ -311,13 +314,18 @@ class IWLA(object): self.logger.debug("False") return False - def isMultimediaFile(self, request): - self.logger.debug("Is multimedia %s" % (request)) + def isMultimediaFile(self, uri): + self.logger.debug("Is multimedia %s" % (uri)) for e in conf.multimedia_files: - if request.lower().endswith(e): + if uri.lower().endswith(e): self.logger.debug("True") return True self.logger.debug("False") + + for file_re in self.multimedia_files_re: + if file_re.match(uri): + self.logger.debug("Is multimedia re True") + return True return False def isValidVisitor(self, hit):