Кодировка mbcs в нерусской Windows
This commit is contained in:
		
							parent
							
								
									fe32c5c6f0
								
							
						
					
					
						commit
						610983e345
					
				@ -1,5 +1,5 @@
 | 
				
			|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 | 
					<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 | 
				
			||||||
<addon id="script.module.pyrrent2http" name="pyrrent2http" version="0.6.0" provider-name="inpos">
 | 
					<addon id="script.module.pyrrent2http" name="pyrrent2http" version="0.7.0" provider-name="inpos">
 | 
				
			||||||
    <requires>
 | 
					    <requires>
 | 
				
			||||||
        <import addon="xbmc.python" version="2.14.0"/>
 | 
					        <import addon="xbmc.python" version="2.14.0"/>
 | 
				
			||||||
        <import	addon="script.module.libtorrent" />
 | 
					        <import	addon="script.module.libtorrent" />
 | 
				
			||||||
 | 
				
			|||||||
@ -5,7 +5,6 @@ import sys, os
 | 
				
			|||||||
import json
 | 
					import json
 | 
				
			||||||
import chardet
 | 
					import chardet
 | 
				
			||||||
try:
 | 
					try:
 | 
				
			||||||
    import xbmcgui
 | 
					 | 
				
			||||||
    from python_libtorrent import get_libtorrent
 | 
					    from python_libtorrent import get_libtorrent
 | 
				
			||||||
    lt=get_libtorrent()
 | 
					    lt=get_libtorrent()
 | 
				
			||||||
    print('Imported libtorrent v%s from python_libtorrent' %(lt.version, ))
 | 
					    print('Imported libtorrent v%s from python_libtorrent' %(lt.version, ))
 | 
				
			||||||
@ -172,7 +171,8 @@ class TorrentFile(object):
 | 
				
			|||||||
        if self.filePtr is None:
 | 
					        if self.filePtr is None:
 | 
				
			||||||
            #print('savePath: %s' % (self.savePath,))
 | 
					            #print('savePath: %s' % (self.savePath,))
 | 
				
			||||||
            while not os.path.exists(self.savePath):
 | 
					            while not os.path.exists(self.savePath):
 | 
				
			||||||
                time.sleep(0.1)
 | 
					                logging.info('Waiting: %s' % (self.savePath,))
 | 
				
			||||||
 | 
					                time.sleep(0.5)
 | 
				
			||||||
            self.filePtr = io.open(self.savePath, 'rb')
 | 
					            self.filePtr = io.open(self.savePath, 'rb')
 | 
				
			||||||
        return self.filePtr
 | 
					        return self.filePtr
 | 
				
			||||||
    def log(self, message):
 | 
					    def log(self, message):
 | 
				
			||||||
@ -375,7 +375,11 @@ class TorrentFS(object):
 | 
				
			|||||||
        if index < 0 or index >= info.num_files():
 | 
					        if index < 0 or index >= info.num_files():
 | 
				
			||||||
            raise IndexError
 | 
					            raise IndexError
 | 
				
			||||||
        fileEntry = info.file_at(index)
 | 
					        fileEntry = info.file_at(index)
 | 
				
			||||||
        path = os.path.abspath(os.path.join(self.SavePath(), fileEntry.path))
 | 
					        fe_path = fileEntry.path
 | 
				
			||||||
 | 
					        fe_path = fe_path.decode(chardet.detect(fe_path)['encoding'])
 | 
				
			||||||
 | 
					        if not sys.platform.startswith('win'):
 | 
				
			||||||
 | 
					            fe_path = fe_path.encode(sys.getfilesystemencoding())
 | 
				
			||||||
 | 
					        path = os.path.abspath(os.path.join(self.SavePath(), fe_path))
 | 
				
			||||||
        return TorrentFile(
 | 
					        return TorrentFile(
 | 
				
			||||||
                           self,
 | 
					                           self,
 | 
				
			||||||
                           fileEntry,
 | 
					                           fileEntry,
 | 
				
			||||||
@ -383,9 +387,12 @@ class TorrentFS(object):
 | 
				
			|||||||
                           index
 | 
					                           index
 | 
				
			||||||
                           )
 | 
					                           )
 | 
				
			||||||
    def FileByName(self, name):
 | 
					    def FileByName(self, name):
 | 
				
			||||||
 | 
					        name = name.decode(chardet.detect(name)['encoding'])
 | 
				
			||||||
 | 
					        if not sys.platform.startswith('win'):
 | 
				
			||||||
 | 
					            name = name.encode(sys.getfilesystemencoding())
 | 
				
			||||||
        savePath = os.path.abspath(os.path.join(self.SavePath(), name))
 | 
					        savePath = os.path.abspath(os.path.join(self.SavePath(), name))
 | 
				
			||||||
        for file_ in self.Files():
 | 
					        for file_ in self.Files():
 | 
				
			||||||
            if file_.SavePath() == savePath:
 | 
					            if file_.savePath == savePath:
 | 
				
			||||||
                return file_
 | 
					                return file_
 | 
				
			||||||
        raise IOError
 | 
					        raise IOError
 | 
				
			||||||
    def Open(self, name):
 | 
					    def Open(self, name):
 | 
				
			||||||
@ -415,8 +422,7 @@ class TorrentFS(object):
 | 
				
			|||||||
        tf.num = self.fileCounter
 | 
					        tf.num = self.fileCounter
 | 
				
			||||||
        tf.log('Opening %s...' % (tf.name,))
 | 
					        tf.log('Opening %s...' % (tf.name,))
 | 
				
			||||||
        tf.SetPriority(1)
 | 
					        tf.SetPriority(1)
 | 
				
			||||||
        startPiece, _ = tf.Pieces()
 | 
					        self.handle.set_piece_deadline(tf.startPiece, 50)
 | 
				
			||||||
        self.handle.set_piece_deadline(startPiece, 50)
 | 
					 | 
				
			||||||
        self.lastOpenedFile = tf
 | 
					        self.lastOpenedFile = tf
 | 
				
			||||||
        self.addOpenedFile(tf)
 | 
					        self.addOpenedFile(tf)
 | 
				
			||||||
        self.checkPriorities()
 | 
					        self.checkPriorities()
 | 
				
			||||||
@ -982,7 +988,7 @@ class Pyrrent2http(object):
 | 
				
			|||||||
            if self.forceShutdown:
 | 
					            if self.forceShutdown:
 | 
				
			||||||
                return
 | 
					                return
 | 
				
			||||||
            if time.time() - time_start > 0.5:
 | 
					            if time.time() - time_start > 0.5:
 | 
				
			||||||
                self.consumeAlerts()
 | 
					                #self.consumeAlerts()
 | 
				
			||||||
                self.TorrentFS.LoadFileProgress()
 | 
					                self.TorrentFS.LoadFileProgress()
 | 
				
			||||||
                state = self.torrentHandle.status().state
 | 
					                state = self.torrentHandle.status().state
 | 
				
			||||||
                if self.config.exitOnFinish and (state == state.finished or state == state.seeding):
 | 
					                if self.config.exitOnFinish and (state == state.finished or state == state.seeding):
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user