From f499dd8502397476e83ed21922b657df4eb685ae Mon Sep 17 00:00:00 2001 From: DiMartinoXBMC Date: Wed, 18 Jan 2017 15:59:45 +0300 Subject: [PATCH] external seek --- Anteoloader.py | 4 ++-- Core.py | 3 +++ Inposloader.py | 4 ++-- Player.py | 4 ++-- changelog.txt | 3 +++ functions.py | 28 ++++++++++++++++++++++++++-- 6 files changed, 38 insertions(+), 8 deletions(-) diff --git a/Anteoloader.py b/Anteoloader.py index 8673171..6b50e07 100644 --- a/Anteoloader.py +++ b/Anteoloader.py @@ -302,12 +302,12 @@ class AnteoPlayer(xbmc.Player): if self.buffer(): log('[AnteoPlayer]: ************************************* GOING LOOP') if self.setup_play(): - WatchedHistoryDB().add(self.basename, + WatchedHistoryDB().add(self.basename, self.torrentUrl, foldername(self.getContentList()[self.contentId]['title']), self.watchedTime, self.totalTime, self.contentId, self.fullSize) self.setup_subs() self.loop() - WatchedHistoryDB().add(self.basename, foldername(self.getContentList()[self.contentId]['title']), self.watchedTime, self.totalTime, self.contentId, self.fullSize) + WatchedHistoryDB().add(self.basename, self.torrentUrl, foldername(self.getContentList()[self.contentId]['title']), self.watchedTime, self.totalTime, self.contentId, self.fullSize) else: log('[AnteoPlayer]: ************************************* break') break diff --git a/Core.py b/Core.py index b46322a..ba8076c 100644 --- a/Core.py +++ b/Core.py @@ -1479,6 +1479,9 @@ class Core: else: torrentUrl = self.__settings__.getSetting("lastTorrent") #xbmc.executebuiltin('Action(Stop)') + if self.torrent_player != '1' and params.get('external') == '1' and not params.get('seek'): + params['seek'] = watched_seek(torrentUrl, params['url']) + self.userStorage(params) if self.torrent_player == '0': from Player import TorrentPlayer diff --git a/Inposloader.py b/Inposloader.py index b9c6128..89b86dd 100644 --- a/Inposloader.py +++ b/Inposloader.py @@ -273,12 +273,12 @@ class InposPlayer(xbmc.Player): while True: log('['+author+'Player]: ************************************* GOING LOOP') if self.setup_play(): - WatchedHistoryDB().add(self.basename, + WatchedHistoryDB().add(self.basename, self.torrentUrl, foldername(self.getContentList()[self.contentId]['title']), self.watchedTime, self.totalTime, self.contentId, self.fullSize) self.setup_subs() self.loop() - WatchedHistoryDB().add(self.basename, foldername(self.getContentList()[self.contentId]['title']), self.watchedTime, self.totalTime, self.contentId, self.fullSize) + WatchedHistoryDB().add(self.basename, self.torrentUrl, foldername(self.getContentList()[self.contentId]['title']), self.watchedTime, self.totalTime, self.contentId, self.fullSize) else: log('['+author+'Player]: ************************************* break') break diff --git a/Player.py b/Player.py index bf5c180..78909ba 100644 --- a/Player.py +++ b/Player.py @@ -166,12 +166,12 @@ class TorrentPlayer(xbmc.Player): debug('************************************* GOING LOOP') self.torrent.startSession() self.torrent.continueSession(self.contentId) - WatchedHistoryDB().add(self.basename, + WatchedHistoryDB().add(self.basename, self.torrentUrl, foldername(self.torrent.getContentList()[self.contentId]['title']), self.watchedTime, self.totalTime, self.contentId, self.fullSize / 1024 / 1024) self.loop() - WatchedHistoryDB().add(self.basename, foldername(self.torrent.getContentList()[self.contentId]['title']), self.watchedTime, self.totalTime, self.contentId, self.fullSize / 1024 / 1024) + WatchedHistoryDB().add(self.basename, self.torrentUrl, foldername(self.torrent.getContentList()[self.contentId]['title']), self.watchedTime, self.totalTime, self.contentId, self.fullSize / 1024 / 1024) else: break debug('************************************* GO NEXT?') diff --git a/changelog.txt b/changelog.txt index bb9ad07..777a953 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ English changelog at http://bit.ly/1MfSVUP +[B]Version 2.6.2[/B] +[+] История Просмотров: Перемотка при внешнем вызове + [B]Version 2.6.1[/B] [+] Окно Поиска: Использование окна в сторонних плагинах diff --git a/functions.py b/functions.py index 4345f76..04d337e 100644 --- a/functions.py +++ b/functions.py @@ -1071,7 +1071,14 @@ class WatchedHistoryDB: self._close() return x if x else None - def add(self, filename, foldername = None, seek = 0, length = 1, ind = 0, size = 0): + def getbypathind(self, path, ind): + self._connect() + self.cur.execute('select seek from history where path="' + path + '" AND ind=' + ind) + x = self.cur.fetchone() + self._close() + return x if x else None + + def add(self, filename, path, foldername = None, seek = 0, length = 1, ind = 0, size = 0): try: watchedPercent = int((float(seek) / float(length)) * 100) except: @@ -1080,7 +1087,7 @@ class WatchedHistoryDB: if self.history_bool and watchedPercent <= max_history_add: self._connect() url = __settings__.getSetting("lastTorrentUrl") - path = __settings__.getSetting("lastTorrent") + #path = __settings__.getSetting("lastTorrent") if not foldername: foldername = '' self.cur.execute('delete from history where filename="' + decode(filename) + '"') @@ -2303,3 +2310,20 @@ def loadsw_onstop(): import searchwindow params = {'mode': 'load'} searchwindow.main(params) + +def watched_seek(filename, ind): + db = WatchedHistoryDB() + seek = db.getbypathind(filename, ind) + log('[watched_seek] seek - '+str(seek)) + if seek: + seek = seek[0] + seek = int(seek) if int(seek) > 3 * 60 else 0 + if seek > 0: + seek_text = '%02d:%02d:%02d' % ((seek / (60 * 60)), (seek / 60) % 60, seek % 60) + dialog_items = [Localization.localize('Play (from %s)') % seek_text, + Localization.localize('Play (from start)')] + ret = xbmcgui.Dialog().select(Localization.localize('Play (with seek)'), dialog_items) + if ret == 0: + return str(seek) + else: + return '0' \ No newline at end of file