pull/1/head
DiMartinoXBMC 2015-08-02 19:41:19 +03:00
parent b239e74bff
commit c38b65c643
10 changed files with 52 additions and 29 deletions

View File

@ -365,14 +365,15 @@ class BTClientPlayer(xbmc.Player):
self.display_name = label self.display_name = label
base = 'http://127.0.0.1:' + str(self.free_port) + '/' base = 'http://127.0.0.1:' + str(self.free_port) + '/'
url = urlparse.urljoin(base, urllib.quote(path)) url = urlparse.urljoin(base, urllib.quote(self.c._file.path))
# мегакостыль! # мегакостыль!
rpc = ({'jsonrpc': '2.0', 'method': 'Files.GetDirectory', 'params': { rpc = ({'jsonrpc': '2.0', 'method': 'Files.GetDirectory', 'params': {
'media': 'video', 'directory': os.path.dirname(path)}, 'id': 0}) 'media': 'video', 'directory': path}, 'id': 0})
data = json.dumps(rpc) data = json.dumps(rpc)
request = xbmc.executeJSONRPC(data) request = xbmc.executeJSONRPC(data)
response = json.loads(request) response = json.loads(request)
xbmc.sleep(300) while not response:
xbmc.sleep(100)
if response: if response:
playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
playlist.clear() playlist.clear()

57
Core.py
View File

