diff --git a/instaloader/__init__.py b/instaloader/__init__.py index 7ed0c85..0fba0e2 100644 --- a/instaloader/__init__.py +++ b/instaloader/__init__.py @@ -1,7 +1,7 @@ """Download pictures (or videos) along with their captions and other metadata from Instagram.""" -__version__ = '4.10' +__version__ = '4.10.1' try: diff --git a/instaloader/instaloadercontext.py b/instaloader/instaloadercontext.py index 7659af3..ffb326d 100644 --- a/instaloader/instaloadercontext.py +++ b/instaloader/instaloadercontext.py @@ -405,20 +405,13 @@ class InstaloaderContext: raise ConnectionException("HTTP error code {}.".format(resp.status_code)) is_html_query = not is_graphql_query and not "__a" in params and host == "www.instagram.com" if is_html_query: - match = re.search(r'window\._sharedData = (.*);', resp.text) + # Extract JSON from HTML response + match = re.search('(?<={"raw":").*?(?', - resp.text) - if match is not None: - post_or_profile_page[0]['graphql'] = json.loads(match.group(1))['graphql'] + raise QueryReturnedNotFoundException("Could not find JSON data in html response.") + # Unescape escaped JSON string + unescaped_string = match.group(0).encode("utf-8").decode("unicode_escape") + resp_json = json.loads(unescaped_string) return resp_json else: resp_json = resp.json() diff --git a/instaloader/lateststamps.py b/instaloader/lateststamps.py index 5846948..02959ba 100644 --- a/instaloader/lateststamps.py +++ b/instaloader/lateststamps.py @@ -27,7 +27,8 @@ class LatestStamps: self.data.read(latest_stamps_file) def _save(self): - makedirs(dirname(self.file), exist_ok=True) + if dn := dirname(self.file): + makedirs(dn, exist_ok=True) with open(self.file, 'w') as f: self.data.write(f)