(video_links)
| 32 | |
| 33 | |
| 34 | def download_video_series(video_links): |
| 35 | for link in video_links: |
| 36 | """iterate through all links in video_links |
| 37 | and download them one by one""" |
| 38 | |
| 39 | # obtain filename by splitting url and getting |
| 40 | # last string |
| 41 | file_name = link.split("/")[-1] |
| 42 | |
| 43 | print("Downloading the file:%s" % file_name) |
| 44 | |
| 45 | # create response object |
| 46 | r = requests.get(link, stream=True) |
| 47 | |
| 48 | # download started |
| 49 | with open(file_name, "wb") as f: |
| 50 | for chunk in r.iter_content(chunk_size=1024 * 1024): |
| 51 | if chunk: |
| 52 | f.write(chunk) |
| 53 | |
| 54 | print("%s downloaded!\n" % file_name) |
| 55 | |
| 56 | print("All videos are downloaded!") |
| 57 | return |
| 58 | |
| 59 | |
| 60 | if __name__ == "__main__": |
no test coverage detected