本文整理汇总了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()