commit
d150210340
36
Core.py
36
Core.py
|
@ -1101,11 +1101,13 @@ class Core:
|
|||
view_style('searchOption')
|
||||
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=True)
|
||||
|
||||
def drawItem(self, title, action, link='', image='', isFolder=True, contextMenu=None, replaceMenu=True, action2='',
|
||||
def drawItem(self, title, action, link='', image='', isFolder=True, contextMenu=None, replaceMenu=True, action2='', fileSize=0L,
|
||||
info={}):
|
||||
listitem = xbmcgui.ListItem(title, iconImage=image, thumbnailImage=image)
|
||||
#log('[drawItem]:'+str((title, action, image, isFolder, contextMenu, replaceMenu, action2, info)))
|
||||
if not info: info = {"Title": title, "plot": title}
|
||||
if not isFolder and fileSize:
|
||||
info['size'] = fileSize
|
||||
if isinstance(link, dict):
|
||||
link_url = ''
|
||||
for key in link.keys():
|
||||
|
@ -1465,14 +1467,19 @@ class Core:
|
|||
if not torrent: torrent = Downloader.Torrent(self.userStorageDirectory,
|
||||
torrentFilesDirectory=self.torrentFilesDirectory)
|
||||
self.__settings__.setSetting("lastTorrent", torrent.saveTorrent(url))
|
||||
|
||||
|
||||
append_filesize = self.__settings__.getSetting("append_filesize") == 'true'
|
||||
hasSize = False
|
||||
contentList = []
|
||||
for filedict in torrent.getContentList():
|
||||
fileTitle = filedict.get('title')
|
||||
if filedict.get('size'):
|
||||
fileTitle += ' [%d MB]' % (filedict.get('size') / 1024 / 1024)
|
||||
contentList.append((unescape(fileTitle), str(filedict.get('ind'))))
|
||||
contentList = sorted(contentList, key=lambda x: x[0])
|
||||
size = filedict.get('size')
|
||||
if size:
|
||||
if append_filesize:
|
||||
fileTitle += ' [%d MB]' % (size / 1024 / 1024)
|
||||
hasSize = True
|
||||
contentList.append((unescape(fileTitle), str(filedict.get('ind')), size))
|
||||
#contentList = sorted(contentList, key=lambda x: x[0])
|
||||
|
||||
dirList, contentListNew = cutFolder(contentList, tdir)
|
||||
|
||||
|
@ -1486,7 +1493,7 @@ class Core:
|
|||
for identifier in ids_video_result:
|
||||
ids_video = ids_video + str(identifier) + ','
|
||||
|
||||
for title, identifier in contentListNew:
|
||||
for title, identifier, filesize in contentListNew:
|
||||
contextMenu = [
|
||||
(self.localize('Download via T-client'),
|
||||
'XBMC.RunPlugin(%s)' % ('%s?action=%s&ind=%s') % (
|
||||
|
@ -1497,9 +1504,20 @@ class Core:
|
|||
]
|
||||
link = {'url': identifier, 'thumbnail': thumbnail, 'save_folder':save_folder}
|
||||
self.drawItem(title, 'playTorrent', link, image=thumbnail, isFolder=False,
|
||||
action2=ids_video.rstrip(','), contextMenu=contextMenu, replaceMenu=False)
|
||||
action2=ids_video.rstrip(','), contextMenu=contextMenu, replaceMenu=False, fileSize=filesize)
|
||||
view_style('openTorrent')
|
||||
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=True)
|
||||
p_handle = int(sys.argv[1])
|
||||
try:
|
||||
xbmcplugin.addSortMethod(p_handle, xbmcplugin.SORT_METHOD_LABEL)
|
||||
if hasSize:
|
||||
xbmcplugin.addSortMethod(p_handle, xbmcplugin.SORT_METHOD_SIZE)
|
||||
xbmc.executebuiltin("Container.SetSortMethod(%s)" % str(1))
|
||||
#xbmc.executebuiltin("Container.SetSortDirection()")
|
||||
except:
|
||||
log(' !!!! >>>> Faild to set sorting method to ' + str(xbmcplugin.SORT_METHOD_SIZE))
|
||||
pass
|
||||
|
||||
xbmcplugin.endOfDirectory(p_handle, succeeded=True)
|
||||
|
||||
def openSection(self, params={}):
|
||||
get = params.get
|
||||
|
|
|
@ -96,7 +96,9 @@ class Libtorrent:
|
|||
torrentUrl) + '.torrent'
|
||||
try:
|
||||
if not re.match("^http\:.+$", torrentUrl):
|
||||
content = xbmcvfs.File(torrentUrl, "rb").read()
|
||||
contentFile = xbmcvfs.File(torrentUrl, "rb")
|
||||
content = contentFile.read()
|
||||
contentFile.close()
|
||||
else:
|
||||
request = urllib2.Request(torrentUrl)
|
||||
request.add_header('Referer', torrentUrl)
|
||||
|
@ -126,30 +128,7 @@ class Libtorrent:
|
|||
|
||||
self.torrentFile = torrentFile
|
||||
return self.torrentFile
|
||||
#baseName = localize_path(os.path.basename(self.getFilePath()))
|
||||
#if not xbmcvfs.exists(self.torrentFilesPath):
|
||||
# xbmcvfs.mkdirs(self.torrentFilesPath)
|
||||
#newFile = self.torrentFilesPath + self.md5(
|
||||
# torrentUrl) + '.torrent' #self.md5(baseName) + '.' +
|
||||
#if xbmcvfs.exists(newFile):
|
||||
# log('saveTorrent: delete file ' + newFile)
|
||||
# xbmcvfs.delete(newFile)
|
||||
#if not xbmcvfs.exists(newFile):
|
||||
# try:
|
||||
# renamed = xbmcvfs.rename(torrentFile, newFile)
|
||||
# log('saveTorrent: xbmcvfs.rename %s %s to %s' %(torrentFile, newFile, str(renamed)))
|
||||
# except Exception, e:
|
||||
# log('Unable to rename torrent file from %s to %s in Torrent::renameTorrent. Exception: %s' %
|
||||
# (torrentFile, newFile, str(e)))
|
||||
# return
|
||||
#self.torrentFile = newFile
|
||||
#if not self.torrentFileInfo:
|
||||
# e=self.lt.bdecode(xbmcvfs.File(self.torrentFile,'rb').read())
|
||||
# self.torrentFileInfo = self.lt.torrent_info(e)
|
||||
# log('torrentFileInfo (saveTorrent2)=' + str(self.torrentFileInfo))
|
||||
|
||||
#return self.torrentFile
|
||||
|
||||
|
||||
def getMagnetInfo(self):
|
||||
magnetSettings = {
|
||||
'url': self.magnetLink,
|
||||
|
|
17
functions.py
17
functions.py
|
@ -428,13 +428,16 @@ def cutFolder(contentList, tdir=None):
|
|||
common_folder = common_folder.split('/')[0]
|
||||
|
||||
common = True
|
||||
for fileTitle, contentId in contentList:
|
||||
for item in contentList:
|
||||
fileTitle = item[0]
|
||||
if common_folder not in fileTitle:
|
||||
common = False
|
||||
break
|
||||
|
||||
# print common_folder
|
||||
for fileTitle, contentId in contentList:
|
||||
for item in contentList:
|
||||
fileTitle = item[0]
|
||||
contentId = item[1]
|
||||
dir = None
|
||||
if common:
|
||||
fileTitle = fileTitle[len(common_folder) + 1:]
|
||||
|
@ -446,10 +449,12 @@ def cutFolder(contentList, tdir=None):
|
|||
elif '/' in fileTitle:
|
||||
dir = fileTitle.split('/')[0]
|
||||
elif not tdir:
|
||||
contentListNew.append((fileTitle, contentId))
|
||||
contentListNew.append(item)
|
||||
|
||||
if tdir and dir == tdir:
|
||||
contentListNew.append((fileTitle[len(dir) + 1:], contentId))
|
||||
tupleContent = list(item)
|
||||
tupleContent[0] = fileTitle[len(dir) + 1:]
|
||||
contentListNew.append(tuple(tupleContent))
|
||||
|
||||
if not tdir and dir and dir not in dirList:
|
||||
dirList.append(dir)
|
||||
|
@ -1711,7 +1716,9 @@ def get_ids_video(contentList):
|
|||
'fli', 'flc', 'm4v', 'iso']
|
||||
allowed_music_ext = ['mp3', 'flac', 'wma', 'ogg', 'm4a', 'aac', 'm4p', 'rm', 'ra']
|
||||
for extlist in [allowed_video_ext, allowed_music_ext]:
|
||||
for title, identifier in contentList:
|
||||
for item in contentList:
|
||||
title = item[0]
|
||||
identifier = item[1]
|
||||
try:
|
||||
ext = title.split('.')[-1]
|
||||
if ext.lower() in extlist:
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
<string id="30066">Confluence (by safonov_ivan)</string>
|
||||
<string id="30067">Aeon Nox (by joyrider)</string>
|
||||
<string id="30068">pyrrent2http (python-libtorrent via http)</string>
|
||||
<string id="30069">Append size to file name</string>
|
||||
<string id="30101">Interface</string>
|
||||
<string id="30102">P2P Network</string>
|
||||
<string id="30103">Advanced</string>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
||||
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
||||
<strings>
|
||||
<string id="30001">Язык интерфейса</string>
|
||||
<string id="30002">Удерживать стиль отображения</string>
|
||||
|
@ -66,6 +66,7 @@
|
|||
<string id="30066">Confluence (от safonov_ivan)</string>
|
||||
<string id="30067">Aeon Nox (от joyrider)</string>
|
||||
<string id="30068">pyrrent2http (python-libtorrent по http)</string>
|
||||
<string id="30069">Добавлять размер к имени файла</string>
|
||||
<string id="30101">Интерфейс</string>
|
||||
<string id="30102">P2P Сеть</string>
|
||||
<string id="30103">Дополнительные</string>
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<setting id="sort_search" type="enum" label="30061" default="0" lvalues="30062|30063|30064"/>
|
||||
<setting id="skin_optimization" type="enum" label="30002" default="1" lvalues="30003|30018|30017|30016|30019|30066|30067"/>
|
||||
<setting id="open_option" type="enum" label="30034" default="0" lvalues="30035|30036|30037|30038"/>
|
||||
<setting id="append_filesize" type="bool" label="30069" default="false"/>
|
||||
</category>
|
||||
<category label="30103">
|
||||
<setting id="timeout" type="enum" lvalues="30026|30027|30028" label="30025" default="1"/>
|
||||
|
|
Loading…
Reference in New Issue