當前位置: 首頁>>代碼示例>>Python>>正文


Python Photo.is_video方法代碼示例

本文整理匯總了Python中photos.models.Photo.is_video方法的典型用法代碼示例。如果您正苦於以下問題:Python Photo.is_video方法的具體用法?Python Photo.is_video怎麽用?Python Photo.is_video使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在photos.models.Photo的用法示例。


在下文中一共展示了Photo.is_video方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_album_photos_payload

# 需要導入模塊: from photos.models import Photo [as 別名]
# 或者: from photos.models.Photo import is_video [as 別名]

#.........這裏部分代碼省略.........
        row_photo_date_created,
        row_video_status,
        row_video_storage_id,
        row_video_duration,
        row_photo_global_glance_score,
        row_photo_my_glance_score,
        row_author_id,
        row_author_nickname,
        row_author_last_online,
        row_author_avatar_file,
        row_author_user_glance_score) = row

        if row_photo_my_glance_score:
            my_glance_score_delta = row_photo_my_glance_score
        else:
            my_glance_score_delta = 0

        # Manually create a Photo instance so we can use it's helper methods
        photo = Photo(photo_id=row_photo_id, subdomain=row_photo_subdomain, media_type=row_media_type)

        photos[row_photo_id] = {
            'photo_id': row_photo_id,
            'youtube_id': row_youtube_id,
            'media_type': photo.get_media_type_display(),
            'client_upload_id': row_client_upload_id,
            'photo_url': photo.get_photo_url(),
            'date_created': row_photo_date_created,
            'author': {
                'id': row_author_id,
                'nickname': row_author_nickname,
                'last_online': row_author_last_online,
                'avatar_url': avatar_url_from_avatar_file_data(row_author_avatar_file),
                'user_glance_score': row_author_user_glance_score
            },
            'comments': [], # Will be filled in later
            'user_tags': [], # Not used yet, will be left empty
            'glances': [], # Deprecated, will be left empty
            'global_glance_score': row_photo_global_glance_score,
            'my_glance_score_delta': my_glance_score_delta
        }
        if photo.is_video():
            # Manually create a Video instance so we can use it's helper methods
            video = Video(status=row_video_status)
            photos[row_photo_id]['video_status'] = video.get_status_display()
            photos[row_photo_id]['video_url'] = Video.get_video_url(row_video_storage_id)
            photos[row_photo_id]['video_thumbnail_url'] = Video.get_video_thumbnail_url(row_video_storage_id)
            photos[row_photo_id]['video_duration'] = row_video_duration

    cursor = connection.cursor()
    cursor.execute(
        """
        SELECT photos_photo.photo_id,
               phone_auth_user.id,
               phone_auth_user.nickname,
               phone_auth_user.last_online,
               phone_auth_user.avatar_file,
               phone_auth_user.user_glance_score,
               photos_photocomment.date_created,
               photos_photocomment.client_msg_id,
               photos_photocomment.comment_text
        FROM photos_photocomment
        LEFT OUTER JOIN photos_photo
            ON photos_photocomment.photo_id=photos_photo.photo_id
        LEFT OUTER JOIN phone_auth_user
            ON photos_photocomment.author_id=phone_auth_user.id
        WHERE album_id=%s
        ORDER BY photos_photocomment.date_created;
        """,
        [album_id])

    for row in cursor.fetchall():
        (row_photo_id,
        row_photo_author_user_id,
        row_photo_author_user_nickname,
        row_photo_author_user_last_online,
        row_photo_author_user_avatar_file,
        row_photo_author_user_user_glance_score,
        row_photocomment_date_created,
        row_photocomment_client_msg_id,
        row_photocomment_comment_text) = row

        photo_id = row_photo_id
        try:
            photos[photo_id]['comments'].append({
                'author': {
                    'id': row_photo_author_user_id,
                    'nickname': row_photo_author_user_nickname,
                    'last_online': row_photo_author_user_last_online,
                    'avatar_url': avatar_url_from_avatar_file_data(row_photo_author_user_avatar_file),
                    'user_glance_score': row_photo_author_user_user_glance_score
                },
                'date_created': row_photocomment_date_created,
                'client_msg_id': row_photocomment_client_msg_id,
                'comment': row_photocomment_comment_text,
            })
        except KeyError:
            # Ignore comments on photos that we are not interested in
            pass

    return photos.values()
開發者ID:shotvibe,項目名稱:shotvibe-web,代碼行數:104,代碼來源:optimized_views.py


注:本文中的photos.models.Photo.is_video方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。