コード例 #1
0
    def from_video_activity(recent_video_activity):
        """ Build a SuggestedActivity dict from a RecentVideoActivity object. """
        activity = SuggestedActivity()
        activity.name = recent_video_activity.video_title
        activity.last_second_watched = recent_video_activity.last_second_watched
        activity.progress = points.video_progress_from_points(
                recent_video_activity.points_earned)

        # TODO(benkomalo): append a seektime so that the video starts at the
        # last position (minus some rewind constant or something...)
        activity.url = recent_video_activity.relative_url
        return activity
コード例 #2
0
 def get_key_and_progress(user_video):
     vid_id = UserVideo.video.get_value_for_datastore(user_video).id()
     points = video_progress_from_points(VideoPointCalculator(user_video))
     if points > 0.9:
         progress = "completed"
     elif points > 0.66:
         progress = "watched-most"
     elif points > 0.33:
         progress = "watched-some"
     else:
         progress = "started"
     return vid_id, progress