diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 84188cc..7cbf0b0 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,11 +1,20 @@ - + + + + + + + + + + @@ -94,12 +103,16 @@ - + - + + + + + @@ -118,16 +131,19 @@ + + + + - @@ -135,16 +151,22 @@ + + + + + + @@ -153,23 +175,33 @@ + + + + + + + + + + + + - - @@ -179,10 +211,11 @@ - + + + - @@ -194,17 +227,28 @@ - + + - - - - - - + + + + + + + + + + + + + + + + @@ -213,44 +257,34 @@ - - + + - + - - + + - - - - - - - - + + + + + + + + - - - - - - - - - - @@ -328,23 +362,21 @@ - + - - + + - - - - - - - - - - + + + + + + + + @@ -354,14 +386,13 @@ - + - - + + - @@ -370,16 +401,22 @@ - - - - - - - - - - + + + + + + + + + + + + + + + + @@ -399,98 +436,63 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + - - + + - - - - - - - - - - - - - - - - - - - - - - - @@ -500,7 +502,7 @@ - + @@ -510,7 +512,7 @@ - + @@ -520,7 +522,7 @@ - + @@ -573,11 +575,9 @@ @@ -633,8 +635,6 @@ - - @@ -731,6 +731,8 @@ + + @@ -912,18 +914,6 @@ - + - + - + @@ -1230,7 +1232,7 @@ - + @@ -1247,7 +1249,6 @@ - @@ -1267,12 +1268,13 @@ - - @@ -1520,14 +1522,6 @@ - - - - - - - - @@ -1535,43 +1529,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1625,6 +1582,284 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1700,294 +1935,73 @@ - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + diff --git a/Anteoloader.py b/Anteoloader.py index bcac138..35700ca 100644 --- a/Anteoloader.py +++ b/Anteoloader.py @@ -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') diff --git a/Core.py b/Core.py index 52e08fe..c0a2277 100644 --- a/Core.py +++ b/Core.py @@ -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) diff --git a/Downloader.py b/Downloader.py index 3d326f3..bde7252 100644 --- a/Downloader.py +++ b/Downloader.py @@ -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): diff --git a/Libtorrent.py b/Libtorrent.py index 020db8b..1e25088 100644 --- a/Libtorrent.py +++ b/Libtorrent.py @@ -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') diff --git a/Localization.py b/Localization.py index f6d47a0..80f0800 100644 --- a/Localization.py +++ b/Localization.py @@ -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':'Перемотка', diff --git a/Player.py b/Player.py index e2f8293..39f4c66 100644 --- a/Player.py +++ b/Player.py @@ -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) diff --git a/addon.xml b/addon.xml index c39c21a..938d89d 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@  - + diff --git a/changelog.txt b/changelog.txt index edb5c2b..91811fb 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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) [+] История Просмотров: Добавлено имя раздачи, тонкая настройка добавления по проценту просмотра diff --git a/functions.py b/functions.py index 4228fbe..8026f0d 100644 --- a/functions.py +++ b/functions.py @@ -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() diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml index c4dc59f..da2da48 100644 --- a/resources/language/English/strings.xml +++ b/resources/language/English/strings.xml @@ -65,6 +65,7 @@ Do not add to Watched History if played more (%) Confluence (by safonov_ivan) Aeon Nox (by joyrider) + pyrrent2http (python-libtorrent via http) Interface P2P Network Advanced diff --git a/resources/language/Russian/strings.xml b/resources/language/Russian/strings.xml index 0055e9c..3bd940f 100644 --- a/resources/language/Russian/strings.xml +++ b/resources/language/Russian/strings.xml @@ -65,6 +65,7 @@ Не добавлять в История Просмотров если больше (%) Confluence (от safonov_ivan) Aeon Nox (от joyrider) + pyrrent2http (python-libtorrent по http) Интерфейс P2P Сеть Дополнительные diff --git a/resources/settings.xml b/resources/settings.xml index 1e8df80..1dc796b 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -15,7 +15,7 @@ - + @@ -61,7 +61,7 @@ - +