Closed moraesdam closed 11 years ago
Hi Daniel Thanks for the bug report. There seems to be error in downloading srt and txt files. For the time being, please download only the video files. I will update the code with corrections shortly.
Hi Daniel/Siddhartha,
I guess I should post a fork, but a quickfix is to wrap lines causing error in a try/except loop, replacing the desired value with a placeholder. e.g., the following worked for me:
try:
total_size = int(response.info().getheader('Content-Length').strip())
except:
print "Content-Length header not found... creating arbitrary total_size of 100"
total_size = 100 # arbitary value
While not a 'solution', this gets it working, and since the bug appears to be related only to printing messages about the download size, it isn't a major problem.
I also changed:
try:
speed = bytes_so_far / (1024 * (time.time() - start_time))
except ZeroDivisionError: # for some reason this occured once after downloading file
speed = 100 # an arbitrary non-zero value
Hi alexf101 and moraesdam,
Very sorry for no response all this while. Only just got the opportunity to address the issue. The error are being caused due to a missing content length in the header. I've committed code which bypasses the header. Please check it out.
Cheers :)
Hi, Siddhartha.
Unfortunately I don't know python yet to help fix this error:
python coursera.py progfun-2012-001
Downloading progfun-2012-001 to coursera/functional-programming-principles-in-sala for user@domain.net Getting downloads list... Logging in... Submitting form... Login successful! Downloads list obtained!
1.getting started
* 1. course introduction * File: 1.1-course-introduction.txt Downloaded 0.00 / 0.00 MiB (100.00% at 6459 kbps) File: 1.1-course-introduction.srt Downloaded 0.00 / 0.00 MiB (100.00% at 8244 kbps) File: 1.1-course-introduction.mp4 Downloaded 7.31 / 7.31 MiB (100.00% at 147 kbps)
* 2. tools setup for linux * File: 1.2-tools-setup-for-linux.txt Downloaded 0.01 / 0.01 MiB (100.00% at 13877 kbps) File: 1.2-tools-setup-for-linux.srt Traceback (most recent call last): File "coursera.py", line 227, in
main()
File "coursera.py", line 219, in main
if c.downloadcontents() == -1:
File "coursera.py", line 183, in downloadcontents
ret = self.downloadfile(url, filename)
File "coursera.py", line 113, in downloadfile
total_size = int(response.info().getheader('Content-Length').strip())
AttributeError: 'NoneType' object has no attribute 'strip'