@ -11,7 +11,7 @@
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the#
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
@ -26,12 +26,7 @@ import xbmcaddon
import xbmcgui import xbmcgui
import xbmcplugin import xbmcplugin
import xbmcvfs import xbmcvfs
import Content
from Player import TorrentPlayer
from functions import * from functions import *
from resources.utorrent.net import *
from resources.scrapers.scrapers import Scrapers
from resources.skins.DialogXml import *
from platform_pulsar import get_platform from platform_pulsar import get_platform
@ -136,7 +131,7 @@ class Core:
image=self.ROOT + '/icons/magnet.png') image=self.ROOT + '/icons/magnet.png')
if self.debug: if self.debug:
self.drawItem('full_download', 'full_download', image=self.ROOT + '/icons/magnet.png') self.drawItem('full_download', 'full_download', image=self.ROOT + '/icons/magnet.png')
self.drawItem('test', 'test', image=self.ROOT + '/icons/magnet.png') self.drawItem('test', 'test', image=self.ROOT + '/icons/magnet.png', isFolder=False)
if '0' != self.__settings__.getSetting("keep_files"): if '0' != self.__settings__.getSetting("keep_files"):
self.drawItem('< %s >' % self.localize('Clear Storage'), 'clearStorage', isFolder=True, self.drawItem('< %s >' % self.localize('Clear Storage'), 'clearStorage', isFolder=True,
@ -273,18 +268,23 @@ class Core:
lockView('wide') lockView('wide')
def test(self, params={}): def test(self, params={}):
#db=DownloadDB() from BTClientPlayer import BTClientPlayer
#db.add(u'XXX2', 'file', json.dumps({'seeds':1,'leechers':1}), 20) torrentUrl='D:\\ntest.torrent'
#url='magnet:?xt=urn:btih:6698E0950DCD257A6B03AF2E8B068B7FF9D4619D&dn=game+of+thrones+season+2+720p+bluray+x264+shaanig&tr=udp%3A%2F%2Fcoppersurfer.tk%3A6969%2Fannounce&tr=udp%3A%2F%2Fopen.demonii.com%3A1337' params['url']='0'
#filename='D:\\torrents\\Torrenter\\torrents\\Jimmy.Fallon.2015.01.09.Don.Cheadle.HDTV.x264-CROOKS.mp4.torrent' if not xbmcvfs.exists(torrentUrl):
#torrent = Downloader.Torrent(self.userStorageDirectory, torrentFilesDirectory=self.torrentFilesDirectory) action = xbmcgui.Dialog()
#self.__settings__.setSetting("lastTorrent", torrent.saveTorrent(filename)) torrentUrl = action.browse(1, self.localize('Choose .torrent in video library'), 'video', '.torrent')
#torrent.downloadProcess() if torrentUrl and xbmcvfs.exists(torrentUrl):
#self.DownloadStatus() if 0 != len(torrentUrl):
url='http://torcache.net/torrent/6698E0950DCD257A6B03AF2E8B068B7FF9D4619D.torrent?title=[kickass.to]game.of.thrones.season.2.720p.bluray.x264.shaanig' self.Player = BTClientPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params)
#xbmc.executebuiltin('xbmc.RunPlugin("plugin://plugin.video.torrenter/?action=openTorrent&external=ThePirateBaySe&url=ThePirateBaySe%3A%3A'+urllib.quote_plus(url)+'&not_download_only=True")') else:
#print str(Searchers().list()) print self.__plugin__ + " Unexpected access to method playTorrent() without torrent content"
first_run_230(False) #path='http://127.0.0.1:5001/Inception.2010.1080p.BluRay.x264.5xRus.Eng-Otaibi.mkv'
#listitem = xbmcgui.ListItem('Inception.2010.1080p.BluRay.x264.5xRus.Eng-Otaibi.mkv', path=path)
#playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
#playlist.clear()
#playlist.add(path, listitem)
#xbmc.Player().play(playlist)
def DownloadStatus(self, params={}): def DownloadStatus(self, params={}):
db = DownloadDB() db = DownloadDB()
@ -592,6 +592,7 @@ class Core:
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=True) xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=True)
def openContent(self, params={}): def openContent(self, params={}):
import Content
self.contenterObject = {} self.contenterObject = {}
self.Content = Content.Content() self.Content = Content.Content()
self.Contenters = Contenters() self.Contenters = Contenters()
@ -675,6 +676,7 @@ class Core:
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=True) xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=True)
def full_download(self, params={}): def full_download(self, params={}):
import Content
self.contenterObject = {} self.contenterObject = {}
self.Content = Content.Content() self.Content = Content.Content()
self.Contenters = Contenters() self.Contenters = Contenters()
@ -759,6 +761,7 @@ class Core:
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=True) xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=True)
def drawcontentList(self, contentList, params={}): def drawcontentList(self, contentList, params={}):
from resources.scrapers.scrapers import Scrapers
contentList = sorted(contentList, key=lambda x: x[0], reverse=True) contentList = sorted(contentList, key=lambda x: x[0], reverse=True)
self.Scraper = Scrapers() self.Scraper = Scrapers()
progressBar = xbmcgui.DialogProgress() progressBar = xbmcgui.DialogProgress()
@ -926,6 +929,7 @@ class Core:
#self.drawItem(title, 'openTorrent', link, img, info=info, contextMenu=contextMenu, replaceMenu=False) #self.drawItem(title, 'openTorrent', link, img, info=info, contextMenu=contextMenu, replaceMenu=False)
def ActionInfo(self, params={}): def ActionInfo(self, params={}):
from resources.skins.DialogXml import DialogXml
get = params.get get = params.get
contenter=get('provider') contenter=get('provider')
infolink=get('url') infolink=get('url')
@ -1058,6 +1062,7 @@ class Core:
self.sectionMenu() self.sectionMenu()
def uTorrentBrowser(self, params={}): def uTorrentBrowser(self, params={}):
from resources.utorrent.net import Download
menu, dirs = [], [] menu, dirs = [], []
contextMenustring = 'XBMC.RunPlugin(%s)' % ('%s?action=%s&url=%s') % (sys.argv[0], 'uTorrentBrowser', '%s') contextMenustring = 'XBMC.RunPlugin(%s)' % ('%s?action=%s&url=%s') % (sys.argv[0], 'uTorrentBrowser', '%s')
get = params.get get = params.get
@ -1312,10 +1317,17 @@ class Core:
torrentUrl = self.__settings__.getSetting("lastTorrent") torrentUrl = self.__settings__.getSetting("lastTorrent")
self.userStorage(params) self.userStorage(params)
if self.torrent_player == '0': if self.torrent_player == '0':
from Player import TorrentPlayer
if 0 != len(torrentUrl): if 0 != len(torrentUrl):
self.Player = TorrentPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params) self.Player = TorrentPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params)
else: else:
print self.__plugin__ + " Unexpected access to method playTorrent() without torrent content" print self.__plugin__ + " Unexpected access to method playTorrent() without torrent content"
elif self.torrent_player == '2':
from BTClientPlayer import BTClientPlayer
if 0 != len(torrentUrl):
self.Player = BTClientPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params)
else:
print self.__plugin__ + " Unexpected access to method playTorrent() without torrent content"
elif self.torrent_player == '1': elif self.torrent_player == '1':
__ASsettings__ = xbmcaddon.Addon(id='script.module.torrent.ts') __ASsettings__ = xbmcaddon.Addon(id='script.module.torrent.ts')
folder=__ASsettings__.getSetting("folder") folder=__ASsettings__.getSetting("folder")
@ -1596,6 +1608,7 @@ class Core:
return return
def downloadFilesList(self, params={}): def downloadFilesList(self, params={}):
from resources.utorrent.net import Download
dirname = None dirname = None
dat = Download().listdirs() dat = Download().listdirs()
if dat == False: if dat == False:
@ -1667,7 +1680,7 @@ class Core:
if success: if success:
showMessage(self.localize('Torrent-client Browser'), self.localize('Added!'), forced=True) showMessage(self.localize('Torrent-client Browser'), self.localize('Added!'), forced=True)
if ind: if ind:
id = self.chooseHASH()[0] id = self.chooseHASH(Download().list())[0]
Download().setprio(id, ind) Download().setprio(id, ind)
def downloadLibtorrent(self, params={}): def downloadLibtorrent(self, params={}):
@ -1744,10 +1757,10 @@ class Core:
else: else:
self.openSection(params) self.openSection(params)
def chooseHASH(self): def chooseHASH(self, list):
dialog_items, dialog_items_clean = [], [] dialog_items, dialog_items_clean = [], []
dialog_files = [] dialog_files = []
dat = Download().list() dat = list
if dat == False: if dat == False:
showMessage(self.localize('Error'), self.localize('No connection! Check settings!'), forced=True) showMessage(self.localize('Error'), self.localize('No connection! Check settings!'), forced=True)
return return

