mirror of
https://github.com/instaloader/instaloader.git
synced 2024-08-18 12:49:38 +02:00
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.
This commit is contained in:
parent
4ce6826f82
commit
ccdac0305f
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user