def InsertVideoEntry(self, video_entry, filename_or_handle,
                       youtube_username='default',
                       content_type='video/quicktime'):
    """Upload a new video to YouTube using the direct upload mechanism.

    Needs authentication.

    Args:
      video_entry: The YouTubeVideoEntry to upload.
      filename_or_handle: A file-like object or file name where the video
          will be read from.
      youtube_username: An optional string representing the username into whose
          account this video is to be uploaded to. Defaults to the currently
          authenticated user.
      content_type: An optional string representing internet media type
          (a.k.a. mime type) of the media object. Currently the YouTube API
          supports these types:
            o video/mpeg
            o video/quicktime
            o video/x-msvideo
            o video/mp4
            o video/x-flv

    Returns:
      The newly created YouTubeVideoEntry if successful.

    Raises:
      AssertionError: video_entry must be a gdata.youtube.VideoEntry instance.
      YouTubeError: An error occurred trying to read the video file provided.
      gdata.service.RequestError: An error occurred trying to upload the video
          to the API server.
    """

    # We need to perform a series of checks on the video_entry and on the
    # file that we plan to upload, such as checking whether we have a valid
    # video_entry and that the file is the correct type and readable, prior
    # to performing the actual POST request.

    try:
      assert(isinstance(video_entry, gdata.youtube.YouTubeVideoEntry))
    except __HOLE__:
      raise YouTubeError({'status':YOUTUBE_INVALID_ARGUMENT,
          'body':'`video_entry` must be a gdata.youtube.VideoEntry instance',
          'reason':'Found %s, not VideoEntry' % type(video_entry)
          })
    #majtype, mintype = content_type.split('/')
    #
    #try:
    #  assert(mintype in YOUTUBE_SUPPORTED_UPLOAD_TYPES)
    #except (ValueError, AssertionError):
    #  raise YouTubeError({'status':YOUTUBE_INVALID_CONTENT_TYPE,
    #      'body':'This is not a valid content type: %s' % content_type,
    #      'reason':'Accepted content types: %s' %
    #          ['video/%s' % (t) for t in YOUTUBE_SUPPORTED_UPLOAD_TYPES]})

    if (isinstance(filename_or_handle, (str, unicode)) 
        and os.path.exists(filename_or_handle)):
      mediasource = gdata.MediaSource()
      mediasource.setFile(filename_or_handle, content_type)
    elif hasattr(filename_or_handle, 'read'):
      import StringIO
      if hasattr(filename_or_handle, 'seek'):
        filename_or_handle.seek(0)
      file_handle = filename_or_handle
      name = 'video'
      if hasattr(filename_or_handle, 'name'):
        name = filename_or_handle.name
      mediasource = gdata.MediaSource(file_handle, content_type,
          content_length=file_handle.len, file_name=name)
    else:
      raise YouTubeError({'status':YOUTUBE_INVALID_ARGUMENT, 'body':
          '`filename_or_handle` must be a path name or a file-like object',
          'reason': ('Found %s, not path name or object '
                     'with a .read() method' % type(filename_or_handle))})
    upload_uri = '%s/%s/%s' % (YOUTUBE_UPLOAD_URI, youtube_username,
                              'uploads')
    self.additional_headers['Slug'] = mediasource.file_name

    # Using a nested try statement to retain Python 2.4 compatibility
    try:
      try:
        return self.Post(video_entry, uri=upload_uri, media_source=mediasource,
                         converter=gdata.youtube.YouTubeVideoEntryFromString)
      except gdata.service.RequestError, e:
        raise YouTubeError(e.args[0])
    finally:
      del(self.additional_headers['Slug'])
dataset/ETHPy150Open acil-bwh/SlicerCIP/Scripted/attic/PicasaSnap/gdata/youtube/service.py/YouTubeService.InsertVideoEntry