View File

@ -41,7 +41,7 @@ class Torrent():
def get_torrent_client(self): def get_torrent_client(self):
player = self.__settings__.getSetting("torrent_player") player = self.__settings__.getSetting("torrent_player")
if player == '0': if player in ['0','2']:
self.player = 'libtorrent' self.player = 'libtorrent'
elif player == '1': elif player == '1':
self.player = 'acestream' self.player = 'acestream'

View File

@ -61,12 +61,14 @@ class Libtorrent:
from python_libtorrent import get_libtorrent from python_libtorrent import get_libtorrent
libtorrent=get_libtorrent() libtorrent=get_libtorrent()
log('Imported libtorrent v%s from python_libtorrent/%s' %(libtorrent.version, self.platform['system'])) log('Imported libtorrent v%s from python_libtorrent/%s' %(libtorrent.version, self.platform['system']))
module=True
except Exception, e: except Exception, e:
module=False
log('Error importing python_libtorrent.%s. Exception: %s' %(self.platform['system'], str(e))) log('Error importing python_libtorrent.%s. Exception: %s' %(self.platform['system'], str(e)))
import libtorrent import libtorrent
try: try:
log('Imported libtorrent v' + libtorrent.version + ' from system') if not module: log('Imported libtorrent v' + libtorrent.version + ' from system')
self.lt = libtorrent self.lt = libtorrent
del libtorrent del libtorrent

View File

