Last active
November 5, 2017 16:09
-
-
Save p3t3r67x0/330112f1e60f64831affa639c316ee8f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import requests | |
def download_stream(video_url, video_name): | |
with open(video_name, 'wb') as handle: | |
response = requests.get(video_url, stream=True) | |
download_size = 0 | |
total_length = response.headers.get('content-length') | |
if total_length is None: # no content length header | |
handle.write(response.content) | |
else: | |
for data in response.iter_content(chunk_size=4096): | |
download_size += len(data) | |
handle.write(data) | |
def main(): | |
with open('arte_list.txt', 'r') as f: | |
a = f.readlines() | |
x = [] | |
y = [] | |
for n, i in enumerate(a): | |
if not i.startswith('\n') and i.startswith('http'): | |
x.append(i.strip('\n')) | |
if not i.startswith('\n') and not i.startswith('http'): | |
y.append(i.strip('\n')) | |
for b in zip(x, y): | |
print b[0], b[1] | |
download_stream(b[0], b[1]) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment