I want to evaluate the integral \begin{equation} \int_{\theta_1}^{\theta_2} \sqrt{A-\frac{\alpha}{\cos^2\theta}-\frac{\beta}{\sin^2\theta}} d\theta, \end{equation} where $\theta_1$, $\theta_2$ are the roots of the expression inside the square root $A-\frac{\alpha}{\cos^2\theta}-\frac{\beta}{\sin^2\theta}$. (The problem comes from evaluating action-angle variables on a classical mechanics problem).
I have found a solution by making a complicated change of variables (see equation (18) on https://arxiv.org/pdf/1005.0464.pdf). What I was thinking is if it is possible to evaluate the integral by the residues method, doing the typical change of variables $z=e^{i\theta}$, $dz=izd\theta$ thus turning the expression \begin{equation} \sqrt{A-\frac{\alpha}{\cos^2\theta}-\frac{\beta}{\sin^2\theta}} d\theta = \sqrt{\frac{A}{z^2}-\frac{4\alpha}{(z^2+1)^2} +\frac{4\beta}{(z^2-1)^2}} dz \end{equation} and then applying the residues theorem.
The problem is that, since the first integral is considered over a certain angle (smaller than $2\pi$ since the integral would diverge) can I pick a special contour on which this method would make sense?