I am trying to load an HLS m3u8 manifest file with unmatched SSL certificate. I am using m3u8 library for Python. My script is the following:
#!/usr/bin/env python
from urllib import quote
import m3u8
import ssl
input_file = quote(raw_input("Please enter the input file path: "), safe=':''/')
#try:
manifest = m3u8.load(input_file)
#except ssl.CertificateError:
#print "WARNING SSL Error!"
for playlist in manifest.playlists:
print playlist.uri
print playlist.stream_info.bandwidth
So when I run it with my link it reports ssl.CertificateError because the SSL certificate is not correct, but I want to skip this check and only print an SSL warning in this case and continue with the execution of the script. Is this possible and how can I do it?
I have changed my script to:
#!/usr/bin/env python
from urllib import quote
import m3u8
import requests
input_file = quote(raw_input("Please enter the input file path: "), safe=':''/')
url = requests.get(input_file, verify = False)
manifest = m3u8.load(url)
for playlist in manifest.playlists:
print playlist.uri
print playlist.stream_info.bandwidth
But now I get the following error:
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/connectionpool.py:852: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecureRequestWarning)
Traceback (most recent call last):
File "./open.sh", line 10, in <module>
manifest = m3u8.load(url)
File "/usr/local/lib/python2.7/dist-packages/m3u8/__init__.py", line 44, in load
if is_url(uri):
File "/usr/local/lib/python2.7/dist-packages/m3u8/parser.py", line 337, in is_url
return re.match(r'https?://', uri) is not None
File "/usr/lib/python2.7/re.py", line 141, in match
return _compile(pattern, flags).match(string)
TypeError: expected string or buffer