Skip to content

Commit

Permalink
Merge pull request subzeroid#1734 from juanep97/master
Browse files Browse the repository at this point in the history
  • Loading branch information
subzeroid authored Jan 7, 2024
2 parents 9656547 + 22d1dc1 commit ca58ed0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions instagrapi/extractors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import html
import json
import re
import datetime
from copy import deepcopy

from .types import (
Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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)


Expand Down
2 changes: 2 additions & 0 deletions instagrapi/mixins/photo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions instagrapi/mixins/story.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
1 change: 1 addition & 0 deletions instagrapi/mixins/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions instagrapi/mixins/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ca58ed0

Please sign in to comment.