Use urllib.{quote,unquote} instead of {pathname2url,url2pathname}
This commit is contained in:
parent
a221036e5a
commit
0f603c3ede
@ -140,7 +140,7 @@ def _convert_mpd_data(data, tracks, music_dir):
|
|||||||
path = data['file'][1:]
|
path = data['file'][1:]
|
||||||
else:
|
else:
|
||||||
path = data['file']
|
path = data['file']
|
||||||
path = urllib.url2pathname(path)
|
path = urllib.unquote(path)
|
||||||
|
|
||||||
if artist_kwargs:
|
if artist_kwargs:
|
||||||
artist = Artist(**artist_kwargs)
|
artist = Artist(**artist_kwargs)
|
||||||
|
|||||||
@ -160,7 +160,7 @@ def _add_to_tag_cache(result, folders, files):
|
|||||||
try:
|
try:
|
||||||
text_path = path.decode('utf-8')
|
text_path = path.decode('utf-8')
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
text_path = urllib.pathname2url(path).decode('utf-8')
|
text_path = urllib.quote(path).decode('utf-8')
|
||||||
name = os.path.split(text_path)[1]
|
name = os.path.split(text_path)[1]
|
||||||
result.append(('directory', text_path))
|
result.append(('directory', text_path))
|
||||||
result.append(('mtime', get_mtime(os.path.join(base_path, path))))
|
result.append(('mtime', get_mtime(os.path.join(base_path, path))))
|
||||||
@ -177,9 +177,9 @@ def _add_to_tag_cache(result, folders, files):
|
|||||||
try:
|
try:
|
||||||
text_path = path.decode('utf-8')
|
text_path = path.decode('utf-8')
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
text_path = urllib.pathname2url(path).decode('utf-8')
|
text_path = urllib.quote(path).decode('utf-8')
|
||||||
relative_path = os.path.relpath(path, base_path)
|
relative_path = os.path.relpath(path, base_path)
|
||||||
relative_uri = urllib.pathname2url(relative_path)
|
relative_uri = urllib.quote(relative_path)
|
||||||
|
|
||||||
track_result['file'] = relative_uri
|
track_result['file'] = relative_uri
|
||||||
track_result['mtime'] = get_mtime(path)
|
track_result['mtime'] = get_mtime(path)
|
||||||
|
|||||||
@ -64,8 +64,8 @@ def path_to_uri(*paths):
|
|||||||
if isinstance(path, unicode):
|
if isinstance(path, unicode):
|
||||||
path = path.encode('utf-8')
|
path = path.encode('utf-8')
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
return 'file:' + urllib.pathname2url(path)
|
return 'file:' + urllib.quote(path)
|
||||||
return 'file://' + urllib.pathname2url(path)
|
return 'file://' + urllib.quote(path)
|
||||||
|
|
||||||
|
|
||||||
def uri_to_path(uri):
|
def uri_to_path(uri):
|
||||||
@ -82,9 +82,9 @@ def uri_to_path(uri):
|
|||||||
if isinstance(uri, unicode):
|
if isinstance(uri, unicode):
|
||||||
uri = uri.encode('utf-8')
|
uri = uri.encode('utf-8')
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
return urllib.url2pathname(re.sub(b'^file:', b'', uri))
|
return urllib.unquote(re.sub(b'^file:', b'', uri))
|
||||||
else:
|
else:
|
||||||
return urllib.url2pathname(re.sub(b'^file://', b'', uri))
|
return urllib.unquote(re.sub(b'^file://', b'', uri))
|
||||||
|
|
||||||
|
|
||||||
def split_path(path):
|
def split_path(path):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user