Merge pull request #6 from DiMartinoXBMC/master

merge from origin
pull/7/head
inpos 2016-03-19 21:15:02 +04:00
commit 65c9e8ef9e
3 changed files with 21 additions and 24 deletions

View File

@ -18,8 +18,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
''' '''
import tempfile
import Downloader import Downloader
import xbmc import xbmc
import xbmcaddon import xbmcaddon
@ -1484,7 +1482,7 @@ class Core:
if append_filesize: if append_filesize:
fileTitle += ' [%d MB]' % (size / 1024 / 1024) fileTitle += ' [%d MB]' % (size / 1024 / 1024)
hasSize = True hasSize = True
contentList.append((unescape(fileTitle), str(filedict.get('ind')), size)) contentList.append([unescape(fileTitle), str(filedict.get('ind')), size])
#contentList = sorted(contentList, key=lambda x: x[0]) #contentList = sorted(contentList, key=lambda x: x[0])
dirList, contentListNew = cutFolder(contentList, tdir) dirList, contentListNew = cutFolder(contentList, tdir)

View File

@ -21,10 +21,6 @@
import hashlib import hashlib
import sys import sys
import Libtorrent
import AceStream
import Anteoloader
import Inposloader
from functions import log from functions import log
class Torrent(): class Torrent():
@ -33,15 +29,19 @@ class Torrent():
def __init__(self, storageDirectory='', torrentFile='', torrentFilesDirectory='torrents'): def __init__(self, storageDirectory='', torrentFile='', torrentFilesDirectory='torrents'):
self.get_torrent_client() self.get_torrent_client()
if self.player == 'libtorrent': if self.player == 'libtorrent':
import Libtorrent
self.player = Libtorrent.Libtorrent(storageDirectory, torrentFile, torrentFilesDirectory) self.player = Libtorrent.Libtorrent(storageDirectory, torrentFile, torrentFilesDirectory)
elif self.player == 'acestream': elif self.player == 'acestream':
import AceStream
self.player = AceStream.AceStream(storageDirectory, torrentFile, torrentFilesDirectory) self.player = AceStream.AceStream(storageDirectory, torrentFile, torrentFilesDirectory)
elif self.player == 'anteo': elif self.player == 'anteo':
import Anteoloader
self.player = Anteoloader.AnteoLoader(storageDirectory, torrentFile, torrentFilesDirectory) self.player = Anteoloader.AnteoLoader(storageDirectory, torrentFile, torrentFilesDirectory)
elif self.player == 'inpos': elif self.player == 'inpos':
import Inposloader
self.player = Inposloader.InposLoader(storageDirectory, torrentFile, torrentFilesDirectory) self.player = Inposloader.InposLoader(storageDirectory, torrentFile, torrentFilesDirectory)
def __exit__(self): def __exit__(self):

View File

@ -422,45 +422,44 @@ def cutFolder(contentList, tdir=None):
if len(contentList) > 1: if len(contentList) > 1:
common_folder = contentList[0][0] common_folder = contentList[0][0]
if '\\' in common_folder: debug('[cutFolder]: common_folder '+common_folder)
common_folder = common_folder.split('\\')[0] if u'\\' in common_folder:
elif '/' in common_folder: common_folder = common_folder.split(u'\\')[0]
common_folder = common_folder.split('/')[0] elif u'/' in common_folder:
common_folder = common_folder.split(u'/')[0]
common = True common = True
for item in contentList: for item in contentList:
fileTitle = item[0] if common_folder not in item[0]:
if common_folder not in fileTitle:
common = False common = False
break break
# print common_folder
for item in contentList: for item in contentList:
fileTitle = item[0]
contentId = item[1]
dir = None dir = None
if common: if common:
fileTitle = fileTitle[len(common_folder) + 1:] item[0] = item[0][len(common_folder) + 1:]
# print fileTitle #debug('[cutFolder]: item[0] '+item[0])
if '\\' in fileTitle: if u'\\' in item[0]:
dir = fileTitle.split('\\')[0] dir = item[0].split(u'\\')[0]
elif '/' in fileTitle: elif u'/' in item[0]:
dir = fileTitle.split('/')[0] dir = item[0].split(u'/')[0]
elif not tdir: elif not tdir:
contentListNew.append(item) contentListNew.append(item)
if tdir and dir == tdir: if tdir and dir == tdir:
tupleContent = list(item) tupleContent = list(item)
tupleContent[0] = fileTitle[len(dir) + 1:] tupleContent[0] = item[0][len(dir) + 1:]
contentListNew.append(tuple(tupleContent)) contentListNew.append(list(tupleContent))
if not tdir and dir and dir not in dirList: if not tdir and dir and dir not in dirList:
dirList.append(dir) dirList.append(dir)
debug('[cutFolder]: dirList, contentListNew '+str(dirList)+str(contentListNew))
return dirList, contentListNew return dirList, contentListNew
else: else:
debug('[cutFolder]: dirList, contentList '+str(dirList)+str(contentList))
return dirList, contentList return dirList, contentList