[hearthisat] Add support for more high-quality download links

This commit is contained in:
Philipp Hagemeister 2015-01-22 12:04:07 +01:00
parent e5763a7a7e
commit b55ee18ff3
2 changed files with 45 additions and 12 deletions

View file

@ -1612,6 +1612,14 @@ def urlhandle_detect_ext(url_handle):
except AttributeError: # Python < 3
getheader = url_handle.info().getheader
cd = getheader('Content-Disposition')
if cd:
m = re.match(r'attachment;\s*filename="(?P<filename>[^"]+)"', cd)
if m:
e = determine_ext(m.group('filename'), default_ext=None)
if e:
return e
return getheader('Content-Type').split("/")[1]