Here's my revised solution that is shorter in working (which is still ridiculously long). The only tedious part is the simplifiying of the integrand after the Weierstrass Substitution. Outline:
Let $ y = \frac \pi 2 - x $, we get
$ \begin{eqnarray} \displaystyle \int \frac{\cos y - 2}{\cos^2 y - \cos y + 1} \, dy & = & \displaystyle \int \frac{(-\sin y) + (\sin y + \cos y - 2)}{\cos^2 y - \cos y + 1} \, dy \\ & = & \int \frac{-\sin y}{\cos^2 y - \cos y + 1} \, dy + \int \frac{\sin y + \cos y - 2} {\cos^2 y - \cos y + 1} \, dy \end{eqnarray} $
The first integral can be solved via substitution of $ p = -\cos y $ then convert it in the form of $ \large\displaystyle \int \frac{ds}{a^2+s^2} = \frac1a \tan^{-1} \left( \frac sa\right) $
For the second integral, we use the Weierstrass Substitution as suggested. Let $ t = \tan\left( \frac y2\right) $ and the integrand simplifies to
$ \large \frac{-6t^2+4t-2}{(t^2+1)^2} $
Apply partial fraction
$ \large \frac{4t}{(t^2+1)^2} - \frac6{t^2+1} + \frac4{(t^2+1)^2} $
Which can be easily integrated.
If I'm correct, back substituting everything yields
$ \large \frac2{\sqrt3} \tan^{-1} \left(\frac2{\sqrt3}\sin x\right) - \frac{2(\sin x + 1)}{\tan \frac x2 + 1} - 4\cot^{-1} x + C $