diff --git a/instagrapi/extractors.py b/instagrapi/extractors.py index 05f76b2e..cc127f23 100644 --- a/instagrapi/extractors.py +++ b/instagrapi/extractors.py @@ -1,6 +1,7 @@ import html import json import re +import datetime from copy import deepcopy from .types import ( @@ -275,6 +276,7 @@ def extract_direct_thread(data): if "inviter" in data: data["inviter"] = extract_user_short(data["inviter"]) data["left_users"] = data.get("left_users", []) + data["last_activity_at"] = datetime.datetime.fromtimestamp(data["last_activity_at"] // 1_000_000) return DirectThread(**data) @@ -330,6 +332,9 @@ def extract_direct_message(data): if xma_media_share: data["xma_share"] = extract_media_v1_xma(xma_media_share[0]) + data['timestamp'] = datetime.datetime.fromtimestamp(data['timestamp'] // 1_000_000) + data['user_id'] = str(data['user_id']) + return DirectMessage(**data) diff --git a/instagrapi/mixins/photo.py b/instagrapi/mixins/photo.py index 7c4b93fd..73f297d6 100644 --- a/instagrapi/mixins/photo.py +++ b/instagrapi/mixins/photo.py @@ -87,6 +87,7 @@ def photo_download_by_url( Path Path for the file downloaded """ + url = str(url) fname = urlparse(url).path.rsplit("/", 1)[1] filename = "%s.%s" % (filename, fname.rsplit(".", 1)[1]) if filename else fname path = Path(folder) / filename @@ -110,6 +111,7 @@ def photo_download_by_url_origin(self, url: str) -> bytes: ------- bytes """ + url = str(url) response = requests.get(url, stream=True, timeout=self.request_timeout) response.raise_for_status() response.raw.decode_content = True diff --git a/instagrapi/mixins/story.py b/instagrapi/mixins/story.py index 65daf199..eb120f8d 100644 --- a/instagrapi/mixins/story.py +++ b/instagrapi/mixins/story.py @@ -293,6 +293,7 @@ def story_download_by_url( Path Path for the file downloaded """ + url = str(url) fname = urlparse(url).path.rsplit("/", 1)[1].strip() assert fname, ( """The URL must contain the path to the file (mp4 or jpg).\n""" diff --git a/instagrapi/mixins/track.py b/instagrapi/mixins/track.py index cdae8cae..57ede148 100644 --- a/instagrapi/mixins/track.py +++ b/instagrapi/mixins/track.py @@ -33,6 +33,7 @@ def track_download_by_url( Path Path for the file downloaded """ + url = str(url) fname = urlparse(url).path.rsplit("/", 1)[1].strip() assert fname, """The URL must contain the path to the file (m4a or mp3).""" filename = "%s.%s" % (filename, fname.rsplit(".", 1)[1]) if filename else fname diff --git a/instagrapi/mixins/video.py b/instagrapi/mixins/video.py index 2e0de707..15ed8356 100644 --- a/instagrapi/mixins/video.py +++ b/instagrapi/mixins/video.py @@ -80,6 +80,7 @@ def video_download_by_url( Path Path for the file downloaded """ + url = str(url) fname = urlparse(url).path.rsplit("/", 1)[1] filename = "%s.%s" % (filename, fname.rsplit(".", 1)[1]) if filename else fname path = Path(folder) / filename