1.0.5 fix

pull/1/head
DiMartinoXBMC 2015-07-23 18:23:22 +03:00
parent 0ef9b6ab9b
commit c807d5ffc2
4 changed files with 31 additions and 51 deletions

12
Core.py
View File

@ -1247,8 +1247,6 @@ class Core:
if url: if url:
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)
if not torrent: torrent = Downloader.Torrent(self.userStorageDirectory,
torrentFilesDirectory=self.torrentFilesDirectory)
self.__settings__.setSetting("lastTorrent", torrent.saveTorrent(url)) self.__settings__.setSetting("lastTorrent", torrent.saveTorrent(url))
contentList = [] contentList = []
for filedict in torrent.getContentList(): for filedict in torrent.getContentList():
@ -1330,11 +1328,7 @@ class Core:
ind = get("url") ind = get("url")
icon = get("thumbnail") if get("thumbnail") else '' icon = get("thumbnail") if get("thumbnail") else ''
path = torrent.getFilePath(int(ind)) path = torrent.getFilePath(int(ind))
label = os.path.basename(path) label = unquote(get("label"), os.path.basename(path))
try:
label = urllib.unquote_plus(get("label"))
except:
print 'except'
torrent.play_url_ind(int(ind), label, icon) torrent.play_url_ind(int(ind), label, icon)
torrent.__exit__() torrent.__exit__()
__ASsettings__.setSetting("folder", folder) __ASsettings__.setSetting("folder", folder)
@ -1364,12 +1358,10 @@ class Core:
def playSTRM(self, params={}): def playSTRM(self, params={}):
get = params.get get = params.get
xbmc.executebuiltin('xbmc.Playlist.Clear') xbmc.executebuiltin('xbmc.Playlist.Clear')
url = unquote(get("url"),None) url = unquote(get("url"), None)
if url: if url:
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)
if not torrent: torrent = Downloader.Torrent(self.userStorageDirectory,
torrentFilesDirectory=self.torrentFilesDirectory)
self.__settings__.setSetting("lastTorrent", torrent.saveTorrent(url)) self.__settings__.setSetting("lastTorrent", torrent.saveTorrent(url))
contentList = [] contentList = []
for filedict in torrent.getContentList(): for filedict in torrent.getContentList():

View File

