mirror of
https://github.com/jellyfin/jellyfin-mpv-shim.git
synced 2024-11-30 09:40:44 +00:00
rewrite smb url with credentials to url without credentials in windows (#84)
* rewrite media url with credentials * use pathlib for extra safety Co-authored-by: Antonio Zhu <antoniozhu@outlook.de>
This commit is contained in:
parent
8776143d5f
commit
308dcffedf
@ -2,6 +2,9 @@ import logging
|
||||
import uuid
|
||||
import urllib.parse
|
||||
import os.path
|
||||
import re
|
||||
import pathlib
|
||||
from sys import platform
|
||||
|
||||
from .conf import settings
|
||||
from .utils import is_local_domain, get_profile, get_seq
|
||||
@ -134,7 +137,16 @@ class Video(object):
|
||||
if urllib.parse.urlparse(self.media_source['Path']).scheme:
|
||||
self.is_transcode = False
|
||||
log.debug("Using remote direct path.")
|
||||
return self.media_source['Path']
|
||||
# translate path for windows
|
||||
# if path is smb path in credential format for kodi and maybe linux \\username:password@mediaserver\foo,
|
||||
# translate it to mediaserver/foo
|
||||
if sys.platform.startswith("win32") or sys.platform.startswith("cygwin"):
|
||||
# matches on SMB scheme
|
||||
match = re.search('(?:\\\\).+:.*@(.+)', self.media_source['Path'])
|
||||
if match:
|
||||
# replace forward slash to backward slashes
|
||||
return pathlib.Path('\\\\' + match.groups()[0]
|
||||
return pathlib.Path(self.media_source['Path'])
|
||||
else:
|
||||
# If there's no uri scheme, check if the file exixsts because it might not be mounted
|
||||
if os.path.isfile(self.media_source['Path']):
|
||||
|
Loading…
Reference in New Issue
Block a user