Merge branch 'master-root'

pull/1/head
Sergey Shramchenko 2016-03-07 20:37:59 +02:00
commit cd4bb41550
13 changed files with 556 additions and 538 deletions

File diff suppressed because it is too large Load Diff

View File

@ -39,8 +39,12 @@ from contextlib import contextmanager, closing, nested
from functions import foldername, showMessage, clearStorage, WatchedHistoryDB, get_ids_video, log, debug, ensure_str
from torrent2http import State, Engine, MediaType
#from pyrrent2http import State, Engine, MediaType
if sys.modules["__main__"].__settings__.getSetting("torrent_player") == '2':
from torrent2http import State, Engine, MediaType
author = 'Anteo'
elif sys.modules["__main__"].__settings__.getSetting("torrent_player") == '3':
from pyrrent2http import State, Engine, MediaType
author = 'Inpos'
ROOT = sys.modules["__main__"].__root__
RESOURCES_PATH = os.path.join(ROOT, 'resources')

View File

@ -35,7 +35,7 @@ class Core:
userStorageDirectory = file_encode(__settings__.getSetting("storage"))
torrentFilesDirectory = 'torrents'
debug = __settings__.getSetting('debug') == 'true'
torrent_player=__settings__.getSetting("torrent_player")
torrent_player = __settings__.getSetting("torrent_player")
history_bool = __settings__.getSetting('history') == 'true'
open_option = int(__settings__.getSetting('open_option'))
language = {0: 'en', 1: 'ru', 2: 'uk', 3: 'he'}.get(int(__settings__.getSetting("language")))
@ -54,7 +54,7 @@ class Core:
def sectionMenu(self):
if self.__settings__.getSetting('plugin_name') != self.__plugin__:
#Every update run
first_run_242()
first_run_250()
self.__settings__.setSetting('plugin_name', self.__plugin__)
#check_network_advancedsettings()
check_download_dir()
@ -100,7 +100,7 @@ class Core:
image=self.ROOT + '/icons/torrentPlayer.png')
self.drawItem('< %s >' % self.localize('Search Control Window'), 'controlCenter',
image=self.ROOT + '/icons/settings.png', isFolder=False)
self.drawItem('< %s >' % self.localize('Magnet-link Player'), 'magentPlayer',#if self.torrent_player!='1':
self.drawItem('< %s >' % self.localize('Magnet-link Player'), 'magentPlayer',
image=self.ROOT + '/icons/magnet.png')
if self.debug:
self.drawItem('full_download', 'full_download', image=self.ROOT + '/icons/magnet.png')
@ -1413,7 +1413,7 @@ class Core:
self.Player = TorrentPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params)
else:
log(self.__plugin__ + " Unexpected access to method playTorrent() without torrent content")
elif self.torrent_player == '2':
elif self.torrent_player == '2' or self.torrent_player == '3':
from Anteoloader import AnteoPlayer
if 0 != len(torrentUrl):
self.Player = AnteoPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params)

View File

@ -49,7 +49,7 @@ class Torrent():
self.player = 'libtorrent'
elif player == '1':
self.player = 'acestream'
elif player == '2':
elif player == '2' or player == '3':
self.player = 'anteo'
def play_url_ind(self, ind, label, icon):

View File

