当前位置: 首页>>代码示例>>Python>>正文


Python Video.fps_choice方法代码示例

本文整理汇总了Python中videos.models.Video.fps_choice方法的典型用法代码示例。如果您正苦于以下问题:Python Video.fps_choice方法的具体用法?Python Video.fps_choice怎么用?Python Video.fps_choice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在videos.models.Video的用法示例。


在下文中一共展示了Video.fps_choice方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: upload_videos

# 需要导入模块: from videos.models import Video [as 别名]
# 或者: from videos.models.Video import fps_choice [as 别名]
def upload_videos(request):
  try:
    uploaded_files = None
    if request.method == 'POST':
      author_email = request.POST['author']
      set_slug = request.POST['set_slug']
      fps_choice = request.POST['fps_choice']
      author = User.objects.filter(email=author_email)[0]
      for k in request.FILES.keys():
        uploaded_file = request.FILES[k]
        uploaded_file_content = uploaded_file.read()
        name, ext = os.path.splitext(uploaded_file.name)
        md5digest = hashlib.md5(uploaded_file_content).hexdigest()
        #if duplicate, overwrite the old
        try:
          uploaded_video = Video.objects.filter(md5=md5digest)[0]
          #TODO make other checkt to see if it is from the same user and the same filename
          # if not raise an error (duplicate md5 from 2 different sources)
        except IndexError:
          uploaded_video = Video()
        uploaded_video.filename = uploaded_file.name
        uploaded_video.size = uploaded_file.size
        uploaded_video.status = settings.DEFAULT_UPLOADED_VIDEO_STATUS
        uploaded_video.extension = ext[1:]
        uploaded_video.mimetype = mimetypes.types_map.get(ext)
        uploaded_video.md5 = md5digest
        delta = datetime.timedelta(days=-46)
        uploaded_video.created_at = datetime.datetime.now()+delta
        uploaded_video.updated_at = datetime.datetime.now()+delta
        uploaded_video.author = author
        uploaded_video.set_slug = set_slug
        uploaded_video.fps_choice = fps_choice
        if not os.path.exists(os.path.join(settings.TMP_VIDEO_ROOT, 'originals')):
          os.makedirs(os.path.join(settings.TMP_VIDEO_ROOT, 'originals'))
        if not os.path.exists(os.path.join(settings.TMP_VIDEO_ROOT, 'originals', set_slug)):
          os.makedirs(os.path.join(settings.TMP_VIDEO_ROOT, 'originals', set_slug))
        original_filename = "%s.%s" % (uploaded_video.md5, uploaded_video.extension)
        with open(os.path.join(settings.TMP_VIDEO_ROOT, 'originals', set_slug, original_filename), 'wb') as f:
          f.write(uploaded_file_content)
        del uploaded_file_content
        uploaded_video.save()
      return HttpResponse('')
    else:
      author_email = request.GET['author'] if 'author' in request.GET else ''
      set_slug = request.GET['set_slug'] if 'set_slug' in request.GET else ''
      fps_choice = request.GET['fps_choice'] if 'fps_choice' in request.GET else ''
    return render_to_response("videos/upload.html", locals())
  except:
    error_details = open(settings.DEBUG_ERROR_FILE, 'w')
    traceback.print_exc(file=error_details)
    error_details.close()
开发者ID:fczuardi-trash,项目名称:publicvideos,代码行数:53,代码来源:views.py


注:本文中的videos.models.Video.fps_choice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。