...
 
Commits (2)
#!/usr/bin/env python3
# Copyright 2013-2018 Mats Sjöberg
#
# This file is part of the getpods programme.
#
# getpods is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# getpods is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with getpods. If not, see <http://www.gnu.org/licenses/>.
......@@ -101,16 +101,14 @@ def download_progress(current, size):
def download_url(url, localname):
read_bytes = 0
with urllib.request.urlopen(url) as \
r, tempfile.NamedTemporaryFile(delete=False) as fp:
with urllib.request.urlopen(url) as r, \
tempfile.NamedTemporaryFile(delete=False) as fp:
total_bytes = r.length
while not r.closed and r.length > 0:
data = r.read(16384)
fp.write(data)
read_bytes += len(data)
download_progress(read_bytes, total_bytes)
fp.close()
tmpname = fp.name
shutil.move(tmpname, localname)
......
# Copyright 2018 Mats Sjöberg
# This file is part of the getpods programme.
#
# getpods is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# getpods is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with getpods. If not, see <http://www.gnu.org/licenses/>.
import collections
import re
......