From ccdac0305fd4b23605535f673773a248fb7eddab Mon Sep 17 00:00:00 2001 From: Lars Lindqvist Date: Sun, 13 Aug 2017 23:37:53 +0200 Subject: [PATCH] Simplify profpic regex. The original method of substituting 2048x2048 for whatever resolution was given seemed somewhat convoluted. This accomplishes the same thing, except raising an exception if the given url is not on the right domain. --- instaloader.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/instaloader.py b/instaloader.py index 691c3fa..a7a4715 100755 --- a/instaloader.py +++ b/instaloader.py @@ -494,12 +494,7 @@ class Instaloader: if os.path.isfile(filename): self._log(filename + ' already exists') return None - match = re.search('http.*://.*instagram.*[^/]*\\.(com|net)/[^/]+/.', url) - if match is None: - raise ConnectionException("URL \'" + url + "\' could not be processed.") - index = len(match.group(0)) - 1 - offset = 8 if match.group(0)[-1:] == 's' else 0 - url = url[:index] + 's2048x2048' + ('/' if offset == 0 else str()) + url[index + offset:] + url = re.sub(r'/s([1-9][0-9]{2})x\1/', '/s2048x2048/', url) self._get_and_write_raw(url, filename) os.utime(filename, (datetime.now().timestamp(), date_object.timestamp())) self._log('') # log output of _get_and_write_raw() does not produce \n