Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.

Commit 77270e1

Browse files
committed
Expose content URL on file messages
1 parent 364aa56 commit 77270e1

File tree

1 file changed

+15
-24
lines changed

1 file changed

+15
-24
lines changed

skpy/msg.py

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,8 @@ class SkypeFileMsg(SkypeMsg):
535535
Attributes:
536536
file (:class:`File`):
537537
File object embedded in the message.
538+
urlContent (str):
539+
URL to retrieve the raw file content.
538540
fileContent (bytes):
539541
Raw content of the file.
540542
"""
@@ -573,6 +575,8 @@ def urlAsm(self):
573575

574576
attrs = SkypeMsg.attrs + ("file",)
575577

578+
contentPath = "original"
579+
576580
@classmethod
577581
def contentToFields(cls, content):
578582
fields = super(SkypeFileMsg, cls).contentToFields(content)
@@ -587,13 +591,18 @@ def contentToFields(cls, content):
587591
fields["file"] = SkypeFileMsg.File(**fileFields)
588592
return fields
589593

594+
@property
595+
def urlContent(self):
596+
return "{0}/views/{1}".format(self.file.urlAsm, self.contentPath) if self.file else None
597+
590598
@property
591599
@SkypeUtils.cacheResult
592600
def fileContent(self):
593-
if not self.file:
601+
if self.file:
602+
return self.skype.conn("GET", self.urlContent,
603+
auth=SkypeConnection.Auth.Authorize).content
604+
else:
594605
return None
595-
return self.skype.conn("GET", "{0}/views/original".format(self.file.urlAsm),
596-
auth=SkypeConnection.Auth.Authorize).content
597606

598607
@property
599608
def html(self):
@@ -614,13 +623,7 @@ class SkypeImageMsg(SkypeFileMsg):
614623
A message containing a picture shared in a conversation.
615624
"""
616625

617-
@property
618-
@SkypeUtils.cacheResult
619-
def fileContent(self):
620-
if not self.file:
621-
return None
622-
return self.skype.conn("GET", "{0}/views/imgpsh_fullsize".format(self.file.urlAsm),
623-
auth=SkypeConnection.Auth.Authorize).content
626+
contentPath = "imgpsh_fullsize"
624627

625628
@property
626629
def html(self):
@@ -639,13 +642,7 @@ class SkypeAudioMsg(SkypeFileMsg):
639642
A message containing audio shared in a conversation.
640643
"""
641644

642-
@property
643-
@SkypeUtils.cacheResult
644-
def fileContent(self):
645-
if not self.file:
646-
return None
647-
return self.skype.conn("GET", "{0}/views/audio".format(self.file.urlAsm),
648-
auth=SkypeConnection.Auth.Authorize).content
645+
contentPath = "audio"
649646

650647
@property
651648
def html(self):
@@ -663,13 +660,7 @@ class SkypeVideoMsg(SkypeFileMsg):
663660
A message containing a video shared in a conversation.
664661
"""
665662

666-
@property
667-
@SkypeUtils.cacheResult
668-
def fileContent(self):
669-
if not self.file:
670-
return None
671-
return self.skype.conn("GET", "{0}/views/video".format(self.file.urlAsm),
672-
auth=SkypeConnection.Auth.Authorize).content
663+
contentPath = "video"
673664

674665
@property
675666
def html(self):

0 commit comments

Comments
 (0)