In polar form we have,
$\alpha_1 + i\alpha_2 = r_1e^{i\phi_1}$, and $\beta_1 + i\beta_2 = r_2e^{i\phi_2}$
So,
$$|\psi\rangle
= r_1e^{i\phi_1} |0\rangle + r_2e^{i\phi_2} |1\rangle
= e^{i\phi_1}(r_1 |0\rangle + r_2e^{i(\phi_2 - \phi_1)} |1\rangle)$$
Lets, $\varphi = \phi_2 - \phi_1$ then,
$$|\psi\rangle = e^{i\phi_1}(r_1 |0\rangle + r_2e^{i\varphi} |1\rangle)$$
Assuming that $|\psi\rangle$ is a normalized quantum state (that is, $r_1^2 + r_2^2 = 1$) we can find an angle $\theta$ such that $\cos(\frac{\theta}{2}) = r_1$ and $\sin(\frac{\theta}{2}) = r_2$. That means,
$$|\psi\rangle = e^{i\phi_1}(\cos{\small(\theta/2)} |0\rangle + e^{i\varphi} \sin{\small(\theta/2)} |1\rangle)$$
And $\phi_1$ is a global phase.
This code snippet calculates $\theta$ and $\varphi$ given two complex numbers $z_1=\alpha_1 + i\alpha_2$ and $z_2=\beta_1 + i\beta_2$
import math, cmath
r1, phi1 = cmath.polar(z1)
r2, phi2 = cmath.polar(z2)
theta = 2 * math.acos(r1)
phi = phi2 - phi1
print('θ =', theta)
print('φ =', phi)