From 565fab4a83cdf44756db839a587ab0bef79e7028 Mon Sep 17 00:00:00 2001 From: inpos Date: Sat, 5 Mar 2016 00:57:33 +0300 Subject: [PATCH] win --- lib/pyrrent2http/pyrrent2http.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/pyrrent2http/pyrrent2http.py b/lib/pyrrent2http/pyrrent2http.py index eb4e9a1..68106ba 100644 --- a/lib/pyrrent2http/pyrrent2http.py +++ b/lib/pyrrent2http/pyrrent2http.py @@ -653,6 +653,8 @@ class Pyrrent2http(object): else: raise def buildTorrentParams(self, uri): + if uri[1] == ':' and sys.platform.startswith('win'): + uri = 'file:///' + uri fileUri = urlparse.urlparse(uri) torrentParams = {} if self.magnet: @@ -662,12 +664,7 @@ class Pyrrent2http(object): if uriPath != '' and sys.platform.startswith('win') and (os.path.sep == uriPath[0] or uriPath[0] == '/'): uriPath = uriPath[1:] try: - if sys.platform.startswith('win'): - driveLetter = uriPath[:2] - wpath = uriPath[2:].replace('\\', '/') - absPath = driveLetter + os.path.abspath(urllib.unquote(wpath)).replace('/', '\\') - else: - absPath = os.path.abspath(urllib.unquote(uriPath)) + absPath = os.path.abspath(urllib.unquote(uriPath)) logging.info('Opening local file: %s' % (absPath,)) with open(absPath, 'rb') as f: torrent_info = lt.torrent_info(lt.bdecode(f.read()))