This is more complex because materials now almost always use nodes.
Whether to use alpha is controlled by the Blend Method. As a replacement for reading material.use_transparency
, try using material.blend_method != 'OPAQUE'
.
To fetch the actual alpha value is harder since it now flows down an arbitrarily-complex node graph. But for simple graphs you can try this
from bpy_extras.node_shader_utils import PrincipledBSDFWrapper
ma_wrap = PrincipledBSDFWrapper(material)
ma_wrap.alpha # use this instead of material.alpha
ma_wrap.alpha_texture.image # use this if you want the alpha texture image
This wrapper is used by the OBJ/FBX exporter. See Import & Export of Node Shaders in the manual for more about it.