|
|
|
@ -34,12 +34,12 @@ def download():
|
|
|
|
|
form.start_time.data = datetime.now().replace(minute=0, second=0) - timedelta(hours=1)
|
|
|
|
|
form.length.data = 60
|
|
|
|
|
elif form.validate_on_submit():
|
|
|
|
|
try:
|
|
|
|
|
output_filename = prepare_download(form)
|
|
|
|
|
if output_filename:
|
|
|
|
|
flash('The download should start immediately.', 'success')
|
|
|
|
|
return render_template('download.html', form=form, filename=output_filename)
|
|
|
|
|
else:
|
|
|
|
|
flash('Error preparing download!', 'warning')
|
|
|
|
|
except ValueError as e:
|
|
|
|
|
flash('Error preparing download: {}'.format(e), 'warning')
|
|
|
|
|
else:
|
|
|
|
|
flash('Error in form!', 'warning')
|
|
|
|
|
return render_template('download.html', form=form)
|
|
|
|
@ -79,7 +79,7 @@ def prepare_download(form):
|
|
|
|
|
if source['start_time'] <= form.start_time.data < source['start_time'] + source['length']:
|
|
|
|
|
start_index = i
|
|
|
|
|
if start_index is None:
|
|
|
|
|
return None
|
|
|
|
|
raise ValueError('Could not find start file')
|
|
|
|
|
sources = sources[start_index:]
|
|
|
|
|
|
|
|
|
|
# Seek into the first file
|
|
|
|
|