+1 to using an rpm macro to avoid adding an external script, if spectool can work with it.
Something like:
%global source0_generate_script ( \
curl ... \
rm -rf ... \
tar ... )
I'm not sure if that syntax is correct.