It's very important to identify the components of a problem. I'd actually say you have two separate problems:
Downloading a file from an URL.
Creating a thumbnail image from an incomplete video file.
Look into those two separately, you'll find plenty of information.