diff --git a/Core.py b/Core.py index 4e73190..a9c1abf 100644 --- a/Core.py +++ b/Core.py @@ -18,8 +18,6 @@ along with this program. If not, see . ''' -import tempfile - import Downloader import xbmc import xbmcaddon @@ -1484,7 +1482,7 @@ class Core: if append_filesize: fileTitle += ' [%d MB]' % (size / 1024 / 1024) 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]) dirList, contentListNew = cutFolder(contentList, tdir) diff --git a/Downloader.py b/Downloader.py index d334c28..468972a 100644 --- a/Downloader.py +++ b/Downloader.py @@ -21,10 +21,6 @@ import hashlib import sys -import Libtorrent -import AceStream -import Anteoloader -import Inposloader from functions import log class Torrent(): @@ -33,15 +29,19 @@ class Torrent(): def __init__(self, storageDirectory='', torrentFile='', torrentFilesDirectory='torrents'): self.get_torrent_client() if self.player == 'libtorrent': + import Libtorrent self.player = Libtorrent.Libtorrent(storageDirectory, torrentFile, torrentFilesDirectory) elif self.player == 'acestream': + import AceStream self.player = AceStream.AceStream(storageDirectory, torrentFile, torrentFilesDirectory) elif self.player == 'anteo': + import Anteoloader self.player = Anteoloader.AnteoLoader(storageDirectory, torrentFile, torrentFilesDirectory) elif self.player == 'inpos': + import Inposloader self.player = Inposloader.InposLoader(storageDirectory, torrentFile, torrentFilesDirectory) def __exit__(self): diff --git a/functions.py b/functions.py index dc26d3c..3f4f15d 100644 --- a/functions.py +++ b/functions.py @@ -422,45 +422,44 @@ def cutFolder(contentList, tdir=None): if len(contentList) > 1: common_folder = contentList[0][0] - if '\\' in common_folder: - common_folder = common_folder.split('\\')[0] - elif '/' in common_folder: - common_folder = common_folder.split('/')[0] + debug('[cutFolder]: common_folder '+common_folder) + if u'\\' in common_folder: + common_folder = common_folder.split(u'\\')[0] + elif u'/' in common_folder: + common_folder = common_folder.split(u'/')[0] common = True for item in contentList: - fileTitle = item[0] - if common_folder not in fileTitle: + if common_folder not in item[0]: common = False break - # print common_folder for item in contentList: - fileTitle = item[0] - contentId = item[1] dir = None 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: - dir = fileTitle.split('\\')[0] - elif '/' in fileTitle: - dir = fileTitle.split('/')[0] + if u'\\' in item[0]: + dir = item[0].split(u'\\')[0] + elif u'/' in item[0]: + dir = item[0].split(u'/')[0] elif not tdir: contentListNew.append(item) if tdir and dir == tdir: tupleContent = list(item) - tupleContent[0] = fileTitle[len(dir) + 1:] - contentListNew.append(tuple(tupleContent)) + tupleContent[0] = item[0][len(dir) + 1:] + contentListNew.append(list(tupleContent)) if not tdir and dir and dir not in dirList: dirList.append(dir) + debug('[cutFolder]: dirList, contentListNew '+str(dirList)+str(contentListNew)) return dirList, contentListNew else: + debug('[cutFolder]: dirList, contentList '+str(dirList)+str(contentList)) return dirList, contentList