Skip to content

Instantly share code, notes, and snippets.

@p3t3r67x0
Last active November 5, 2017 16:09

Revisions

  1. Aurelius Wendelken revised this gist Nov 5, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions download_arte_mp4.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    #!/usr/bin/env python
    # -*- coding: utf-8 -*-

    import requests

  2. Aurelius Wendelken created this gist Nov 5, 2017.
    41 changes: 41 additions & 0 deletions download_arte_mp4.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    #!/usr/bin/env python

    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()