localize
parent
a83699f477
commit
c08f0c3b0e
|
@ -29,7 +29,7 @@ import xbmcgui
|
|||
import xbmcvfs
|
||||
import xbmcaddon
|
||||
import Localization
|
||||
from functions import file_encode, isSubtitle, DownloadDB, log, debug, is_writable, unquote, file_url
|
||||
from functions import localize_path, isSubtitle, is_writable, file_url
|
||||
|
||||
|
||||
import os
|
||||
|
@ -261,7 +261,7 @@ class AnteoLoader:
|
|||
class AnteoPlayer(xbmc.Player):
|
||||
__plugin__ = sys.modules["__main__"].__plugin__
|
||||
__settings__ = sys.modules["__main__"].__settings__
|
||||
ROOT = sys.modules["__main__"].__root__ # .decode('utf-8').encode(sys.getfilesystemencoding())
|
||||
ROOT = sys.modules["__main__"].__root__
|
||||
USERAGENT = "Mozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/20100101 Firefox/5.0"
|
||||
torrentFilesDirectory = 'torrents'
|
||||
debug = __settings__.getSetting('debug') == 'true'
|
||||
|
@ -318,7 +318,6 @@ class AnteoPlayer(xbmc.Player):
|
|||
break
|
||||
except Exception, e:
|
||||
import traceback
|
||||
log('['+author+'Player]: ' + str(e))
|
||||
log(traceback.format_exc())
|
||||
finally:
|
||||
self.engine.close()
|
||||
|
@ -621,7 +620,7 @@ class AnteoPlayer(xbmc.Player):
|
|||
|
||||
def _get_status_lines(self, s, f):
|
||||
return [
|
||||
self.display_name,
|
||||
localize_path(self.display_name),
|
||||
"%.2f%% %s" % (f.progress * 100, self.localize(STATE_STRS[s.state]).decode('utf-8')),
|
||||
"D:%.2f%s U:%.2f%s S:%d P:%d" % (s.download_rate, self.localize('kb/s').decode('utf-8'),
|
||||
s.upload_rate, self.localize('kb/s').decode('utf-8'),
|
||||
|
|
4
Core.py
4
Core.py
|
@ -31,8 +31,8 @@ from functions import *
|
|||
class Core:
|
||||
__plugin__ = sys.modules["__main__"].__plugin__
|
||||
__settings__ = sys.modules["__main__"].__settings__
|
||||
ROOT = sys.modules["__main__"].__root__ #.decode('utf-8').encode(sys.getfilesystemencoding())
|
||||
userStorageDirectory = file_encode(__settings__.getSetting("storage"))
|
||||
ROOT = sys.modules["__main__"].__root__
|
||||
userStorageDirectory = localize_path(__settings__.getSetting("storage"))#file_encode(__settings__.getSetting("storage"))
|
||||
torrentFilesDirectory = 'torrents'
|
||||
debug = __settings__.getSetting('debug') == 'true'
|
||||
torrent_player = __settings__.getSetting("torrent_player")
|
||||
|
|
|
@ -31,7 +31,8 @@ import xbmc
|
|||
import xbmcgui
|
||||
import xbmcvfs
|
||||
import Localization
|
||||
from functions import file_encode, isSubtitle, DownloadDB, log, debug, is_writable, vista_check, windows_check
|
||||
from functions import isSubtitle, DownloadDB, log, debug, is_writable,\
|
||||
vista_check, windows_check, localize_path
|
||||
from platform_pulsar import get_platform
|
||||
|
||||
class Libtorrent:
|
||||
|
@ -127,7 +128,7 @@ class Libtorrent:
|
|||
log('Exception: ' + str(e))
|
||||
xbmcvfs.delete(torrentFile)
|
||||
return
|
||||
baseName = file_encode(os.path.basename(self.getFilePath()))
|
||||
baseName = localize_path(os.path.basename(self.getFilePath()))
|
||||
if not xbmcvfs.exists(self.torrentFilesPath):
|
||||
xbmcvfs.mkdirs(self.torrentFilesPath)
|
||||
newFile = self.torrentFilesPath + self.md5(baseName) + '.' + self.md5(
|
||||
|
@ -240,7 +241,7 @@ class Libtorrent:
|
|||
def getContentList(self):
|
||||
filelist = []
|
||||
for contentId, contentFile in enumerate(self.torrentFileInfo.files()):
|
||||
stringdata = {"title": contentFile.path, "size": contentFile.size, "ind": int(contentId),
|
||||
stringdata = {"title": localize_path(contentFile.path), "size": contentFile.size, "ind": int(contentId),
|
||||
'offset': contentFile.offset}
|
||||
filelist.append(stringdata)
|
||||
return filelist
|
||||
|
|
|
@ -124,7 +124,6 @@ class OverlayText(object):
|
|||
class TorrentPlayer(xbmc.Player):
|
||||
__plugin__ = sys.modules["__main__"].__plugin__
|
||||
__settings__ = sys.modules["__main__"].__settings__
|
||||
ROOT = sys.modules["__main__"].__root__ # .decode('utf-8').encode(sys.getfilesystemencoding())
|
||||
USERAGENT = "Mozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/20100101 Firefox/5.0"
|
||||
torrentFilesDirectory = 'torrents'
|
||||
debug = __settings__.getSetting('debug') == 'true'
|
||||
|
@ -466,7 +465,7 @@ class TorrentPlayer(xbmc.Player):
|
|||
|
||||
def _get_status_lines(self, s):
|
||||
return [
|
||||
self.display_name.decode('utf-8')+'; '+self.torrent.get_debug_info('dht_state'),
|
||||
self.display_name+'; '+self.torrent.get_debug_info('dht_state'),
|
||||
"%.2f%% %s; %s" % (s.progress * 100, self.localize(STATE_STRS[s.state]).decode('utf-8'), self.torrent.get_debug_info('trackers_sum')),
|
||||
"D:%.2f%s U:%.2f%s S:%d P:%d" % (s.download_rate / 1024, self.localize('kb/s').decode('utf-8'),
|
||||
s.upload_rate / 1024, self.localize('kb/s').decode('utf-8'),
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<import addon="script.module.requests"/>
|
||||
<import addon="script.module.torrent2http"/>
|
||||
<import addon="script.module.pyrrent2http"/>
|
||||
<import addon="script.module.chardet" />
|
||||
</requires>
|
||||
<extension point="xbmc.python.pluginsource" provides="video" library="default.py">
|
||||
<provides>video</provides>
|
||||
|
|
32
functions.py
32
functions.py
|
@ -2000,8 +2000,8 @@ def ensure_str(string, encoding='utf-8'):
|
|||
|
||||
def file_url(torrentFile):
|
||||
import urlparse
|
||||
if not re.match("^file\:.+$", torrentFile) and os.path.exists(torrentFile):
|
||||
torrentFile = urlparse.urljoin('file:', urllib.pathname2url(ensure_str(torrentFile)))
|
||||
if not re.match("^file\:.+$", torrentFile) and xbmcvfs.exists(torrentFile):
|
||||
torrentFile = urlparse.urljoin('file:', urllib.pathname2url(torrentFile))
|
||||
return torrentFile
|
||||
|
||||
def dump(obj):
|
||||
|
@ -2032,3 +2032,31 @@ def foldername(path):
|
|||
else:
|
||||
foldername = ''
|
||||
return foldername
|
||||
|
||||
def uri2path(uri):
|
||||
import urlparse
|
||||
if uri[1] == ':' and sys.platform.startswith('win'):
|
||||
uri = 'file:///' + uri
|
||||
fileUri = urlparse.urlparse(uri)
|
||||
if fileUri.scheme == 'file':
|
||||
uriPath = fileUri.path
|
||||
if uriPath != '' and sys.platform.startswith('win') and (os.path.sep == uriPath[0] or uriPath[0] == '/'):
|
||||
uriPath = uriPath[1:]
|
||||
absPath = os.path.abspath(urllib.unquote(uriPath))
|
||||
return localize_path(absPath)
|
||||
|
||||
def normalize_msg(tmpl, *args):
|
||||
import chardet
|
||||
msg = isinstance(tmpl, unicode) and tmpl or tmpl.decode(chardet.detect(tmpl)['encoding'])
|
||||
arg_ = []
|
||||
for a in args:
|
||||
if not isinstance(a, unicode): arg_.append(a.decode(chardet.detect(a)['encoding']))
|
||||
return msg % tuple(arg_)
|
||||
|
||||
|
||||
def localize_path(path):
|
||||
import chardet
|
||||
if not isinstance(path, unicode): path = path.decode(chardet.detect(path)['encoding'])
|
||||
if not sys.platform.startswith('win'):
|
||||
path = path.encode(True and sys.getfilesystemencoding() or 'utf-8')
|
||||
return path
|
Loading…
Reference in New Issue