コード例 #1
0
ファイル: UserProfilePhotos.py プロジェクト: jacopodl/TbotPy
    def build_from_json(juph):
        """

        :param juph: A dictionary that contains JSON-parsed object
        :type juph: dict
        :rtype: UserProfilePhotos
        """
        phus = []
        phu = []
        for photos in juph['photos']:
            for photo in photos:
                phu.append(PhotoSize.build_from_json(photo))
            phus.append(tuple(phu))
        return UserProfilePhotos(juph['total_count'], phus)
コード例 #2
0
ファイル: Sticker.py プロジェクト: jacopodl/TbotPy
    def build_from_json(jsticker):
        """

        :param jsticker: A dictionary that contains JSON-parsed object
        :type jsticker: dict
        :rtype: Sticker
        """
        thumb = None
        file_size = 0
        if 'thumb' in jsticker.keys():
            thumb = PhotoSize.build_from_json(jsticker['thumb'])
        if 'file_size' in jsticker.keys():
            file_size = int(jsticker['file_size'])
        return Sticker(jsticker['file_id'], int(jsticker['width']), int(jsticker['height']), thumb, file_size)
コード例 #3
0
ファイル: Video.py プロジェクト: jacopodl/TbotPy
    def build_from_json(jvideo):
        """

        :param jvideo: A dictionary that contains JSON-parsed object
        :type jvideo: dict
        :rtype: Video
        """
        thumb = None
        mime_type = ""
        file_size = 0
        if 'thumb' in jvideo.keys():
            thumb = PhotoSize.build_from_json(jvideo['thumb'])
        if 'mime_type' in jvideo.keys():
            mime_type = jvideo['mime_type']
        if 'file_size' in jvideo.keys():
            file_size = int(jvideo['file_size'])
        return Video(jvideo['file_id'], int(jvideo['width']), int(jvideo['height']), int(jvideo['duration']), thumb,
                     mime_type, file_size)
コード例 #4
0
ファイル: Document.py プロジェクト: jacopodl/TbotPy
    def build_from_json(jdocument):
        """

        :param jdocument: A dictionary that contains JSON-parsed object
        :type jdocument: dict
        :rtype: Document
        """
        thumb = None
        file_name = ""
        mime_type = ""
        file_size = 0
        if 'thumb' in jdocument.keys():
            thumb = PhotoSize.build_from_json(jdocument['thumb'])
        if 'file_name' in jdocument.keys():
            file_name = jdocument['file_name']
        if 'mime_type' in jdocument.keys():
            mime_type = jdocument['mime_type']
        if 'file_size' in jdocument.keys():
            file_size = int(jdocument['file_size'])
        return Document(jdocument['file_id'], thumb, file_name, mime_type, file_size)
コード例 #5
0
ファイル: Message.py プロジェクト: jacopodl/TbotPy
 def __extract_ph_array(jph: list):
     pharray = []
     for photo in jph:
         pharray.append(PhotoSize.build_from_json(photo))
     return tuple(pharray)