@ -138,8 +138,8 @@ class Libtorrent:
try:
xbmcvfs.rename(torrentFile, newFile)
except Exception, e:
print 'Unable to rename torrent file from "' + torrentFile + '" to "' + newFile + '" in Torrent::renameTorrent' + '. Exception: ' + str(
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:
@ -436,7 +436,7 @@ class Libtorrent:
else:
resume_file=self.resume_data_path()
if xbmcvfs.exists(resume_file):
log('loading resume data from file'+resume_file)
log('loading resume data from file '+resume_file)
try:
resumDataFile=xbmcvfs.File(resume_file,'rb')
self.save_resume_data=resumDataFile.read()
@ -444,7 +444,7 @@ class Libtorrent:
torrent_info['resume_data']=self.save_resume_data
except:
log(' Failed to load resume data from file'+ resume_file)
log('Failed to load resume data from file '+ resume_file)
self.torrentHandle = self.session.add_torrent(torrent_info)
self.torrentHandle.set_sequential_download(True)
self.torrentHandle.set_max_connections(60)
@ -454,7 +454,6 @@ class Libtorrent:
def stopSession(self):
for i in range(self.torrentFileInfo.num_pieces()):
self.torrentHandle.piece_priority(i, 0)
self.resume_data()
def continueSession(self, contentId=0, Offset=0, seeding=False, isMP4=False):
self.piece_length = self.torrentFileInfo.piece_length()
@ -462,10 +461,8 @@ class Libtorrent:
if not Offset:
Offset = selectedFileInfo['size'] / (1024 * 1024)
self.partOffset = (Offset * 1024 * 1024 / self.piece_length) + 1
# print 'partOffset ' + str(self.partOffset)+str(' ')
self.startPart = selectedFileInfo['offset'] / self.piece_length
self.endPart = int((selectedFileInfo['offset'] + selectedFileInfo['size']) / self.piece_length)
# print 'part ' + str(self.startPart)+ str(' ')+ str(self.endPart)
multiplier = self.partOffset / 5
log('continueSession: multiplier ' + str(multiplier))
for i in range(self.startPart, self.startPart + self.partOffset):
@ -473,13 +470,12 @@ class Libtorrent:
self.torrentHandle.piece_priority(i, 7)
if isMP4 and i % multiplier == 0:
self.torrentHandle.piece_priority(self.endPart - i / multiplier, 7)
# print str(i)
if multiplier >= i:
self.torrentHandle.piece_priority(self.endPart - i, 7)
# print str(i)
def checkThread(self):
if self.threadComplete == True:
self.resume_data()
log('checkThread KIIIIIIIIIIILLLLLLLLLLLLLLL')
try:
self.session.remove_torrent(self.torrentHandle)
@ -535,14 +531,14 @@ class Libtorrent:
def debug(self):
#try:
if 1==1:
# print str(self.getFilePath(0))
# log(str(self.getFilePath(0)))
s = self.torrentHandle.status()
#get_cache_status=self.session.get_cache_status()
#log('get_cache_status - %s/%s' % (str(get_cache_status.blocks_written), str(get_cache_status.blocks_read)))
# get_settings=self.torrentHandle.status
# print s.num_pieces
# log(s.num_pieces)
#priorities = self.torrentHandle.piece_priorities()
#print str(priorities)
#log(str(priorities))
state_str = ['queued', 'checking', 'downloading metadata',
'downloading', 'finished', 'seeding', 'allocating', 'checking fastresume']
@ -564,11 +560,11 @@ class Libtorrent:
#i = 0
# for t in s.pieces:
# if t: i=i+1
#print str(self.session.pop_alert())
# print str(s.pieces[self.startPart:self.endPart])
# print 'True pieces: %d' % i
# print s.current_tracker
# print str(s.pieces)
#log(str(self.session.pop_alert())
# log(str(s.pieces[self.startPart:self.endPart]))
# log('True pieces: %d' % i)
# log(s.current_tracker)
# log(str(s.pieces))
#except:
else:
log('debug error')

View File

@ -539,7 +539,7 @@ def localize(text):
'Please, restart Kodi now!':'Теперь перезагрузите Коди, пожалуйста!',
'./ (Root folder)':'./ (Корневой каталог)',
'Opening torrent file':'Открытие torrent-файла',
'New player to Torrenter v2 - Torrent2HTTP! It should be faster, stable and better with Android, also seeking works in it.':'В Torrenter новый плеер - Torrent2HTTP! Он стабильнее, быстрее и отлично ладит с Android, в нем работает перемотка.',
'New player to Torrenter v2 - pyrrent2http! Advantages of Torrent2HTTP but with python-libtorrent library instead of libtorrent-go!':'В Torrenter новый плеер - pyrrent2http! Преимущества Torrent2HTTP, но на библиотеке python-libtorrent вместо libtorrent-go!',
'Would you like to try it?':'Хотите его попробовать?',
'Torrent2HTTP enabled! Can be changed in Settings.':'Torrent2HTTP включен! Можно изменить в Настройках.',
'Seeking':'Перемотка',

View File

@ -259,7 +259,7 @@ class TorrentPlayer(xbmc.Player):
downloadedSize = self.torrent.torrentHandle.file_progress()[self.contentId]
status = self.torrent.torrentHandle.status()
iterator = int(status.progress * 100)
if status.state == 0 or (status.progress == 0 and status.num_pieces > 0):
if status.state in [0, 1] or (status.progress == 0 and status.num_pieces > 0):
iterator = int(status.num_pieces * 100 / num_pieces)
if iterator > 99: iterator = 99
progressBar.update(iterator, self.localize('Checking preloaded files...'), ' ', ' ')
@ -286,8 +286,6 @@ class TorrentPlayer(xbmc.Player):
self.torrent.checkThread()
return
xbmc.sleep(1000)
#self.torrent.torrentHandle.flush_cache()
#self.torrent.session.remove_torrent(self.torrent.torrentHandle)
self.torrent.resume_data()
#self.torrent.session.remove_torrent(self.torrent.torrentHandle)
progressBar.update(0)

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.torrenter" name="Torrenter" version="2.4.6" provider-name="DiMartino">
<addon id="plugin.video.torrenter" name="Torrenter" version="2.5.0" provider-name="DiMartino">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
<import addon="script.module.libtorrent"/>

View File

@ -1,5 +1,9 @@
English changelog at http://bit.ly/1MfSVUP
[B]Version 2.5.0[/B]
[+] НОВЫЙ проигрыватель pyrrent2http от inpos! Аналог torrent2http написаный на python, а не на GO.
[+] Проигрыватель: Ускорена повторная работа с торрентом - resume data (спасибо srg70 и RussakHH)
[B]Version 2.4.6[/B]
[+] Проигрыватель: Уменьшена просадка после загрузки буфера (спасибо srg70 и RussakHH)
[+] История Просмотров: Добавлено имя раздачи, тонкая настройка добавления по проценту просмотра

View File

@ -1749,15 +1749,15 @@ def first_run_231():
xbmc.executebuiltin('Dialog.Close(all,true)')
xbmc.executebuiltin('XBMC.ActivateWindow(Addonbrowser,addons://search/%s)' % ('Torrenter Searcher'))
def first_run_242():
if __settings__.getSetting('torrent_player')=='2':
__settings__.setSetting('first_run_242','True')
def first_run_250():
if __settings__.getSetting('torrent_player')=='3':
__settings__.setSetting('first_run_250','True')
if not __settings__.getSetting('first_run_242')=='True':
__settings__.setSetting('first_run_242','True')
yes=xbmcgui.Dialog().yesno('< %s >' % (Localization.localize('Torrenter Update ') + '2.4.2'),
Localization.localize('New player to Torrenter v2 - Torrent2HTTP! It should be faster, '
'stable and better with Android, also seeking works in it.'),
if not __settings__.getSetting('first_run_250')=='True':
__settings__.setSetting('first_run_250','True')
yes=xbmcgui.Dialog().yesno('< %s >' % (Localization.localize('Torrenter Update ') + '2.5.0'),
Localization.localize('New player to Torrenter v2 - pyrrent2http! Advantages of Torrent2HTTP '
'but with python-libtorrent library instead of libtorrent-go!'),
Localization.localize('Would you like to try it?'),)
if yes:
__settings__.openSettings()

View File

@ -65,6 +65,7 @@
<string id="30065">Do not add to Watched History if played more (%)</string>
<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="30101">Interface</string>
<string id="30102">P2P Network</string>
<string id="30103">Advanced</string>

View File

@ -65,6 +65,7 @@
<string id="30065">Не добавлять в История Просмотров если больше (%)</string>
<string id="30066">Confluence (от safonov_ivan)</string>
<string id="30067">Aeon Nox (от joyrider)</string>
<string id="30068">pyrrent2http (python-libtorrent по http)</string>
<string id="30101">Интерфейс</string>
<string id="30102">P2P Сеть</string>
<string id="30103">Дополнительные</string>

View File

@ -15,7 +15,7 @@
<setting id="debug" type="bool" label="30015" default="false"/>
</category>
<category label="30102">
<setting id="torrent_player" type="enum" label="30023" default="2" lvalues="30021|30022|30046" />
<setting id="torrent_player" type="enum" label="30023" default="2" lvalues="30021|30022|30046|30068" />
<setting id="storage" type="folder" label="30004" default=""/>
<setting id="keep_files" type="enum" label="30008" default="1" lvalues="30043|30044|30045"/>
<setting id="next_dl" type="bool" label="30013" default="true" visible="!eq(-3,1)"/>
@ -61,7 +61,7 @@
<setting id="torrent_qbittorrent_password" type="text" label="50316" visible="eq(-21,4)" default="admin" option="hidden"/>
</category>
<category label="30105">
<setting id="torrent_player" type="enum" label="30023" default="2" lvalues="30021|30022|30046" />
<setting id="torrent_player" type="enum" label="30023" default="2" lvalues="30021|30022|30046|30068" />
<setting id="ask_dir" type="bool" label="30031" default="false"/>
<setting id="connections_limit" type="number" label="30051" default="200" visible=" eq(-2,2)"/>
<setting id="use_random_port" type="bool" label="30052" default="false" visible=" eq(-3,2)"/>