Posts: 249
Joined: Feb 2005
Reputation:
0
EnderW
Skilled Python Coder
Posts: 249
thanks for you answer.
i think i perhaps get some things wrong. i'm horrible at reading others code (and coding myself), but from the short time i spent looking on it i assume that every time a block of data is received it will call ondataretrieved(). my problem then would be getting the parameters out from there, as i would have to modify the module. that would make it harder to update the module in the future as the added lines made specifically for my script would have to be added. i could of course be way off here, but if you have the time it would be nice if you could explain how i would do it most easily.
xbmcscripts.com administrator
Posts: 145
Joined: Apr 2005
Reputation:
0
Phunck
Senior Member
Posts: 145
i can see that the name "bytesread" is confusing. this is the number of bytes read, not the actual data. if you look at the parameters for ondatareceived:
ondataretrieved(self, bytesread, totalsize, url, localfile)
then you can see that you get bytesread and totalsize. if you want to calculate a percentage (note totalsize might be none if there is no "content-length" header):
percent=(bytesread*100.0)/totalsize
if you look at the code for cachedhttpwithprogress then you'll notice that i create the progressbar here if it isn't already created and then i update the percentage. in ondownloadfinished i just close the progressbar.
Posts: 249
Joined: Feb 2005
Reputation:
0
EnderW
Skilled Python Coder
Posts: 249
thanks for the clarification, seems like i have to edit the module then as i suspected. will make it more troublesome for users to update, but i can't see any other way you could handle it really...unless you could pass on a function from "my script" to your module which your module then execute in my script sending those same parameters...i suck at explaining, but i hope you understand. that way you could update the module at any time without needing to edit it.
xbmcscripts.com administrator
Posts: 249
Joined: Feb 2005
Reputation:
0
EnderW
Skilled Python Coder
Posts: 249
ah, of course...thanks again. i got a lot left to learn about python and even though i knew about inheriting, it didn't occour to me to use it :\
xbmcscripts.com is down at the moment, but should be back up soon...no one can download your script at the moment though.
xbmcscripts.com administrator
Posts: 211
Joined: Mar 2005
Reputation:
0
Bernd
Senior Member
Posts: 211
phunck, with your latest changes this really is the ultimate http fetch class!
it really rocks :kickass: and is a great step towards better and more reliable scripts.
thanks man
bernd
Posts: 928
Joined: Feb 2004
Reputation:
0
Asteron
"Skilled" Python Coder
Posts: 928
is there any word on getting this module into cvs? would that be reasonable first of all?
Posts: 145
Joined: Apr 2005
Reputation:
0
Phunck
Senior Member
Posts: 145
i have close to zero experience with cvs. but i'm 100% for sharing the source with everybody. so, somebody else must decide if it is appropriate to put it there.
note: as i said the x drive is not available from xbmc and so i've chosen to use 'q:\\scripts\\httpcache\\'
instead. this is not optimal as bernd pointed out, but i see no better alternative. if anybody has any better suggestion for the cache location i'm willing to change it.
Posts: 928
Joined: Feb 2004
Reputation:
0
Asteron
"Skilled" Python Coder
Posts: 928
if x: - z: is not doable it should probably go in something like
q:\scripts\temp\cache rather than q:\scripts\httpcache
Posts: 211
Joined: Mar 2005
Reputation:
0
Bernd
Senior Member
Posts: 211
try using urllib.quote, urllib.quote_plus, urllib.urlencode