Here is a solution using real analysis. First, denote the two integrals as
\begin{align*}
J & \equiv\int\limits_0^{\pi}\frac {x\left(\sin\frac x2\color{red}-\cos\frac x2\right)}{\sqrt{\sin x}}\,\mathrm dx\\K & \equiv\int\limits_0^{\pi}\frac {x\left(\sin\frac x2\color{red}+\cos\frac x2\right)}{\sqrt{\sin x}}\,\mathrm dx
\end{align*}
And from your post, recall that $K=\pi^2$. Adding the two integrals together removes the $\cos\frac x2$ factor inside the integrand, leaving only
\begin{align*}
J+K & =2\int\limits_0^{\pi}\frac {x\sin\frac x2}{\sqrt{\sin x}}\,\mathrm dx\\ & =\sqrt 2\int\limits_0^{\pi}x\sqrt{\tan\frac x2}\,\mathrm dx\\ & =4\sqrt{2}\int\limits_0^{+\infty}\frac {\sqrt t}{1+t^2}\arctan t\,\mathrm dt
\end{align*}
Where a double angle identity was utilized in the second equation and the half-angle tangent substitution in the third equation. The last integral has been evaluated here before using Complex Analysis, Feynman's Trick, etc. Here is an alternative approach using double integrals. First, enforce the substitution $x=\sqrt t$ so that the integral becomes
$$\int\limits_0^{+\infty}\frac {\sqrt t}{1+t^2}\arctan t\,\mathrm dt=2\int\limits_0^{+\infty}\frac {x^2}{1+x^4}\arctan x^2\,\mathrm dx$$
Next, use the identity
$$\arctan x^2=\int\limits_0^1\frac {x^2}{1+x^4 y^2}\,\mathrm dy$$
Swapping the order of integration and using partial fraction decomposition, then we get
\begin{align*}
2\int\limits_0^{+\infty}\,\int\limits_0^1\frac {x^4}{(1+x^4)(1+x^4y^2)}\,\mathrm dy\,\mathrm dx & =2\int\limits_0^1\frac 1{y^2-1}\int\limits_0^{+\infty}\frac 1{1+x^4}-\frac 1{1+x^4y^2}\,\mathrm dx\,\mathrm dy\\ & =\frac {\pi}{\sqrt 2}\int\limits_0^1\frac 1{y^2-1}\left(1-\frac 1{\sqrt y}\right)\,\mathrm dy\\ & =\frac {\pi^2}{4\sqrt 2}+\frac {\pi\log 4}{4\sqrt 2}
\end{align*}
To recap, we have the equation
$$J+\pi^2=4\sqrt{2}\int\limits_0^{+\infty}\frac {\sqrt t}{1+t^2}\arctan t\,\mathrm dt=\pi^2+\pi\log 4$$
Subtracting a $\pi^2$ from both sides, then
$$\int\limits_0^{\pi}\frac {x\left(\sin\frac x2-\cos\frac x2\right)}{\sqrt{\sin x}}\,\mathrm dx\color{blue}{=\pi\log 4}$$
For any $\;x\in\left[\dfrac{\pi}8, \dfrac\pi4\right[,\;$ it results that
$\begin{align}\dfrac{4\pi\tan^4(2x)}{\cos^2(x)}&\geqslant\dfrac{4\pi\tan^4(2x)}{\cos^2(\frac\pi8)}>4\pi\tan^4(2x) =\dfrac{4\pi\sin^4(2x)}{\cos^4(2x)}\geqslant\\[3pt]&\geqslant\dfrac{4\pi\sin^4(\frac{\pi}4)}{\sin^4\!\left(\frac{\pi}2\!-\!2x\right)}=\dfrac{\pi}{\sin^4\!\left(\frac{\pi}2\!-\!2x\right)}>\dfrac{\pi}{\left(\frac{\pi}2\!-\!2x\right)^4}\,.\end{align}$
Moreover ,
$\begin{align}\!\!\!\!\!\!\displaystyle\int_0^1\!\dfrac{4\pi\tan^4(2x)}{\cos^2(x)}\,\mathrm dx&>\!\int_{\frac\pi8}^{\frac\pi4}\!\dfrac{4\pi\tan^4(2x)}{\cos^2(x)}\,\mathrm dx>\!\int_{\frac\pi8}^{\frac\pi4}\!\!\dfrac{\pi}{\left(\frac{\pi}2\!-\!2x\right)^4}\,\mathrm dx=\\[3pt]&=\lim\limits_{\varepsilon\to0^+}\,\left[\dfrac{\pi}{6\left(\frac\pi2\!-\!2x\right)^3}\right]_{\frac\pi8}^{\frac\pi4-\varepsilon}\!\!\!\!=+\infty\;.\end{align}$
Best Answer
You could simply use the difference of squares formula to go from the first to the third step in one stride. Also, the way you wrote the integrand as a derivative is incorrect. Try differentiating to check. To get the indefinite integral, all you need to do is integrate by parts - integrating the trig function and differentiating the polynomial coefficient. So, $\int x^2\cos xdx=(x^2-2)\sin x+2x\cos x$ and $\int x\sin xdx=\sin x-x\cos x$. So, the answer is actually $-\sin(1)+2\cos(1)+4\sin(1)-4\cos(1)-2\sin(1)=\sin(1)-2\cos(1)$