From c3e7c7b9531ef13d3e749beaa855746b2c7f9c19 Mon Sep 17 00:00:00 2001 From: DiMartinoXBMC Date: Sun, 18 Jan 2015 01:32:32 +0300 Subject: [PATCH] fixes and fr --- .idea/workspace.xml | 703 +++++++++++++++------------------- Core.py | 2 +- Player.py | 21 +- changelog.txt | 4 + functions.py | 2 +- resources/searchers/T411FR.py | 134 +++++++ resources/settings.xml | 1 + 7 files changed, 468 insertions(+), 399 deletions(-) create mode 100644 resources/searchers/T411FR.py diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 07806eb..a7616e9 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,8 +2,12 @@ + - + + + + @@ -35,11 +39,11 @@ - + - - + + @@ -47,79 +51,57 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + - + - - + + @@ -128,53 +110,42 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -182,18 +153,18 @@ - - + + - - + + - - + + @@ -209,26 +180,6 @@ - - - - - - - - - - - - - - - - - - - - @@ -251,20 +202,21 @@ @@ -300,6 +252,7 @@ + @@ -364,57 +317,12 @@ - - - - - - - - - - - - - - - - - - - - - - @@ -431,6 +339,11 @@ + + + + + @@ -743,7 +660,8 @@ - @@ -751,14 +669,6 @@ - - - - - - - - @@ -816,39 +726,37 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -903,39 +811,37 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -990,39 +896,37 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1063,13 +967,6 @@ - - - - - - - @@ -1091,13 +988,6 @@ - - - - - - - @@ -1134,14 +1024,6 @@ - - - - - - - - @@ -1157,14 +1039,6 @@ - - - - - - - - @@ -1173,46 +1047,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1247,16 +1081,72 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -1264,43 +1154,84 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Core.py b/Core.py index 86f6603..12d1a6f 100644 --- a/Core.py +++ b/Core.py @@ -461,7 +461,7 @@ class Core: contextMenu.append((self.localize('Individual Tracker Options'), 'XBMC.RunScript(%s)' % (os.path.join(ROOT, 'controlcenter.py,') + 'addtime=%s&title=%s' % (str(addtime), title)))) contextMenu.append((self.localize('Keyboard'), - ListString % ('search', '&showKey=true', 'url', urllib.quote_plus(title)))) + 'XBMC.ActivateWindow(Videos,%s)' % (sys.argv[0] + '?action=%s&action2=%s&%s=%s') % ('search', '&showKey=true', 'url', urllib.quote_plus(title)))) if int(fav) == 1: contextMenu.append((self.localize('Delete from %s') % self.localize('Favourites SH'), ListString % ('History', 'unfav', 'addtime', str(addtime)))) diff --git a/Player.py b/Player.py index 1dad86a..cf9ab93 100644 --- a/Player.py +++ b/Player.py @@ -163,8 +163,8 @@ class TorrentPlayer(xbmc.Player): def init(self): - self.next_dl = True if self.__settings__.getSetting('next_dl') == 'true' else False - self.next_contentId = None + self.next_dl = True if self.__settings__.getSetting('next_dl') == 'true' and self.ids_video else False + self.next_contentId = False self.display_name = '' self.downloadedSize = 0 self.dialog = xbmcgui.Dialog() @@ -272,13 +272,6 @@ class TorrentPlayer(xbmc.Player): if self.subs_dl: self.setup_subs(label, path) - if self.next_dl and self.ids_video: - next_contentId_index = self.ids_video.index(str(self.contentId)) + 1 - if len(self.ids_video) > next_contentId_index: - self.next_contentId = int(self.ids_video[next_contentId_index]) - else: - self.next_contentId = False - if not self.ids_video: seasonId = self.get("seasonId") episodeId = self.get("episodeId") @@ -349,17 +342,24 @@ class TorrentPlayer(xbmc.Player): with nested(self.attach(overlay.show, self.on_playback_paused), self.attach(overlay.hide, self.on_playback_resumed, self.on_playback_stopped)): while not xbmc.abortRequested and self.isPlaying(): + xbmc.sleep(2000) self.torrent.checkThread() self.torrent.debug() status = self.torrent.torrentHandle.status() overlay.text = "\n".join(self._get_status_lines(status)) #downloadedSize = torrent.torrentHandle.file_progress()[contentId] self.iterator = int(status.progress * 100) + if self.iterator == 100 and self.next_dl: + next_contentId_index = self.ids_video.index(str(self.contentId)) + 1 + if len(self.ids_video) > next_contentId_index: + self.next_contentId = int(self.ids_video[next_contentId_index]) + else: + self.next_contentId = False if not self.seeding_run and self.iterator == 100 and self.seeding: self.seeding_run=True - xbmc.sleep(1000) self.seed(self.contentId) self.seeding_status=True + xbmc.sleep(7000) if self.iterator == 100 and not self.next_dling and (self.next_contentId or self.next_contentId==0): showMessage(Localization.localize('Torrent Downloading'), Localization.localize('Starting download next episode!'), forced=True) @@ -369,7 +369,6 @@ class TorrentPlayer(xbmc.Player): self.basename=self.display_name = os.path.basename(path) self.torrent.continueSession(self.next_contentId) self.next_dling = True - xbmc.sleep(1000) def _get_status_lines(self, s): return [ diff --git a/changelog.txt b/changelog.txt index 04471ac..1e63696 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,8 @@ [B]Version 2.1.2[/B] +[+] Поиск: Добавлен французский t411.me по просьбе Zombi +[+] Множественные баг-фиксы + +[B]Version 2.1.2[/B] [+] Торрент-клиент: Поддержка Deluge WebUI (No SSL) [+] История Поиска: Возможность изменять запрос с помощью клавиатуры [+] Поиска: Настройка выбора действия вместо Открытия торрента diff --git a/functions.py b/functions.py index b8714d5..1d123b3 100644 --- a/functions.py +++ b/functions.py @@ -935,7 +935,7 @@ class HistoryDB: self._connect() providers=self.get_providers(addtime) keys=Searchers().dic().keys() - if len(providers)>0: + if providers and len(providers)>0: if searcher in providers: providers.remove(searcher) else: diff --git a/resources/searchers/T411FR.py b/resources/searchers/T411FR.py new file mode 100644 index 0000000..d6aeed6 --- /dev/null +++ b/resources/searchers/T411FR.py @@ -0,0 +1,134 @@ +# -*- coding: utf-8 -*- +''' + Torrenter plugin for XBMC + Copyright (C) 2012 Vadim Skorba + vadim.skorba@gmail.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +''' + +import re +import os +import urllib +import tempfile +import sys + +import SearcherABC + + +class T411FR(SearcherABC.SearcherABC): + ''' + Weight of source with this searcher provided. + Will be multiplied on default weight. + Default weight is seeds number + ''' + sourceWeight = 1 + + ''' + Relative (from root directory of plugin) path to image + will shown as source image at result listing + ''' + searchIcon = '/resources/searchers/icons/T411FR.png' + + ''' + Flag indicates is this source - magnet links source or not. + Used for filtration of sources in case of old library (setting selected). + Old libraries won't to convert magnet as torrent file to the storage + ''' + + @property + def isMagnetLinkSource(self): + return False + + ''' + Main method should be implemented for search process. + Receives keyword and have to return dictionary of proper tuples: + filesList.append(( + int(weight),# Calculated global weight of sources + int(seeds),# Seeds count + str(title),# Title will be shown + str(link),# Link to the torrent/magnet + str(image),# Path/URL to image shown at the list + ))''' + + headers = {('Origin', 'http://t411.me'), + ('User-Agent', + 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 YaBrowser/14.10.2062.12061 Safari/537.36'), + ('Referer', 'http://t411.me/'),('X-NewRelic-ID','x='), + ('X-Requested-With','XMLHttpRequest'),} + + def search(self, keyword): + filesList = [] + url='http://www.t411.me/torrents/search/?search=%s' % urllib.quote_plus(keyword.decode('utf-8').encode('cp1251')) + url+='&order=seeders&type=desc' + #headers = {('Origin', 'http://t411.me'), + # ('User-Agent', + # 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 YaBrowser/14.10.2062.12061 Safari/537.36'), + # ('Referer', 'http://t411.me/')} + + response = self.makeRequest(url, headers=self.headers) + if None != response and 0 < len(response): + #self.cookieJar.save(ignore_discard=True) + #self.check_login(response) + #print response + regex = '''.+?.+?.+?.+?.+?.+?.+?.+?(.+?).+?(\d+).+?(\d+)''' + for (title, link, size, seeds, leechers) in re.compile(regex, re.DOTALL).findall(response): + title=self.clear_title(title) + image = sys.modules["__main__"].__root__ + self.searchIcon + link = 'http://www.t411.me/torrents/download/?id='+link + filesList.append(( + int(int(self.sourceWeight) * int(seeds)), + int(seeds), int(leechers), size, + title, + self.__class__.__name__ + '::' + link, + image, + )) + return filesList + + def clear_title(self, s): + return self.stripHtml(self.unescape(s)).replace(' ',' ').replace(' ',' ').strip() + + def check_login(self, response=None): + if None != response and 0 < len(response): + #print response + if re.compile('