|
a/rdpl2stream/lib/DummyMMSHandler.py |
|
b/rdpl2stream/lib/DummyMMSHandler.py |
|
... |
|
... |
17 |
# along with Radio Tray. If not, see <http://www.gnu.org/licenses/>.
|
17 |
# along with Radio Tray. If not, see <http://www.gnu.org/licenses/>.
|
18 |
#
|
18 |
#
|
19 |
##########################################################################
|
19 |
##########################################################################
|
20 |
import urllib2
|
20 |
import urllib2
|
21 |
|
21 |
|
22 |
class DummyMMSHandler(urllib2.BaseHandler):
|
22 |
class DummyMMSHandler(urllib2.HTTPRedirectHandler):
|
23 |
|
23 |
|
24 |
def mms_open(self, request):
|
24 |
# Handle mms redirection, or let the standard code deal with it.
|
25 |
print request.get_full_url()
|
25 |
def http_error_302(self, req, fp, code, msg, headers):
|
26 |
raise urllib2.URLError("MMS REDIRECT:"+request.get_full_url()) |
26 |
if 'location' in headers:
|
|
|
27 |
newurl = headers.getheaders('location')[0]
|
|
|
28 |
if newurl.startswith('mms:'):
|
|
|
29 |
raise urllib2.URLError("MMS REDIRECT:"+headers["Location"])
|
|
|
30 |
return urllib2.HTTPRedirectHandler.http_error_302(self, req, fp, code,
|
|
|
31 |
msg, headers)
|