An exercise I'm doing asks me to verify the following identity: $$ \int_0^{\infty}\frac{x^a}{\left(x+i\right)^2\left(x-i\right)^2}dx=\frac{\left(1-a\right)\pi}{4\cos\left(\frac{a\pi}{2}\right)},\quad -1<a<3. $$ I've calculated the value of the integral on the left side to be $$ I=\frac{2\pi i\sum\underset{z\to \pm i}{\text{Res}}\left[\dfrac{x^a}{\left(x+i\right)^2\left(x-i\right)^2}\right]}{1-e^{2a\pi I}}, $$ but I can't evaluate the residues in order to prove that the two sides match and solve the exercise. Here it is what I've tried.
Residues: these are precisely
$$2\pi i\lim _{z\rightarrow -i}\left(\frac{d}{dz}\frac{z^ae^{2\pi ia}}{\left(z-i\right)^2}\right)\quad\text{ and }\quad2\pi i\lim_{z\rightarrow i}\left(\frac{d}{dz}\frac{z^a}{\left(z+i\right)^2}\right)$$ Then the upper side of the fraction above evaluates as $$ \begin{split}2\pi i\sum \text{Res}\left(f\left(z\right){,}\pm i\right) &=2\pi i\left(\frac{1}{4}i^{a-1}\left(1-a\right)+\left(-\frac{1}{4}\left(-i\right)^{a-1}\left(1-a\right)e^{2\pi ia}\right)\right)\\ & =\left(\frac{\pi}{2}\left(1-a\right)\right)\left(e^{\frac{i\pi a}{2}}-e^{\frac{3i\pi a}{2}}\right)\\ &\implies I=\frac{\pi \left(1-a\right)}{4}\cdot 2\cdot \frac{\left(e^{\frac{i\pi a}{2}}-e^{\frac{3i\pi a}{2}}\right)}{1-e^{2i\pi a}} \end{split}$$
Hence $$2\cdot\frac{\left(e^{\frac{i\pi a}{2}}-e^{\frac{3i\pi a}{2}}\right)}{1-e^{2i\pi a}}\Rightarrow\ \frac{1}{\cos\left(\frac{a\pi}{2}\right)}=\frac{2}{e^{\frac{i\pi a}{2}}+e^{-\frac{i\pi a}{2}}}$$
First, you seem to have made a sign mistake. A correct computation gives
$$ I = \frac{(1-a)\pi}{4} \cdot \bbox[color:blue; padding:5px; background:#F5E5FF;]{2} \cdot \frac{e^{\frac{i\pi a}{2}}-e^{\frac{3i\pi a}{2}}}{1-e^{2i\pi a}}. $$
Then we can proceed as follows: Substituting $\omega = e^{i\pi a/2}$ for simplicity,
\begin{align*} 2 \cdot \frac{e^{\frac{i\pi a}{2}}-e^{\frac{3i\pi a}{2}}}{1-e^{2i\pi a}} &= 2 \cdot \frac{\omega - \omega^3}{1 - \omega^4} = \frac{2\omega(\omega^2 - 1)}{(\omega^2 - 1)(\omega^2 + 1)} \\ &= \frac{2}{\omega + \omega^{-1}} = \frac{1}{\cos(\pi a/2)}. \end{align*}
Plugging this back completes the proof of the identity.