|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
import time
|
|
|
|
|
import logging as log
|
|
|
|
|
|
|
|
|
|
from tqdm import tqdm
|
|
|
|
|
#from tqdm import tqdm
|
|
|
|
|
import requests as req
|
|
|
|
|
from requests.auth import HTTPBasicAuth
|
|
|
|
|
|
|
|
|
@ -80,7 +80,6 @@ class Studip:
|
|
|
|
|
rsp = self.auth_req('/api.php/user/' + user_id + '/courses')
|
|
|
|
|
ord_sems = self.get_ordered_semesters()
|
|
|
|
|
courses = rsp.json()['collection']
|
|
|
|
|
i = 0
|
|
|
|
|
course_list = {}
|
|
|
|
|
for course_uri in courses:
|
|
|
|
|
course = courses[course_uri]
|
|
|
|
@ -147,12 +146,12 @@ class Studip:
|
|
|
|
|
last_dl = self.db.get_last_file_dl(doc)
|
|
|
|
|
if last_dl == None or last_dl < doc_chdate:
|
|
|
|
|
rsp2 = self.auth_req('/api.php/file/' + doc + '/download')
|
|
|
|
|
total_size = int(rsp2.headers.get('content-length', 0))
|
|
|
|
|
print('downloading ' + doc_name)
|
|
|
|
|
progbar = tqdm(total=total_size, unit='iB', unit_scale=True)
|
|
|
|
|
#total_size = int(rsp2.headers.get('content-length', 0))
|
|
|
|
|
log.info('downloading ' + doc_name)
|
|
|
|
|
#progbar = tqdm(total=total_size, unit='iB', unit_scale=True)
|
|
|
|
|
with open(doc_name, 'wb') as doc_file:
|
|
|
|
|
for chunk in rsp2.iter_content(self.CHUNK_SIZE):
|
|
|
|
|
progbar.update(len(chunk))
|
|
|
|
|
#progbar.update(len(chunk))
|
|
|
|
|
doc_file.write(chunk)
|
|
|
|
|
self.db.set_last_file_dl(str(doc), str(int(time.time())))
|
|
|
|
|
|
|
|
|
|