From aa5a92f07ef53185cb6d715121f2034219c01beb Mon Sep 17 00:00:00 2001 From: Alhaziel01 Date: Tue, 22 Dec 2020 09:20:08 +0100 Subject: [PATCH] Fix Vcrypt (snip) --- lib/unshortenit.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/unshortenit.py b/lib/unshortenit.py index eebfd946..a4e421ea 100644 --- a/lib/unshortenit.py +++ b/lib/unshortenit.py @@ -545,17 +545,22 @@ class UnshortenIt(object): logger.info('Use Cloudscraper') uri = httptools.downloadpage(uri, timeout=self._timeout, headers=headers, follow_redirects=False, cf=True).headers['location'] if "snip." in uri: + new_uri = '' if 'out_generator' in uri: uri = re.findall('url=(.*)$', uri)[0] elif '/decode/' in uri: scheme, netloc, path, query, fragment = urlsplit(uri) splitted = path.split('/') splitted[1] = 'outlink' - new_uri = httptools.downloadpage(uri, follow_redirects=False, post={'url': splitted[2]}).headers['location'] + r = httptools.downloadpage(uri, follow_redirects=False, post={'url': splitted[2]}) + if 'location' in r.headers and r.headers['location']: + new_uri = r.headers['location'] + else: + r = httptools.downloadpage(scheme + '://' + netloc + "/".join(splitted) + query + fragment, follow_redirects=False, post={'url': splitted[2]}) + if 'location' in r.headers and r.headers['location']: + new_uri = r.headers['location'] if new_uri and new_uri != uri: uri = new_uri - else: - uri = httptools.downloadpage(scheme + '://' + netloc + "/".join(splitted) + query + fragment, follow_redirects=False, post={'url': splitted[2]}).headers['location'] # uri = decrypt(uri.split('/')[-1]) return uri, r.code if r else 200