Anteoloader и Inposloader разделены
parent
9e588e5e9c
commit
622c4dc3e7
|
@ -40,16 +40,16 @@ from contextlib import contextmanager, closing, nested
|
||||||
|
|
||||||
from functions import foldername, showMessage, clearStorage, WatchedHistoryDB, get_ids_video, log, debug, ensure_str
|
from functions import foldername, showMessage, clearStorage, WatchedHistoryDB, get_ids_video, log, debug, ensure_str
|
||||||
|
|
||||||
if sys.modules["__main__"].__settings__.getSetting("torrent_player") == '2':
|
#if sys.modules["__main__"].__settings__.getSetting("torrent_player") == '2':
|
||||||
from torrent2http import State, Engine, MediaType
|
from torrent2http import State, Engine, MediaType
|
||||||
author = 'Anteo'
|
author = 'Anteo'
|
||||||
__settings__ = xbmcaddon.Addon(id='script.module.torrent2http')
|
__settings__ = xbmcaddon.Addon(id='script.module.torrent2http')
|
||||||
__version__ = __settings__.getAddonInfo('version')
|
__version__ = __settings__.getAddonInfo('version')
|
||||||
elif sys.modules["__main__"].__settings__.getSetting("torrent_player") == '3':
|
#elif sys.modules["__main__"].__settings__.getSetting("torrent_player") == '3':
|
||||||
from pyrrent2http import State, Engine, MediaType
|
# from pyrrent2http import State, Engine, MediaType
|
||||||
author = 'Inpos'
|
# author = 'Inpos'
|
||||||
__settings__ = xbmcaddon.Addon(id='script.module.pyrrent2http')
|
# __settings__ = xbmcaddon.Addon(id='script.module.pyrrent2http')
|
||||||
__version__ = __settings__.getAddonInfo('version')
|
# __version__ = __settings__.getAddonInfo('version')
|
||||||
|
|
||||||
ROOT = sys.modules["__main__"].__root__
|
ROOT = sys.modules["__main__"].__root__
|
||||||
RESOURCES_PATH = os.path.join(ROOT, 'resources')
|
RESOURCES_PATH = os.path.join(ROOT, 'resources')
|
||||||
|
@ -613,9 +613,9 @@ class AnteoPlayer(xbmc.Player):
|
||||||
def _get_status_lines(self, s, f):
|
def _get_status_lines(self, s, f):
|
||||||
return [
|
return [
|
||||||
localize_path(self.display_name),
|
localize_path(self.display_name),
|
||||||
"%.2f%% %s" % (f.progress * 100, self.localize(STATE_STRS[s.state])),
|
"%.2f%% %s" % (f.progress * 100, self.localize(STATE_STRS[s.state]).decode('utf-8')),
|
||||||
"D:%.2f%s U:%.2f%s S:%d P:%d" % (s.download_rate, self.localize('kb/s'),
|
"D:%.2f%s U:%.2f%s S:%d P:%d" % (s.download_rate, self.localize('kb/s').decode('utf-8'),
|
||||||
s.upload_rate, self.localize('kb/s'),
|
s.upload_rate, self.localize('kb/s').decode('utf-8'),
|
||||||
s.num_seeds, s.num_peers)
|
s.num_seeds, s.num_peers)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
8
Core.py
8
Core.py
|
@ -1391,12 +1391,18 @@ class Core:
|
||||||
self.Player = TorrentPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params)
|
self.Player = TorrentPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params)
|
||||||
else:
|
else:
|
||||||
log(self.__plugin__ + " Unexpected access to method playTorrent() without torrent content")
|
log(self.__plugin__ + " Unexpected access to method playTorrent() without torrent content")
|
||||||
elif self.torrent_player == '2' or self.torrent_player == '3':
|
elif self.torrent_player == '2':
|
||||||
from Anteoloader import AnteoPlayer
|
from Anteoloader import AnteoPlayer
|
||||||
if 0 != len(torrentUrl):
|
if 0 != len(torrentUrl):
|
||||||
self.Player = AnteoPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params)
|
self.Player = AnteoPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params)
|
||||||
else:
|
else:
|
||||||
log(self.__plugin__ + " Unexpected access to method playTorrent() without torrent content")
|
log(self.__plugin__ + " Unexpected access to method playTorrent() without torrent content")
|
||||||
|
elif self.torrent_player == '3':
|
||||||
|
from Inposloader import InposPlayer
|
||||||
|
if 0 != len(torrentUrl):
|
||||||
|
self.Player = InposPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params)
|
||||||
|
else:
|
||||||
|
log(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")
|
||||||
|
|
|
@ -24,6 +24,7 @@ import sys
|
||||||
import Libtorrent
|
import Libtorrent
|
||||||
import AceStream
|
import AceStream
|
||||||
import Anteoloader
|
import Anteoloader
|
||||||
|
import Inposloader
|
||||||
from functions import log
|
from functions import log
|
||||||
|
|
||||||
class Torrent():
|
class Torrent():
|
||||||
|
@ -40,6 +41,9 @@ class Torrent():
|
||||||
elif self.player == 'anteo':
|
elif self.player == 'anteo':
|
||||||
self.player = Anteoloader.AnteoLoader(storageDirectory, torrentFile, torrentFilesDirectory)
|
self.player = Anteoloader.AnteoLoader(storageDirectory, torrentFile, torrentFilesDirectory)
|
||||||
|
|
||||||
|
elif self.player == 'inpos':
|
||||||
|
self.player = Inposloader.InposLoader(storageDirectory, torrentFile, torrentFilesDirectory)
|
||||||
|
|
||||||
def __exit__(self):
|
def __exit__(self):
|
||||||
self.player.__exit__()
|
self.player.__exit__()
|
||||||
|
|
||||||
|
@ -49,8 +53,10 @@ class Torrent():
|
||||||
self.player = 'libtorrent'
|
self.player = 'libtorrent'
|
||||||
elif player == '1':
|
elif player == '1':
|
||||||
self.player = 'acestream'
|
self.player = 'acestream'
|
||||||
elif player == '2' or player == '3':
|
elif player == '2':
|
||||||
self.player = 'anteo'
|
self.player = 'anteo'
|
||||||
|
elif player == '3':
|
||||||
|
self.player = 'inpos'
|
||||||
|
|
||||||
def play_url_ind(self, ind, label, icon):
|
def play_url_ind(self, ind, label, icon):
|
||||||
return self.player.play_url_ind(int(ind), label, str(icon))
|
return self.player.play_url_ind(int(ind), label, str(icon))
|
||||||
|
|
|
@ -40,12 +40,12 @@ from contextlib import contextmanager, closing, nested
|
||||||
|
|
||||||
from functions import foldername, showMessage, clearStorage, WatchedHistoryDB, get_ids_video, log, debug, ensure_str
|
from functions import foldername, showMessage, clearStorage, WatchedHistoryDB, get_ids_video, log, debug, ensure_str
|
||||||
|
|
||||||
if sys.modules["__main__"].__settings__.getSetting("torrent_player") == '2':
|
#if sys.modules["__main__"].__settings__.getSetting("torrent_player") == '2':
|
||||||
from torrent2http import State, Engine, MediaType
|
# from torrent2http import State, Engine, MediaType
|
||||||
author = 'Anteo'
|
# author = 'Anteo'
|
||||||
__settings__ = xbmcaddon.Addon(id='script.module.torrent2http')
|
# __settings__ = xbmcaddon.Addon(id='script.module.torrent2http')
|
||||||
__version__ = __settings__.getAddonInfo('version')
|
# __version__ = __settings__.getAddonInfo('version')
|
||||||
elif sys.modules["__main__"].__settings__.getSetting("torrent_player") == '3':
|
#elif sys.modules["__main__"].__settings__.getSetting("torrent_player") == '3':
|
||||||
from pyrrent2http import State, Engine, MediaType
|
from pyrrent2http import State, Engine, MediaType
|
||||||
author = 'Inpos'
|
author = 'Inpos'
|
||||||
__settings__ = xbmcaddon.Addon(id='script.module.pyrrent2http')
|
__settings__ = xbmcaddon.Addon(id='script.module.pyrrent2http')
|
||||||
|
@ -94,7 +94,7 @@ class Encryption:
|
||||||
ENABLED = 1
|
ENABLED = 1
|
||||||
DISABLED = 2
|
DISABLED = 2
|
||||||
|
|
||||||
class AnteoLoader:
|
class InposLoader:
|
||||||
magnetLink = None
|
magnetLink = None
|
||||||
engine = None
|
engine = None
|
||||||
torrentFile = None
|
torrentFile = None
|
||||||
|
@ -152,16 +152,11 @@ class AnteoLoader:
|
||||||
return string
|
return string
|
||||||
|
|
||||||
def getContentList(self):
|
def getContentList(self):
|
||||||
try:
|
|
||||||
from Libtorrent import Libtorrent
|
from Libtorrent import Libtorrent
|
||||||
torrent = Libtorrent(self.storageDirectory, self.torrentFile)
|
torrent = Libtorrent(self.storageDirectory, self.torrentFile)
|
||||||
return torrent.getContentList()
|
return torrent.getContentList()
|
||||||
except:
|
|
||||||
import traceback
|
|
||||||
log(traceback.format_exc())
|
|
||||||
return self.getContentList_engine()
|
|
||||||
|
|
||||||
def getContentList_engine(self):
|
'''def getContentList_engine(self):
|
||||||
self.setup_engine()
|
self.setup_engine()
|
||||||
files = []
|
files = []
|
||||||
filelist = []
|
filelist = []
|
||||||
|
@ -197,7 +192,7 @@ class AnteoLoader:
|
||||||
log(traceback.format_exc())
|
log(traceback.format_exc())
|
||||||
finally:
|
finally:
|
||||||
self.engine.close()
|
self.engine.close()
|
||||||
return filelist
|
return filelist'''
|
||||||
|
|
||||||
def saveTorrent(self, torrentUrl):
|
def saveTorrent(self, torrentUrl):
|
||||||
#if not xbmcvfs.exists(torrentUrl) or re.match("^http.+$", torrentUrl):
|
#if not xbmcvfs.exists(torrentUrl) or re.match("^http.+$", torrentUrl):
|
||||||
|
@ -228,7 +223,7 @@ class AnteoLoader:
|
||||||
localFile.write(content)
|
localFile.write(content)
|
||||||
localFile.close()
|
localFile.close()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log('Unable to rename torrent file from %s to %s in AnteoLoader::saveTorrent. Exception: %s' %
|
log('Unable to rename torrent file from %s to %s in InposLoader::saveTorrent. Exception: %s' %
|
||||||
(torrentUrl, torrentFile, str(e)))
|
(torrentUrl, torrentFile, str(e)))
|
||||||
return
|
return
|
||||||
if xbmcvfs.exists(torrentFile) and not os.path.exists(torrentFile):
|
if xbmcvfs.exists(torrentFile) and not os.path.exists(torrentFile):
|
||||||
|
@ -257,7 +252,7 @@ class AnteoLoader:
|
||||||
self.torrentFile = magnet
|
self.torrentFile = magnet
|
||||||
log('['+author+'Loader][magnetToTorrent]: self.torrentFile '+str(self.torrentFile))
|
log('['+author+'Loader][magnetToTorrent]: self.torrentFile '+str(self.torrentFile))
|
||||||
|
|
||||||
class AnteoPlayer(xbmc.Player):
|
class InposPlayer(xbmc.Player):
|
||||||
__plugin__ = sys.modules["__main__"].__plugin__
|
__plugin__ = sys.modules["__main__"].__plugin__
|
||||||
__settings__ = sys.modules["__main__"].__settings__
|
__settings__ = sys.modules["__main__"].__settings__
|
||||||
ROOT = sys.modules["__main__"].__root__
|
ROOT = sys.modules["__main__"].__root__
|
||||||
|
@ -539,7 +534,7 @@ class AnteoPlayer(xbmc.Player):
|
||||||
file_status = self.engine.file_status(self.contentId)
|
file_status = self.engine.file_status(self.contentId)
|
||||||
subs = []
|
subs = []
|
||||||
filename = os.path.basename(file_status.name)
|
filename = os.path.basename(file_status.name)
|
||||||
sub_files = self.engine.list(media_types=[MediaType.SUBTITLES])
|
sub_files = self.engine.list_from_info(media_types=[MediaType.SUBTITLES])
|
||||||
for i in sub_files:
|
for i in sub_files:
|
||||||
if isSubtitle(filename, i.name):
|
if isSubtitle(filename, i.name):
|
||||||
subs.append(i)
|
subs.append(i)
|
||||||
|
@ -649,14 +644,14 @@ class AnteoPlayer(xbmc.Player):
|
||||||
|
|
||||||
def get_ids(self):
|
def get_ids(self):
|
||||||
contentList = []
|
contentList = []
|
||||||
for fs in self.engine.list():
|
for fs in self.engine.list_from_info():
|
||||||
contentList.append((fs.name, str(fs.index)))
|
contentList.append((fs.name, str(fs.index)))
|
||||||
contentList = sorted(contentList, key=lambda x: x[0])
|
contentList = sorted(contentList, key=lambda x: x[0])
|
||||||
return get_ids_video(contentList)
|
return get_ids_video(contentList)
|
||||||
|
|
||||||
def getContentList(self):
|
def getContentList(self):
|
||||||
filelist = []
|
filelist = []
|
||||||
for fs in self.engine.list():
|
for fs in self.engine.list_from_info():
|
||||||
stringdata = {"title": ensure_str(fs.name), "size": fs.size, "ind": fs.index,
|
stringdata = {"title": ensure_str(fs.name), "size": fs.size, "ind": fs.index,
|
||||||
'offset': fs.offset}
|
'offset': fs.offset}
|
||||||
filelist.append(stringdata)
|
filelist.append(stringdata)
|
||||||
|
|
Loading…
Reference in New Issue