Closed rakiru closed 10 years ago
Git.io being what it is, there's probably some API we can use..
True. I'm curious what the issue with the current method is though.
Yeah. It does seem pretty odd, but I haven't noticed it with any other sites.
This seems to be due to URLLib's inability to follow some 30x redirects. We should probably look at the requests module or work around this ourselves.
I think moving to requests would be a decent idea, rather than having to build upon urllib. I can see other plugins needing it anyway, perhaps even for special URL handlers, and with the great package manager system, dependencies like that aren't an issue anyway.
It's not /that/ great yet. :P
Yeah, maybe we could use Requests. However, current URLs plugin is working and is extensible already - Maybe take a look at it first.
"yet" being the key word there. ;P
Well, if I remember correctly, it involves subclassing RedirectHandler (or something similar) and calling urllib2.install_opener() or similar. Using requests would be much simpler/cleaner, and should be trivial to do.
Well, the main problem seems to be that it throws errors on non-200 status codes. Urllib itself doesn't do that.
On Thu, Nov 21, 2013 at 4:20 PM, Sean Gordon notifications@github.comwrote:
"yet" being the key word there. ;P
Well, if I remember correctly, it involves subclassing RedirectHandler (or something similar) and calling urllib2.install_opener() or similar. Using requests would be much simpler/cleaner, and should be trivial to do.
— Reply to this email directly or view it on GitHubhttps://github.com/UltrosBot/Ultros/issues/9#issuecomment-28998262 .
You mean with other 2XX messages, or with non 2XX messages?
Non-2XX messages, I think.
Well, yeah, those are errors. Just catch the exceptions and deal with them. What's urllib do with a 404/403, etc?
Nothing, I think. Could check: http://httpstat.us
EDIT: http://puu.sh/5pab8.png
https://github.com/UltrosBot/Ultros/commit/4085e4c5c48336f4659f01996096c3a6974bb9d3 I'm not sure if this was the only problem, but the URLs from Notifico were surrounded by formatting chars, which were still on the end of the URL we were attempting to download.
gio.io URLs return 400 errors for some unknown reason. Possibly missing headers or something.
EDIT: This also goes for db.tt URLs. Something weird is going on here.