Opening a clip with python "TypeError"

I am trying to open a clip in blender via the python api and load it into a movieclip input node without the use of user input. The only operation i could find was the “bpy.ops.clip.open” to open a clip, which is the only type that the node accepts. Whenever i type only the directory in the line:

bpy.ops.clip.open(directory='/home/roger/Desktop/DSC_0001.MOV' , files=[])

it raises the error:


Error: No files selected to be opened


Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
  File "/home/roger/Desktop/blender-2.69-linux-glibc211-x86_64/2.69/scripts/modules/bpy/ops.py", line 188, in __call__
    ret = op_call(self.idname_py(), None, kw)
RuntimeError: Error: No files selected to be opened

and when i try to define the file:

bpy.ops.clip.open(directory='/home/roger/Desktop/' , files=['DSC_0001.MOV'])

it raises this error:


Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
  File "/home/roger/Desktop/blender-2.69-linux-glibc211-x86_64/2.69/scripts/modules/bpy/ops.py", line 188, in __call__
    ret = op_call(self.idname_py(), None, kw)
TypeError: Converting py args to operator properties:  CLIP_OT_open.files expected a each sequence member to be a dict for an RNA collection, not _io.TextIOWrapper

I have tried looking online for code snippets and examples to use this operator but i have not found anything other than the single documentation page.

The files collection is a PropertyGroup of OperatorFileListElement type, which has a name property.
To emulate this in your script try a list of dictionaries with the required fields.


bpy.ops.clip.open(directory='/home/roger/Desktop/' , files=[{"name":"DSC_0001.MOV"}])

Thanks, that worked perfectly!