Encode file path properly using python
You can use urllib. The following example might need to be changed if you use Python 3.x, but the general idea is the same:
import urllib
encoded_filename = urllib.quote(filename)
f = open(encoded_filename)
You may need pathname2url
Python 2.x (docs)
>>> from urllib import pathname2url
>>> pathname2url('foo, bar.mp3')
'foo%2C%20bar.mp3'
Python 3.x (docs)
>>> from urllib.request import pathname2url
>>> pathname2url('foo, bar.mp3')
'foo%2C%20bar.mp3'
from urllib import pathname2url
pathname2url('foo,bar.mp3')