playSTRM choose file
parent
03a8ac71bc
commit
c63401533c
85
Core.py
85
Core.py
|
@ -42,23 +42,6 @@ class Core:
|
||||||
history_bool = __settings__.getSetting('history') == 'true'
|
history_bool = __settings__.getSetting('history') == 'true'
|
||||||
open_option = int(__settings__.getSetting('open_option'))
|
open_option = int(__settings__.getSetting('open_option'))
|
||||||
language = {0: 'en', 1: 'ru', 2: 'ru'}.get(int(__settings__.getSetting("language")))
|
language = {0: 'en', 1: 'ru', 2: 'ru'}.get(int(__settings__.getSetting("language")))
|
||||||
htmlCodes = (
|
|
||||||
('&', '&'),
|
|
||||||
('<', '<'),
|
|
||||||
('>', '>'),
|
|
||||||
('"', '"'),
|
|
||||||
("'", '''),
|
|
||||||
)
|
|
||||||
stripPairs = (
|
|
||||||
('<p>', '\n'),
|
|
||||||
('<li>', '\n'),
|
|
||||||
('<br>', '\n'),
|
|
||||||
('<.+?>', ' '),
|
|
||||||
('</.+?>', ' '),
|
|
||||||
(' ', ' '),
|
|
||||||
('«', '"'),
|
|
||||||
('»', '"'),
|
|
||||||
)
|
|
||||||
scrapperDB_ver = {'en':'1.1', 'ru':'1.3'}
|
scrapperDB_ver = {'en':'1.1', 'ru':'1.3'}
|
||||||
|
|
||||||
print 'SYS ARGV: ' + str(sys.argv)
|
print 'SYS ARGV: ' + str(sys.argv)
|
||||||
|
@ -1044,16 +1027,6 @@ class Core:
|
||||||
commands[name] = value
|
commands[name] = value
|
||||||
return commands
|
return commands
|
||||||
|
|
||||||
def unescape(self, string):
|
|
||||||
for (symbol, code) in self.htmlCodes:
|
|
||||||
string = re.sub(code, symbol, string)
|
|
||||||
return string
|
|
||||||
|
|
||||||
def stripHtml(self, string):
|
|
||||||
for (html, replacement) in self.stripPairs:
|
|
||||||
string = re.sub(html, replacement, string)
|
|
||||||
return string
|
|
||||||
|
|
||||||
def executeAction(self, params={}):
|
def executeAction(self, params={}):
|
||||||
get = params.get
|
get = params.get
|
||||||
if hasattr(self, get("action")):
|
if hasattr(self, get("action")):
|
||||||
|
@ -1230,9 +1203,9 @@ class Core:
|
||||||
showMessage(self.localize('Error'), self.localize('Not a magnet-link!'))
|
showMessage(self.localize('Error'), self.localize('Not a magnet-link!'))
|
||||||
return
|
return
|
||||||
elif keyboard.isConfirmed():
|
elif keyboard.isConfirmed():
|
||||||
params["url"] = urllib.quote_plus(self.unescape(urllib.unquote_plus(query)))
|
params["url"] = urllib.quote_plus(unescape(urllib.unquote_plus(query)))
|
||||||
else:
|
else:
|
||||||
params["url"] = urllib.quote_plus(self.unescape(urllib.unquote_plus(defaultKeyword)))
|
params["url"] = urllib.quote_plus(unescape(urllib.unquote_plus(defaultKeyword)))
|
||||||
#print str(params)
|
#print str(params)
|
||||||
self.torrentPlayer(params)
|
self.torrentPlayer(params)
|
||||||
|
|
||||||
|
@ -1258,7 +1231,7 @@ class Core:
|
||||||
fileTitle = filedict.get('title')
|
fileTitle = filedict.get('title')
|
||||||
if filedict.get('size'):
|
if filedict.get('size'):
|
||||||
fileTitle += ' [%d MB]' % (filedict.get('size') / 1024 / 1024)
|
fileTitle += ' [%d MB]' % (filedict.get('size') / 1024 / 1024)
|
||||||
contentList.append((self.unescape(fileTitle), str(filedict.get('ind'))))
|
contentList.append((unescape(fileTitle), str(filedict.get('ind'))))
|
||||||
contentList = sorted(contentList, key=lambda x: x[0])
|
contentList = sorted(contentList, key=lambda x: x[0])
|
||||||
|
|
||||||
#print str(contentList)
|
#print str(contentList)
|
||||||
|
@ -1375,16 +1348,9 @@ class Core:
|
||||||
self.__settings__.setSetting("lastTorrentUrl", url)
|
self.__settings__.setSetting("lastTorrentUrl", url)
|
||||||
torrent = Downloader.Torrent(self.userStorageDirectory, torrentFilesDirectory=self.torrentFilesDirectory)
|
torrent = Downloader.Torrent(self.userStorageDirectory, torrentFilesDirectory=self.torrentFilesDirectory)
|
||||||
self.__settings__.setSetting("lastTorrent", torrent.saveTorrent(url))
|
self.__settings__.setSetting("lastTorrent", torrent.saveTorrent(url))
|
||||||
contentList = []
|
fileIndex = chooseFile(torrent.getContentList())
|
||||||
for filedict in torrent.getContentList():
|
if fileIndex:
|
||||||
fileTitle = filedict.get('title')
|
xbmc.executebuiltin('xbmc.RunPlugin("plugin://plugin.video.torrenter/?action=playTorrent&url='+fileIndex+'")')
|
||||||
if filedict.get('size'):
|
|
||||||
fileTitle += ' [%d MB]' % (filedict.get('size') / 1024 / 1024)
|
|
||||||
contentList.append((filedict.get('size'), self.unescape(fileTitle), str(filedict.get('ind'))))
|
|
||||||
if len(contentList)>0:
|
|
||||||
contentList = sorted(contentList, key=lambda x: x[0], reverse=True)
|
|
||||||
#self.playTorrent({'url':contentList[0][2]})
|
|
||||||
xbmc.executebuiltin('xbmc.RunPlugin("plugin://plugin.video.torrenter/?action=playTorrent&url='+contentList[0][2]+'")')
|
|
||||||
|
|
||||||
def openTorrent(self, params={}):
|
def openTorrent(self, params={}):
|
||||||
get = params.get
|
get = params.get
|
||||||
|
@ -1413,47 +1379,16 @@ class Core:
|
||||||
self.__settings__.setSetting("lastTorrent", torrent.saveTorrent(url))
|
self.__settings__.setSetting("lastTorrent", torrent.saveTorrent(url))
|
||||||
if silent != 'true':
|
if silent != 'true':
|
||||||
if external:
|
if external:
|
||||||
myshows_items, myshows_files, contentList, myshows_sizes = [], [], [], {}
|
fileIndex = chooseFile(torrent.getContentList())
|
||||||
for filedict in torrent.getContentList():
|
if fileIndex:
|
||||||
fileTitle = ''
|
xbmc.executebuiltin('xbmc.RunPlugin("plugin://plugin.video.torrenter/?action=playTorrent&url=' + fileIndex + '")')
|
||||||
if filedict.get('size'):
|
|
||||||
myshows_sizes[str(filedict.get('ind'))]='[%d MB] ' % (filedict.get('size') / 1024 / 1024)
|
|
||||||
title = filedict.get('title')
|
|
||||||
fileTitle = fileTitle + '[%s]%s' % (title[len(title) - 3:], title)
|
|
||||||
contentList.append((self.unescape(fileTitle), str(filedict.get('ind'))))
|
|
||||||
contentList = sorted(contentList, key=lambda x: x[0])
|
|
||||||
for title, identifier in contentList:
|
|
||||||
try:
|
|
||||||
if title.split('.')[-1].lower() in ['avi','mp4','mkv','flv','mov','vob','wmv','ogm','asx','mpg','mpeg','avc','vp3','fli','flc','m4v','iso','mp3']:
|
|
||||||
myshows_items.append(title)
|
|
||||||
myshows_files.append(identifier)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
if len(myshows_items) > 1:
|
|
||||||
if len(myshows_sizes)==0:
|
|
||||||
myshows_items = cutFileNames(myshows_items)
|
|
||||||
else:
|
|
||||||
myshows_cut = cutFileNames(myshows_items)
|
|
||||||
myshows_items=[]
|
|
||||||
x=-1
|
|
||||||
for i in myshows_files:
|
|
||||||
x=x+1
|
|
||||||
fileTitle=myshows_sizes[str(i)]+myshows_cut[x]
|
|
||||||
myshows_items.append(fileTitle)
|
|
||||||
dialog = xbmcgui.Dialog()
|
|
||||||
if len(myshows_items) == 1:
|
|
||||||
ret = 0
|
|
||||||
else:
|
|
||||||
ret = dialog.select(self.localize('Search results:'), myshows_items)
|
|
||||||
if ret > -1:
|
|
||||||
xbmc.executebuiltin('xbmc.RunPlugin("plugin://plugin.video.torrenter/?action=playTorrent&url=' + myshows_files[ret] + '")')
|
|
||||||
else:
|
else:
|
||||||
contentList = []
|
contentList = []
|
||||||
for filedict in torrent.getContentList():
|
for filedict in torrent.getContentList():
|
||||||
fileTitle = filedict.get('title')
|
fileTitle = filedict.get('title')
|
||||||
if filedict.get('size'):
|
if filedict.get('size'):
|
||||||
fileTitle += ' [%d MB]' % (filedict.get('size') / 1024 / 1024)
|
fileTitle += ' [%d MB]' % (filedict.get('size') / 1024 / 1024)
|
||||||
contentList.append((self.unescape(fileTitle), str(filedict.get('ind'))))
|
contentList.append((unescape(fileTitle), str(filedict.get('ind'))))
|
||||||
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)
|
||||||
|
|
|
@ -154,8 +154,8 @@ class Libtorrent:
|
||||||
'save_path': self.storageDirectory,
|
'save_path': self.storageDirectory,
|
||||||
'storage_mode': self.lt.storage_mode_t(0),
|
'storage_mode': self.lt.storage_mode_t(0),
|
||||||
'paused': True,
|
'paused': True,
|
||||||
'auto_managed': True,
|
#'auto_managed': True,
|
||||||
'duplicate_is_error': True
|
#'duplicate_is_error': True
|
||||||
}
|
}
|
||||||
progressBar = xbmcgui.DialogProgress()
|
progressBar = xbmcgui.DialogProgress()
|
||||||
progressBar.create(Localization.localize('Please Wait'), Localization.localize('Magnet-link is converting'))
|
progressBar.create(Localization.localize('Please Wait'), Localization.localize('Magnet-link is converting'))
|
||||||
|
@ -180,6 +180,7 @@ class Libtorrent:
|
||||||
self.magnetLink = magnet
|
self.magnetLink = magnet
|
||||||
self.initSession()
|
self.initSession()
|
||||||
torrentInfo = self.getMagnetInfo()
|
torrentInfo = self.getMagnetInfo()
|
||||||
|
if torrentInfo:
|
||||||
try:
|
try:
|
||||||
torrentFile = self.lt.create_torrent(torrentInfo)
|
torrentFile = self.lt.create_torrent(torrentInfo)
|
||||||
baseName = os.path.basename(self.storageDirectory + os.sep + torrentInfo.files()[0].path)
|
baseName = os.path.basename(self.storageDirectory + os.sep + torrentInfo.files()[0].path)
|
||||||
|
@ -195,6 +196,9 @@ class Libtorrent:
|
||||||
xbmc.executebuiltin("Notification(%s, %s, 7500)" % (Localization.localize('Error'), Localization.localize(
|
xbmc.executebuiltin("Notification(%s, %s, 7500)" % (Localization.localize('Error'), Localization.localize(
|
||||||
'Can\'t download torrent, probably no seeds available.')))
|
'Can\'t download torrent, probably no seeds available.')))
|
||||||
self.torrentFileInfo = torrentInfo
|
self.torrentFileInfo = torrentInfo
|
||||||
|
finally:
|
||||||
|
self.session.remove_torrent(self.torrentHandle)
|
||||||
|
self.torrentHandle = None
|
||||||
|
|
||||||
def getUploadRate(self):
|
def getUploadRate(self):
|
||||||
if None == self.torrentHandle:
|
if None == self.torrentHandle:
|
||||||
|
@ -538,7 +542,7 @@ class Libtorrent:
|
||||||
try:
|
try:
|
||||||
nodes=self.session.dht_state().get('nodes')
|
nodes=self.session.dht_state().get('nodes')
|
||||||
except:
|
except:
|
||||||
nodes=None
|
nodes=self.session.status().get('nodes_num')
|
||||||
nodes=len(nodes) if nodes else 0
|
nodes=len(nodes) if nodes else 0
|
||||||
result='DHT: %s (%d)' % (is_dht_running, nodes)
|
result='DHT: %s (%d)' % (is_dht_running, nodes)
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
English changelog at http://bit.ly/1MfSVUP
|
English changelog at http://bit.ly/1MfSVUP
|
||||||
|
|
||||||
[B]Version 2.3.6[/B]
|
[B]Version 2.3.6[/B]
|
||||||
[+] Оптимизация импорта
|
[+] Оптимизация импорта, ускорена работа меню
|
||||||
[+] Новый Проигрыватель BTclient (https://github.com/izderadicka/btclient) в тестовом режиме.
|
[+] Новый Проигрыватель [url=https://github.com/izderadicka/btclient]BTclient[/url] в тестовом режиме, требует python-libtorrent >=1.0.4.
|
||||||
|
|
||||||
[B]Version 2.3.5[/B]
|
[B]Version 2.3.5[/B]
|
||||||
[+] Проигрыватель: Уменьшена просадка после загрузки буфера
|
[+] Проигрыватель: Уменьшена просадка после загрузки буфера
|
||||||
|
|
Loading…
Reference in New Issue