diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 890e38c..8e6ea76 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,6 +4,7 @@
+
@@ -37,9 +38,144 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -48,36 +184,37 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -167,7 +304,7 @@
-
+
@@ -357,7 +494,6 @@
-
@@ -370,6 +506,7 @@
+
@@ -405,6 +542,7 @@
+
@@ -502,7 +640,6 @@
-
@@ -684,12 +821,6 @@
1420801533300
-
- 1437489171221
-
-
- 1437489171222
-
1437496683560
@@ -978,7 +1109,13 @@
1450454675383
-
+
+ 1450525487060
+
+
+ 1450525487061
+
+
@@ -989,7 +1126,7 @@
-
+
@@ -1019,7 +1156,6 @@
-
@@ -1044,7 +1180,8 @@
-
+
+
@@ -1361,16 +1498,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -1491,7 +1618,7 @@
-
+
@@ -1521,38 +1648,184 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Anteoloader.py b/Anteoloader.py
index 378cf7d..9812e32 100644
--- a/Anteoloader.py
+++ b/Anteoloader.py
@@ -28,7 +28,7 @@ import xbmc
import xbmcgui
import xbmcvfs
import Localization
-from functions import file_encode, isSubtitle, DownloadDB, log, debug, is_writable, unquote
+from functions import file_encode, isSubtitle, DownloadDB, log, debug, is_writable, unquote, file_url
import os
@@ -102,12 +102,10 @@ class AnteoLoader:
sys.exit(1)
#pre settings
- if os.path.exists(torrentFile) and xbmc.getCondVisibility("system.platform.windows") and not re.match("^file\:.+$", torrentFile):
- self.torrentFile = "file:///"+torrentFile.replace('\\','//').replace('////','//')
+ if os.path.exists(torrentFile):
+ self.torrentFile = file_url(torrentFile)
elif re.match("^magnet\:.+$", torrentFile):
self.magnetLink = torrentFile
- else:
- self.torrentFile = torrentFile
def __exit__(self):
log('on __exit__')
@@ -204,10 +202,8 @@ class AnteoLoader:
if not xbmcvfs.exists(self.torrentFilesPath): xbmcvfs.mkdirs(self.torrentFilesPath)
torrentFile = os.path.join(self.torrentFilesPath, self.md5(torrentUrl) + '.torrent')
xbmcvfs.copy(torrentUrl, torrentFile)
- if xbmcvfs.exists(torrentFile) and xbmc.getCondVisibility("system.platform.windows") and not re.match("^file\:.+$", torrentFile):
- self.torrentFile = "file:///"+torrentFile.replace('\\','//').replace('////','//')
- elif xbmcvfs.exists(torrentFile):
- self.torrentFile = torrentFile
+ if xbmcvfs.exists(torrentFile):
+ self.torrentFile = file_url(torrentFile)
return self.torrentFile
def md5(self, string):
@@ -222,10 +218,7 @@ class AnteoLoader:
from Libtorrent import Libtorrent
torrent = Libtorrent(self.storageDirectory, self.magnetLink)
torrent.magnetToTorrent(self.magnetLink)
- if xbmc.getCondVisibility("system.platform.windows") and not re.match("^file\:.+$", torrent.torrentFile):
- self.torrentFile = "file:///"+torrent.torrentFile.replace('\\','//').replace('////','//')
- else:
- self.torrentFile = torrent.torrentFile
+ self.torrentFile = file_url(torrent.torrentFile)
class AnteoPlayer(xbmc.Player):
__plugin__ = sys.modules["__main__"].__plugin__
@@ -301,8 +294,8 @@ class AnteoPlayer(xbmc.Player):
self.on_playback_resumed = []
self.on_playback_paused = []
self.on_playback_stopped = []
- if xbmcvfs.exists(self.torrentUrl) and xbmc.getCondVisibility("system.platform.windows") and not re.match("^file\:.+$", self.torrentUrl):
- self.torrentUrl = "file:///"+str(self.torrentUrl).replace('\\','//').replace('////','//')
+ if os.path.exists(self.torrentUrl):
+ self.torrentUrl = file_url(self.torrentUrl)
def setup_engine(self):
#uri=None, binaries_path=None, platform=None, download_path=".",
diff --git a/functions.py b/functions.py
index 64d826e..adc12da 100644
--- a/functions.py
+++ b/functions.py
@@ -1841,3 +1841,17 @@ def check_download_dir():
dialog.ok(Localization.localize('Torrenter'),
Localization.localize('Please specify storage folder in Settings!'))
__settings__.openSettings()
+
+def ensure_str(string, encoding='utf-8'):
+ if isinstance(string, unicode):
+ string = string.encode(encoding)
+ if not isinstance(string, str):
+ string = str(string)
+ return string
+
+def file_url(torrentFile):
+ import urlparse
+ if not re.match("^file\:.+$", torrentFile):
+ torrentFile = urlparse.urljoin('file:', urllib.pathname2url(ensure_str(torrentFile)))
+ return torrentFile
+