Poll Error -Finding the Right Context (2.8VSE) The script below is meant to add an effect like "Cross" to the active strip in the VSE..However,after adding 2 colorstrips ,selecting them (alternatively and  both together)and  on running the script,it gives the following error -

RuntimeError: Operator bpy.ops.sequencer.effect_strip_add.poll() failed, context is incorrectError: 


On using the Bruteforce method here,to override the context the terminal throws new error's. TypeError: bpy_struct: item.attr = val: enum "TIMELINE" not found in (, 'VIEW_3D', 'IMAGE_EDITOR', 'NODE_EDITOR', 'SEQUENCE_EDITOR', 'CLIP_EDITOR', 'DOPESHEET_EDITOR', 'GRAPH_EDITOR', 'NLA_EDITOR', 'TEXT_EDITOR', 'CONSOLE', 'INFO', 'OUTLINER', 'PROPERTIES', 'FILE_BROWSER', 'PREFERENCES')

However ,on running the following command ,the 'TIMELINE' window opens ,as expected -

bpy.context.area.ui_type ="TIMELINE"


Please let me know, how to overide this Poll error .

import bpy

#check poll data
#all the area types except 'EMPTY' from blender.org/api/blender_python_api_current/bpy.types.Area.html#bpy.types.Area.type
types = {'VIEW_3D', 'TIMELINE', 'GRAPH_EDITOR', 'DOPESHEET_EDITOR', 'NLA_EDITOR', 'IMAGE_EDITOR', 'SEQUENCE_EDITOR', 'CLIP_EDITOR', 'TEXT_EDITOR', 'NODE_EDITOR', 'LOGIC_EDITOR', 'PROPERTIES', 'OUTLINER', 'USER_PREFERENCES', 'INFO', 'FILE_BROWSER', 'CONSOLE'}
#save the current area
area = bpy.context.area.type

#try each type
for type in types:
    #set the context
    bpy.context.area.type = type

    #print out context where operator works (change the ops below to check a different operator)
    if bpy.ops.sequencer.duplicate.poll():
        print(type)

#leave the context where it was
bpy.context.area.type = area


#Script to apply a Cross effect at the end of the selected strip
activeStrip = bpy.context.scene.sequence_editor.active_strip

aEnd =  activeStrip.frame_final_end

bpy.ops.sequencer.effect_strip_add(frame_start= aEnd, frame_end=aEnd +10, channel=1, replace_sel=True, overlap=False, type='CROSS', color=(0.0, 0.0, 0.0))
Use API Methods



Similarly to https://blender.stackexchange.com/a/101129/15543 ditch the operator completely here and use API methods.  Sequences.new_effect()

import bpy

context = bpy.context
scene = context.scene
sed = scene.sequence_editor
sequences = sed.sequences
active_strip = sed.active_strip
if active_strip:

    color_strip = sequences.new_effect("Color", 'COLOR', 
           active_strip.channel - 1,
           frame_start=active_strip.frame_start, 
           frame_end=active_strip.frame_final_end)

    color_strip.color = (1, 0, 0)

    cross_strip = sequences.new_effect("Cross", 'CROSS', 
           active_strip.channel + 1,
           frame_start=active_strip.frame_start, 
           frame_end=active_strip.frame_final_end, 
           seq1=active_strip,
           seq2=color_strip)
    cross_strip.blend_type = 'CROSS'
    cross_strip.blend_alpha = 0.5