From 4223c6d9420d632854370b95354f7ccee78092ca Mon Sep 17 00:00:00 2001 From: DiMartinoXBMC Date: Sat, 7 Jan 2017 14:39:57 +0300 Subject: [PATCH] some really shady shit --- Anteoloader.py | 11 +++++++---- Core.py | 7 +++++-- Inposloader.py | 11 +++++++---- Player.py | 16 +++++++++------ changelog.txt | 5 +++++ functions.py | 12 ++++++++---- resources/language/English/strings.xml | 1 + resources/language/Russian/strings.xml | 7 +++++++ resources/settings.xml | 1 + searchwindow.py | 27 +++++++++++++++++++------- 10 files changed, 71 insertions(+), 27 deletions(-) diff --git a/Anteoloader.py b/Anteoloader.py index 3863849..d4ae9f6 100644 --- a/Anteoloader.py +++ b/Anteoloader.py @@ -302,6 +302,9 @@ class AnteoPlayer(xbmc.Player): if self.buffer(): log('[AnteoPlayer]: ************************************* GOING LOOP') if self.setup_play(): + WatchedHistoryDB().add(self.basename, + 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) @@ -321,19 +324,19 @@ class AnteoPlayer(xbmc.Player): log('[AnteoPlayer]: ************************************* NO! break') showMessage(self.localize('Information'), - self.localize('Stopping the torrent2http process...'), forced=True) + self.localize('Stopping the torrent2http process...')) break xbmc.Player().stop() - loadsw_onstop() # Reload Search Window - if '1' != self.__settings__.getSetting("keep_files") and 'Saved Files' not in self.userStorageDirectory: xbmc.sleep(1000) clearStorage(self.userStorageDirectory) showMessage(self.localize('Information'), - self.localize('torrent2http process stopped.'), forced=True) + self.localize('torrent2http process stopped.')) + + loadsw_onstop() # Reload Search Window def init(self): self.next_contentId = False diff --git a/Core.py b/Core.py index 9921556..ff8189d 100644 --- a/Core.py +++ b/Core.py @@ -1473,7 +1473,10 @@ class Core: self.userStorageDirectory=dirname def playTorrent(self, params={}): - torrentUrl = self.__settings__.getSetting("lastTorrent") + if params.get('filename'): + torrentUrl = params.get('filename') + else: + torrentUrl = self.__settings__.getSetting("lastTorrent") #xbmc.executebuiltin('Action(Stop)') self.userStorage(params) if self.torrent_player == '0': @@ -1608,7 +1611,7 @@ class Core: 'XBMC.RunPlugin(%s)' % ('%s?action=%s&ind=%s') % ( sys.argv[0], 'downloadLibtorrent', str(identifier))), ] - link = {'url': identifier, 'thumbnail': thumbnail, 'save_folder':save_folder} + link = {'url': identifier, 'thumbnail': thumbnail, 'save_folder':save_folder, 'filename':url} self.drawItem(title, 'playTorrent', link, image=thumbnail, isFolder=False, action2=ids_video.rstrip(','), contextMenu=contextMenu, replaceMenu=False, fileSize=filesize) view_style('openTorrent') diff --git a/Inposloader.py b/Inposloader.py index e30125d..b9c6128 100644 --- a/Inposloader.py +++ b/Inposloader.py @@ -273,6 +273,9 @@ class InposPlayer(xbmc.Player): while True: log('['+author+'Player]: ************************************* GOING LOOP') if self.setup_play(): + WatchedHistoryDB().add(self.basename, + 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) @@ -301,8 +304,6 @@ class InposPlayer(xbmc.Player): xbmc.Player().stop() - loadsw_onstop() # Reload Search Window - if '1' != self.__settings__.getSetting("keep_files") and 'Saved Files' not in self.userStorageDirectory: xbmc.sleep(1000) clearStorage(self.userStorageDirectory) @@ -313,7 +314,9 @@ class InposPlayer(xbmc.Player): #else: #if self.seeding: self.db_delete() showMessage(self.localize('Information'), - self.localize('Torrent downloading is stopped.'), forced=True) + self.localize('Torrent downloading is stopped.')) + + loadsw_onstop() # Reload Search Window def init(self): self.next_contentId = False @@ -572,7 +575,7 @@ class InposPlayer(xbmc.Player): int) and self.next_contentId != False: self.engine.activate_file(self.next_contentId) showMessage(self.localize('Torrent Downloading'), - self.localize('Starting download next episode!'), forced=True) + self.localize('Starting download next episode!')) log('[loop]: next_contentId '+str(self.next_contentId)+str(isinstance(self.next_contentId, int))) file_status = self.engine.file_status(self.next_contentId) self.basename = self.display_name = os.path.basename(file_status.name) diff --git a/Player.py b/Player.py index 835197b..bf5c180 100644 --- a/Player.py +++ b/Player.py @@ -166,6 +166,10 @@ class TorrentPlayer(xbmc.Player): debug('************************************* GOING LOOP') self.torrent.startSession() self.torrent.continueSession(self.contentId) + WatchedHistoryDB().add(self.basename, + 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) else: @@ -184,8 +188,6 @@ class TorrentPlayer(xbmc.Player): debug('************************************* NO! break') break - loadsw_onstop() # Reload Search Window - self.torrent.stopSession() self.torrent.threadComplete = True self.torrent.checkThread() @@ -195,11 +197,13 @@ class TorrentPlayer(xbmc.Player): else: if self.seeding_status: showMessage(self.localize('Information'), - self.localize('Torrent is seeding. To stop it use Download Status.'), forced=True) + self.localize('Torrent is seeding. To stop it use Download Status.')) else: if self.seeding: self.db_delete() showMessage(self.localize('Information'), - self.localize('Torrent downloading is stopped.'), forced=True) + self.localize('Torrent downloading is stopped.')) + + loadsw_onstop() # Reload Search Window def init(self): self.next_dl = True if self.__settings__.getSetting('next_dl') == 'true' and self.ids_video else False @@ -369,7 +373,7 @@ class TorrentPlayer(xbmc.Player): if len(subs) > 0: self.torrent.startSession() showMessage(self.localize('Information'), - self.localize('Downloading and copy subtitles. Please wait.'), forced=True) + self.localize('Downloading and copy subtitles. Please wait.')) for ind, title in subs: self.torrent.continueSession(ind) while iterator < 100: @@ -457,7 +461,7 @@ class TorrentPlayer(xbmc.Player): if self.iterator == 100 and self.next_dl and not self.next_dling and isinstance(self.next_contentId, int) and self.next_contentId != False: showMessage(self.localize('Torrent Downloading'), - self.localize('Starting download next episode!'), forced=True) + self.localize('Starting download next episode!')) self.torrent.stopSession() # xbmc.sleep(1000) path = self.torrent.getFilePath(self.next_contentId) diff --git a/changelog.txt b/changelog.txt index 41488c5..162a519 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,10 @@ English changelog at http://bit.ly/1MfSVUP +[B]Version 2.6.0[/B] +[+] Окно Поиска: Полноценный релиз +[+] Настройки: Добавлена возможность отключения уведомлений +[+] История Просмотров: При аварийном выходе данные остаются + [B]Version 2.5.6[/B] [+] Списки Медиа: Добавлен RuTorOrg diff --git a/functions.py b/functions.py index c72e562..9941335 100644 --- a/functions.py +++ b/functions.py @@ -93,10 +93,10 @@ def clearStorage(userStorageDirectory, force = False): if saved_bool: shutil.move(saved_temp, saved) - showMessage(Localization.localize('Storage'), Localization.localize('Storage has been cleared'), forced=True) + showMessage(Localization.localize('Storage'), Localization.localize('Storage has been cleared')) else: - showMessage(Localization.localize('Storage'), Localization.localize('Does not exists'), forced=True) + showMessage(Localization.localize('Storage'), Localization.localize('Does not exists')) log('[clearStorage]: fail storage '+userStorageDirectory + os.sep) try: @@ -152,8 +152,9 @@ def debug(msg, forced=False): def showMessage(heading, message, times=10000, forced=False): - xbmc.executebuiltin('XBMC.Notification("%s", "%s", %s, "%s")' % ( - heading.replace('"', "'"), message.replace('"', "'"), times, icon)) + if forced or not getSettingAsBool('disable_notifications'): + xbmc.executebuiltin('XBMC.Notification("%s", "%s", %s, "%s")' % ( + heading.replace('"', "'"), message.replace('"', "'"), times, icon)) debug(str((heading.replace('"', "'"), message.replace('"', "'"), times, icon))) @@ -1362,6 +1363,7 @@ def get_contentList(url): import Downloader url = urllib.unquote_plus(url) + log('0' + __settings__.getSetting("lastTorrent")) __settings__.setSetting("lastTorrentUrl", url) classMatch = re.search('(\w+)::(.+)', url) @@ -1372,7 +1374,9 @@ def get_contentList(url): torrent = Downloader.Torrent(userStorageDirectory, url, torrentFilesDirectory=torrentFilesDirectory) + log('1'+__settings__.getSetting("lastTorrent")) __settings__.setSetting("lastTorrent", torrent.saveTorrent(url)) + log('2'+__settings__.getSetting("lastTorrent")) append_filesize = __settings__.getSetting("append_filesize") == 'true' diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml index 895544e..cac403a 100644 --- a/resources/language/English/strings.xml +++ b/resources/language/English/strings.xml @@ -85,6 +85,7 @@ Enabled, optional Disabled Search Window Transparent Background + Disable Notifications Save path Call dialog Default diff --git a/resources/language/Russian/strings.xml b/resources/language/Russian/strings.xml index 168a464..0d0603d 100644 --- a/resources/language/Russian/strings.xml +++ b/resources/language/Russian/strings.xml @@ -79,6 +79,13 @@ Дополнительные Торрент-клиент Hentai (тонкая настр.) + Режим работы Окна Поиска + Включен, убрать старый вид + Включен, заменить старый вид + Включен, как опция + Отключен + Прозрачность Окна Поиска + Отключить Уведомления Директория для сохранения файлов Вызывать диалог Задать по умолчанию diff --git a/resources/settings.xml b/resources/settings.xml index fa7d48b..b435dd3 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -73,6 +73,7 @@ + diff --git a/searchwindow.py b/searchwindow.py index 59505aa..f6b5529 100644 --- a/searchwindow.py +++ b/searchwindow.py @@ -240,8 +240,11 @@ class SearchWindow(pyxbmct.AddonDialogWindow): navi = read.read() read.close() - debug('navi_load navi: '+str(navi)) - log('navi_load navi: ' + str(navi['route'])) + try: + debug('navi_load navi: '+str(navi)) + log('navi_load navi: ' + str(navi['route'])) + except: + log('navi_load load error') if navi and len(navi) > 0: self.navi = json.loads(navi) @@ -335,7 +338,11 @@ class SearchWindow(pyxbmct.AddonDialogWindow): if query: self.input_search.setText(query) else: - query = self.input_search.getText() + if self.input_search.getText() not in ['', None]: + query = self.input_search.getText() + elif self.navi['last_query'] not in ['', None]: + query = self.navi['last_query'] + self.input_search.setText(self.navi['last_query']) log('Search query: ' + str(query)) @@ -814,7 +821,7 @@ class SearchWindow(pyxbmct.AddonDialogWindow): contentListNew = sorted(contentListNew, key=lambda x: x[0], reverse=False) for title, identifier, filesize in contentListNew: - params = {'mode': 'torrent_play', 'url': identifier, 'url2': ids_video.rstrip(','), 'filename': link} + params = {'mode': 'torrent_play', 'fileIndex': identifier, 'url2': ids_video.rstrip(','), 'url': link} self.drawItem(title, params) self.navi_save('open_torrent') @@ -865,7 +872,11 @@ class SearchWindow(pyxbmct.AddonDialogWindow): return label_list def context(self): - if self.getFocus() == self.listing: + try: + focused_control = self.getFocus() + except: + focused_control = None + if focused_control == self.listing: item = self.listing.getSelectedItem() params = json.loads(item.getfilename()) mode = params.get('mode') @@ -879,6 +890,8 @@ class SearchWindow(pyxbmct.AddonDialogWindow): if ret > -1 and ret < len(label_list): getattr(self, "right_press" + str(ret + 1))() + elif focused_control == self.input_search: + self.input_search.setText('') def right_menu(self, mode='place'): if not mode == 'place': @@ -1028,7 +1041,7 @@ class SearchWindow(pyxbmct.AddonDialogWindow): self.navi_back() elif mode == 'torrent_play': if index == 1: - url = self.form_link('playTorrent', params) + url = self.form_link('playSTRM', params) xbmc.executebuiltin('xbmc.RunPlugin("%s")' % (url)) __settings__.setSetting('loadsw_onstop', 'true') self.close() @@ -1125,7 +1138,7 @@ class SearchWindow(pyxbmct.AddonDialogWindow): link_url = '' for key in link.keys(): if link.get(key) and key != 'mode': - link_url = '%s&%s=%s' % (link_url, key, urllib.quote_plus(link.get(key))) + link_url = '%s&%s=%s' % (link_url, key, urllib.quote_plus(ensure_str(link.get(key)))) url = '%s?action=%s' % ('plugin://plugin.video.torrenter/', action) + link_url else: url = '%s?action=%s&url=%s' % ('plugin://plugin.video.torrenter/', action, urllib.quote_plus(link))