Dog rescued after spending almost 24 hours stuck in pipe