@ -123,7 +123,7 @@ class Libtorrent:
xbmcvfs.mkdirs(self.torrentFilesPath) xbmcvfs.mkdirs(self.torrentFilesPath)
newFile = self.torrentFilesPath + self.md5(baseName) + '.' + self.md5( newFile = self.torrentFilesPath + self.md5(baseName) + '.' + self.md5(
torrentUrl) + '.torrent' # + '.'+ baseName torrentUrl) + '.torrent' # + '.'+ baseName
if not xbmcvfs.exists(newFile): if xbmcvfs.exists(newFile):
xbmcvfs.delete(newFile) xbmcvfs.delete(newFile)
if not xbmcvfs.exists(newFile): if not xbmcvfs.exists(newFile):
try: try:
@ -328,33 +328,17 @@ class Libtorrent:
#self.session.add_extension("smart_ban") #self.session.add_extension("smart_ban")
# Session settings # Session settings
session_settings = self.session.settings() #session_settings = self.session.settings()
#
session_settings.announce_to_all_tiers = True #session_settings.announce_to_all_tiers = True
session_settings.announce_to_all_trackers = True #session_settings.announce_to_all_trackers = True
session_settings.connection_speed = 100 #session_settings.connection_speed = 100
session_settings.peer_connect_timeout = 2 #session_settings.peer_connect_timeout = 2
session_settings.rate_limit_ip_overhead = True #session_settings.rate_limit_ip_overhead = True
session_settings.request_timeout = 5 #session_settings.request_timeout = 5
session_settings.torrent_connect_boost = 100 #session_settings.torrent_connect_boost = 100
#
#libtorrent 0.15 compability #self.session.set_settings(session_settings)
#session_settings = self.session.get_settings()
#session_settings['announce_to_all_tiers'] = True
#session_settings['announce_to_all_trackers'] = True
#session_settings['connection_speed'] = 100
#session_settings['peer_connect_timeout'] = 2
#session_settings['rate_limit_ip_overhead'] = True
#session_settings['request_timeout'] = 5
#session_settings['torrent_connect_boost'] = 100
#tribler example never tested
#session_settings['user_agent'] = 'python_client/' + self.lt.version
#session_settings['auto_manage_startup'] = 30
#session_settings['auto_manage_interval'] = 30
#session_settings['dht_announce_interval'] = 60
self.session.set_settings(session_settings)
def encryptSession(self): def encryptSession(self):
# Encryption settings # Encryption settings
@ -375,14 +359,16 @@ class Libtorrent:
if None == self.magnetLink: if None == self.magnetLink:
self.torrentHandle = self.session.add_torrent({'ti': self.torrentFileInfo, self.torrentHandle = self.session.add_torrent({'ti': self.torrentFileInfo,
'save_path': self.storageDirectory, 'save_path': self.storageDirectory,
'flags': 0x300, #'flags': 0x300,
# 'storage_mode': self.lt.storage_mode_t.storage_mode_allocate, 'paused': False,
'auto_managed': False,
'storage_mode': self.lt.storage_mode_t.storage_mode_allocate,
}) })
else: else:
self.torrentFileInfo = self.getMagnetInfo() self.torrentFileInfo = self.getMagnetInfo()
self.torrentHandle.set_sequential_download(True) self.torrentHandle.set_sequential_download(True)
#self.torrentHandle.set_max_connections(60) self.torrentHandle.set_max_connections(60)
#self.torrentHandle.set_max_uploads(-1) self.torrentHandle.set_max_uploads(-1)
self.stopSession() self.stopSession()
def stopSession(self): def stopSession(self):
@ -400,7 +386,7 @@ class Libtorrent:
self.endPart = int((selectedFileInfo['offset'] + selectedFileInfo['size']) / self.piece_length) self.endPart = int((selectedFileInfo['offset'] + selectedFileInfo['size']) / self.piece_length)
# print 'part ' + str(self.startPart)+ str(' ')+ str(self.endPart) # print 'part ' + str(self.startPart)+ str(' ')+ str(self.endPart)
multiplier = self.partOffset / 5 multiplier = self.partOffset / 5
print 'continueSession: multiplier ' + str(multiplier) log('continueSession: multiplier ' + str(multiplier))
for i in range(self.startPart, self.startPart + self.partOffset): for i in range(self.startPart, self.startPart + self.partOffset):
if i <= self.endPart: if i <= self.endPart:
self.torrentHandle.piece_priority(i, 7) self.torrentHandle.piece_priority(i, 7)
@ -446,11 +432,12 @@ class Libtorrent:
state_str = ['queued', 'checking', 'downloading metadata', state_str = ['queued', 'checking', 'downloading metadata',
'downloading', 'finished', 'seeding', 'allocating'] 'downloading', 'finished', 'seeding', 'allocating']
print '[%s] %.2f%% complete (down: %.1f kb/s up: %.1f kB/s peers: %d) %s' % \ log('[%s] %.2f%% complete (down: %.1f kb/s up: %.1f kB/s peers: %d) %s' % \
(self.lt.version, s.progress * 100, s.download_rate / 1000, (self.lt.version, s.progress * 100, s.download_rate / 1000,
s.upload_rate / 1000, s.upload_rate / 1000,
s.num_peers, state_str[s.state]) s.num_peers, state_str[s.state]))
i = 0 debug('TRACKERS:' +str(self.torrentHandle.trackers()))
#i = 0
# for t in s.pieces: # for t in s.pieces:
# if t: i=i+1 # if t: i=i+1
# print str(self.session.pop_alert()) # print str(self.session.pop_alert())

View File

@ -134,6 +134,7 @@ class TorrentPlayer(xbmc.Player):
seeding_run = False seeding_run = False
ids_video = None ids_video = None
episodeId = None episodeId = None
basename = ''
def __init__(self, userStorageDirectory, torrentUrl, params={}): def __init__(self, userStorageDirectory, torrentUrl, params={}):
self.userStorageDirectory = userStorageDirectory self.userStorageDirectory = userStorageDirectory
@ -425,10 +426,11 @@ class TorrentPlayer(xbmc.Player):
] ]
def db_delete(self): def db_delete(self):
db = DownloadDB() if self.basename:
get = db.get(self.basename) db = DownloadDB()
if get: get = db.get(self.basename)
db.delete(get[0]) if get:
db.delete(get[0])
def seed(self, contentId): def seed(self, contentId):
self.db_delete() self.db_delete()

View File

@ -55,7 +55,6 @@ userStorageDirectory = __settings__.getSetting("storage")
USERAGENT = "Mozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/20100101 Firefox/5.0" USERAGENT = "Mozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/20100101 Firefox/5.0"
__addonpath__ = __settings__.getAddonInfo('path') __addonpath__ = __settings__.getAddonInfo('path')
icon = __addonpath__ + '/icon.png' icon = __addonpath__ + '/icon.png'
debug = __settings__.getSetting("debug")
__version__ = __settings__.getAddonInfo('version') __version__ = __settings__.getAddonInfo('version')
__plugin__ = __settings__.getAddonInfo('name') + " v." + __version__ __plugin__ = __settings__.getAddonInfo('name') + " v." + __version__