@@ -535,6 +535,8 @@ class SkypeFileMsg(SkypeMsg):
535
535
Attributes:
536
536
file (:class:`File`):
537
537
File object embedded in the message.
538
+ urlContent (str):
539
+ URL to retrieve the raw file content.
538
540
fileContent (bytes):
539
541
Raw content of the file.
540
542
"""
@@ -573,6 +575,8 @@ def urlAsm(self):
573
575
574
576
attrs = SkypeMsg .attrs + ("file" ,)
575
577
578
+ contentPath = "original"
579
+
576
580
@classmethod
577
581
def contentToFields (cls , content ):
578
582
fields = super (SkypeFileMsg , cls ).contentToFields (content )
@@ -587,13 +591,18 @@ def contentToFields(cls, content):
587
591
fields ["file" ] = SkypeFileMsg .File (** fileFields )
588
592
return fields
589
593
594
+ @property
595
+ def urlContent (self ):
596
+ return "{0}/views/{1}" .format (self .file .urlAsm , self .contentPath ) if self .file else None
597
+
590
598
@property
591
599
@SkypeUtils .cacheResult
592
600
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 :
594
605
return None
595
- return self .skype .conn ("GET" , "{0}/views/original" .format (self .file .urlAsm ),
596
- auth = SkypeConnection .Auth .Authorize ).content
597
606
598
607
@property
599
608
def html (self ):
@@ -614,13 +623,7 @@ class SkypeImageMsg(SkypeFileMsg):
614
623
A message containing a picture shared in a conversation.
615
624
"""
616
625
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"
624
627
625
628
@property
626
629
def html (self ):
@@ -639,13 +642,7 @@ class SkypeAudioMsg(SkypeFileMsg):
639
642
A message containing audio shared in a conversation.
640
643
"""
641
644
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"
649
646
650
647
@property
651
648
def html (self ):
@@ -663,13 +660,7 @@ class SkypeVideoMsg(SkypeFileMsg):
663
660
A message containing a video shared in a conversation.
664
661
"""
665
662
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"
673
664
674
665
@property
675
666
def html (self ):
0 commit comments