Skip to content

Instantly share code, notes, and snippets.

@p3t3r67x0
Created March 26, 2018 08:01
Show Gist options
  • Save p3t3r67x0/92ed7b65fa1aa51eea3be621a05c421b to your computer and use it in GitHub Desktop.
Save p3t3r67x0/92ed7b65fa1aa51eea3be621a05c421b to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
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():
if len(sys.argv) > 1:
with open(sys.argv[1], 'r') as f:
a = f.readlines()
else:
print 'Enter the filename from the mp4 list!'
sys.exit(1)
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