@ -3,6 +3,7 @@
<requires> <requires>
<import addon="xbmc.python" version="2.1.0"/> <import addon="xbmc.python" version="2.1.0"/>
<import addon="script.module.libtorrent"/> <import addon="script.module.libtorrent"/>
<import addon="script.module.btclient"/>
<import addon="script.module.torrent.ts"/> <import addon="script.module.torrent.ts"/>
</requires> </requires>
<extension point="xbmc.python.pluginsource" provides="video" library="default.py"> <extension point="xbmc.python.pluginsource" provides="video" library="default.py">

View File

@ -1,5 +1,9 @@
English changelog at http://bit.ly/1MfSVUP English changelog at http://bit.ly/1MfSVUP
[B]Version 2.3.6[/B]
[+] Оптимизация импорта
[+] Новый Проигрыватель BTclient (https://github.com/izderadicka/btclient) в тестовом режиме.
[B]Version 2.3.5[/B] [B]Version 2.3.5[/B]
[+] Проигрыватель: Уменьшена просадка после загрузки буфера [+] Проигрыватель: Уменьшена просадка после загрузки буфера
[+] Проигрыватель: Проверка на запись хранилища [+] Проигрыватель: Проверка на запись хранилища

View File

@ -36,7 +36,6 @@ import xbmc
import xbmcaddon import xbmcaddon
import xbmcvfs import xbmcvfs
import Localization import Localization
from resources.scrapers.scrapers import Scrapers
try: try:
from hashlib import md5 from hashlib import md5
@ -1265,6 +1264,7 @@ class Contenters():
pass pass
def first_time(self, scrapperDB_ver, language='ru'): def first_time(self, scrapperDB_ver, language='ru'):
from resources.scrapers.scrapers import Scrapers
searcher = 'metadata' searcher = 'metadata'
redl = False redl = False
scrapperDB_ver = scrapperDB_ver[language] scrapperDB_ver = scrapperDB_ver[language]

View File

@ -43,6 +43,7 @@
<string id="30043">Delete files</string> <string id="30043">Delete files</string>
<string id="30044">Save files</string> <string id="30044">Save files</string>
<string id="30045">Ask to save</string> <string id="30045">Ask to save</string>
<string id="30046">BTclient (python-libtorrent via http)</string>
<string id="30101">Interface</string> <string id="30101">Interface</string>
<string id="30102">P2P Network</string> <string id="30102">P2P Network</string>
<string id="30103">Advanced</string> <string id="30103">Advanced</string>

View File

@ -43,6 +43,7 @@
<string id="30043">Удалять файлы</string> <string id="30043">Удалять файлы</string>
<string id="30044">Сохранять файлы</string> <string id="30044">Сохранять файлы</string>
<string id="30045">Спросить о сохранении</string> <string id="30045">Спросить о сохранении</string>
<string id="30046">BTclient (python-libtorrent по http)</string>
<string id="30101">Интерфейс</string> <string id="30101">Интерфейс</string>
<string id="30102">P2P Сеть</string> <string id="30102">P2P Сеть</string>
<string id="30103">Дополнительные</string> <string id="30103">Дополнительные</string>

View File

@ -16,7 +16,7 @@
<setting id="debug" type="bool" label="30015" default="false"/> <setting id="debug" type="bool" label="30015" default="false"/>
</category> </category>
<category label="30102"> <category label="30102">
<setting id="torrent_player" type="enum" label="30023" default="0" lvalues="30021|30022" /> <setting id="torrent_player" type="enum" label="30023" default="0" lvalues="30021|30022|30046" />
<setting id="storage" type="folder" label="30004" default=""/> <setting id="storage" type="folder" label="30004" default=""/>
<setting id="keep_files" type="enum" label="30008" default="1" lvalues="30043|30044|30045"/> <setting id="keep_files" type="enum" label="30008" default="1" lvalues="30043|30044|30045"/>
<setting id="ask_dir" type="bool" label="30031" default="false" enable="!eq(-1,0)" /> <setting id="ask_dir" type="bool" label="30031" default="false" enable="!eq(-1,0)" />