downloadkit/downloadkit.py
changeset 127 e6bf005a5f58
parent 126 c107e11c37e8
child 128 c63eca238256
equal deleted inserted replaced
126:c107e11c37e8 127:e6bf005a5f58
   155 				chunk = response.read(CHUNK)
   155 				chunk = response.read(CHUNK)
   156 				if not chunk: break
   156 				if not chunk: break
   157 				if first_chunk and chunk.find('<div id="sign_in_box">') != -1:
   157 				if first_chunk and chunk.find('<div id="sign_in_box">') != -1:
   158 					# our urllib2 cookies have gone awol - login again
   158 					# our urllib2 cookies have gone awol - login again
   159 					login(False)
   159 					login(False)
   160 					req = urllib2.Request(downloadurl)
   160 					req = urllib2.Request(downloadurl, None, headers)
   161 					response = urllib2.urlopen(req)
   161 					response = urllib2.urlopen(req)
   162 					chunk = response.read(CHUNK)	  
   162 					chunk = response.read(CHUNK)	  
   163 				fp.write(chunk)
   163 				fp.write(chunk)
   164 				first_chunk = False
   164 				first_chunk = False
   165 			fp.close()
   165 			fp.close()