Since the integrand decays like $1/|z|^2$
$$
\oint\pi\cot(\pi z){\small\left(\frac1{(8z+1)^2}-\frac1{(8z+3)^2}-\frac1{(8z+5)^2}+\frac1{(8z+7)^2}\right)}\,\mathrm{d}z=0\tag{1}
$$
There are singularities at each integer and at $\left\{-\frac18,-\frac38,-\frac58,-\frac78\right\}$.
The residue of $\pi\cot(\pi z)$ is $1$ at each integer, so the contribution of the residues at the integers is
$$
2\sum_{k=0}^\infty\left(\frac1{(8k+1)^2}-\frac1{(8k+3)^2}-\frac1{(8k+5)^2}+\frac1{(8k+7)^2}\right)\tag{2}
$$
\oint\pi\cot(\pi z){\small\left(\frac1{(8z+1)^2}-\frac1{(8z+3)^2}-\frac1{(8z+5)^2}+\frac1{(8z+7)^2}\right)}\,\mathrm{d}z=0\tag{1}
$$
There are singularities at each integer and at $\left\{-\frac18,-\frac38,-\frac58,-\frac78\right\}$.
The residue of $\pi\cot(\pi z)$ is $1$ at each integer, so the contribution of the residues at the integers is
$$
2\sum_{k=0}^\infty\left(\frac1{(8k+1)^2}-\frac1{(8k+3)^2}-\frac1{(8k+5)^2}+\frac1{(8k+7)^2}\right)\tag{2}