From c383dec8f6986c348a609314e05d9600149acf78 Mon Sep 17 00:00:00 2001 From: DiMartinoXBMC Date: Thu, 24 Dec 2015 20:44:39 +0300 Subject: [PATCH] lib history and set fix --- .idea/workspace.xml | 307 +++++++++++++++++++++----------------------- Player.py | 11 +- functions.py | 16 ++- 3 files changed, 168 insertions(+), 166 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 00115ce..e65d9ba 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,7 +3,8 @@ - + + @@ -33,11 +34,11 @@ - + - - + + @@ -153,17 +154,15 @@ - - - - - - - - - - - + + + + + + + + + @@ -173,7 +172,7 @@ - + @@ -191,11 +190,11 @@ - + - - + + @@ -246,7 +245,7 @@ - + @@ -269,36 +268,33 @@ - + - - + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + @@ -337,10 +333,10 @@ - + - + @@ -456,7 +452,6 @@ @@ -519,6 +515,7 @@ + @@ -616,7 +613,6 @@ - @@ -798,12 +794,6 @@ - + - - + + @@ -1133,7 +1129,6 @@ - @@ -1158,7 +1153,8 @@ - @@ -1321,39 +1317,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1551,64 +1514,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + @@ -1649,10 +1564,18 @@ + + + + + + + + - - + + @@ -1768,17 +1691,85 @@ - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Player.py b/Player.py index b0de4f4..cf78177 100644 --- a/Player.py +++ b/Player.py @@ -30,7 +30,7 @@ import Downloader import xbmcgui import xbmcvfs import Localization -from functions import calculate, showMessage, clearStorage, DownloadDB, get_ids_video, log, debug +from functions import calculate, showMessage, clearStorage, WatchedHistoryDB, DownloadDB, get_ids_video, log, debug ROOT = sys.modules["__main__"].__root__ RESOURCES_PATH = os.path.join(ROOT, 'resources') @@ -134,6 +134,10 @@ class TorrentPlayer(xbmc.Player): seeding_run = False ids_video = None episodeId = None + fullSize = 0 + watchedTime = 0 + totalTime = 1 + seek = 0 basename = '' def __init__(self, userStorageDirectory, torrentUrl, params={}): @@ -161,6 +165,7 @@ class TorrentPlayer(xbmc.Player): self.torrent.startSession() self.torrent.continueSession(self.contentId) self.loop() + WatchedHistoryDB().add(self.basename, self.watchedTime, self.totalTime, self.contentId, self.fullSize / 1024 / 1024) else: break debug('************************************* GO NEXT?') @@ -278,6 +283,8 @@ class TorrentPlayer(xbmc.Player): def setup_play(self): self.next_dling = False self.iterator = 0 + self.watchedTime = 0 + self.totalTime = 1 path = self.torrent.getFilePath(self.contentId) label = os.path.basename(path) self.basename = label @@ -394,6 +401,8 @@ class TorrentPlayer(xbmc.Player): self.attach(overlay.hide, self.on_playback_resumed, self.on_playback_stopped)): while not xbmc.abortRequested and self.isPlaying() and not self.torrent.threadComplete: self.torrent.checkThread() + self.watchedTime = xbmc.Player().getTime() + self.totalTime = xbmc.Player().getTotalTime() if self.iterator == 100 and debug_counter < 100: debug_counter += 1 else: diff --git a/functions.py b/functions.py index c77de70..e3c79f0 100644 --- a/functions.py +++ b/functions.py @@ -1744,9 +1744,10 @@ def first_run_242(): 'stable and better with Android, also seeking works in it.'), Localization.localize('Would you like to try it?'),) if yes: - __settings__.setSetting('torrent_player','2') - ok = xbmcgui.Dialog().ok('< %s >' % (Localization.localize('Torrenter Update ') + '2.4.2'), - Localization.localize('Torrent2HTTP enabled! Can be changed in Settings.')) + __settings__.openSettings() + #__settings__.setSetting('torrent_player','2') + #ok = xbmcgui.Dialog().ok('< %s >' % (Localization.localize('Torrenter Update ') + '2.4.2'), + # Localization.localize('Torrent2HTTP enabled! Can be changed in Settings.')) def seeking_warning(seek): if __settings__.getSetting('torrent_player')=='2': @@ -1766,9 +1767,10 @@ def seeking_warning(seek): Localization.localize('Seeking is working only with player Torrent2HTTP.'), Localization.localize('Would you like to try it?')) if yes: - __settings__.setSetting('torrent_player','2') - ok = xbmcgui.Dialog().ok('< %s >' % (Localization.localize('Seeking')), - Localization.localize('Torrent2HTTP enabled! Can be changed in Settings.')) + __settings__.openSettings() + #__settings__.setSetting('torrent_player','2') + #ok = xbmcgui.Dialog().ok('< %s >' % (Localization.localize('Seeking')), + # Localization.localize('Torrent2HTTP enabled! Can be changed in Settings.')) return seek def noActiveSerachers(): @@ -1955,7 +1957,7 @@ def get_download_dir(): dialog=xbmcgui.Dialog() dialog.ok(Localization.localize('Torrenter'), Localization.localize('Please specify storage folder in Settings!')) - __settings__.openSettings() + # try: if not platform['system']=='android':