diff options
author | Koch Michael <charlie8913@gmail.com> | 2014-06-01 20:23:56 +0200 |
---|---|---|
committer | Koch Michael <charlie8913@gmail.com> | 2014-06-01 20:23:56 +0200 |
commit | fd5d654d1833be335c21c20724032c4438d7d8bc (patch) | |
tree | 008319d70ef9df3147a8a216aea29923a7feb805 | |
parent | Merge branch 'fix-uploadedto' (diff) | |
parent | added missing argument (diff) | |
download | pyload-fd5d654d1833be335c21c20724032c4438d7d8bc.tar.xz |
Merge remote-tracking branch 'upstream/master'
-rw-r--r-- | pyload/interaction/InteractionTask.py | 36 | ||||
-rw-r--r-- | pyload/plugins/Crypter.py | 7 | ||||
-rw-r--r-- | pyload/threads/InfoThread.py | 11 | ||||
-rw-r--r-- | pyload/web/app/scripts/views/input/clickInput.js | 43 | ||||
-rw-r--r-- | pyload/web/app/scripts/views/input/inputLoader.js | 7 | ||||
-rw-r--r-- | pyload/web/app/scripts/views/input/inputView.js | 5 | ||||
-rw-r--r-- | pyload/web/app/scripts/views/queryModal.js | 19 | ||||
-rw-r--r-- | pyload/web/app/styles/default/style.less | 6 |
8 files changed, 108 insertions, 26 deletions
diff --git a/pyload/interaction/InteractionTask.py b/pyload/interaction/InteractionTask.py index b404aa6ce..498d807c0 100644 --- a/pyload/interaction/InteractionTask.py +++ b/pyload/interaction/InteractionTask.py @@ -1,27 +1,25 @@ # -*- coding: utf-8 -*- -""" - 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 <http://www.gnu.org/licenses/>. - - @author: RaNaN -""" +############################################################################### +# Copyright(c) 2008-2014 pyLoad Team +# http://www.pyload.org +# +# This file is part of pyLoad. +# pyLoad is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# Subjected to the terms and conditions in LICENSE +# +# @author: RaNaN +############################################################################### from time import time from pyload.Api import InteractionTask as BaseInteractionTask from pyload.Api import Interaction, InputType, Input -#noinspection PyUnresolvedReferences +# noinspection PyUnresolvedReferences class InteractionTask(BaseInteractionTask): """ General Interaction Task extends ITask defined by api with additional fields and methods. @@ -61,6 +59,10 @@ class InteractionTask(BaseInteractionTask): self.wait_until = 0 def convertResult(self, value): + if self.input.type == InputType.Click: + parts = value.split(',') + return int(parts[0]), int(parts[1]) + #TODO: convert based on input/output return value diff --git a/pyload/plugins/Crypter.py b/pyload/plugins/Crypter.py index b6bdb1edd..e3b373dbb 100644 --- a/pyload/plugins/Crypter.py +++ b/pyload/plugins/Crypter.py @@ -286,6 +286,11 @@ class Crypter(Base): """ Retry decrypting, will only work once. Somewhat deprecated method, should be avoided. """ raise Retry() + def getPassword(self): + """ Deprecated """ + self.logDebug("Deprecated method .getPassword(), use self.password instead.") + return self.password + def convertPackages(self): """ Deprecated """ self.logDebug("Deprecated method .convertPackages()") @@ -300,4 +305,4 @@ class Crypter(Base): def clean(self): if hasattr(self, "req"): self.req.close() - del self.req
\ No newline at end of file + del self.req diff --git a/pyload/threads/InfoThread.py b/pyload/threads/InfoThread.py index 1ff68fb45..1c95d9aca 100644 --- a/pyload/threads/InfoThread.py +++ b/pyload/threads/InfoThread.py @@ -31,6 +31,9 @@ class InfoThread(DecrypterThread): plugins = accumulate(self.data) crypter = {} + # db or info result + cb = self.updateDB if self.pid > 1 else self.updateResult + # filter out crypter plugins for name in self.m.core.pluginManager.getPlugins("crypter"): if name in plugins: @@ -41,22 +44,19 @@ class InfoThread(DecrypterThread): # decrypt them links, packages = self.decrypt(crypter, err=True) # push these as initial result and save package names - self.updateResult(links) + cb(links) for pack in packages: for url in pack.getURLs(): self.names[url] = pack.name links.extend(pack.links) - self.updateResult(pack.links) + cb(pack.links) # TODO: no plugin information pushed to GUI # parse links and merge hoster, crypter = self.m.core.pluginManager.parseUrls([l.url for l in links]) accumulate(hoster + crypter, plugins) - # db or info result - cb = self.updateDB if self.pid > 1 else self.updateResult - self.progress = ProgressInfo("BasePlugin", "", _("online check"), 0, 0, sum(len(urls) for urls in plugins.itervalues()), self.owner, ProgressType.LinkCheck) @@ -102,6 +102,7 @@ class InfoThread(DecrypterThread): # merge in packages that already have a name data = accumulate(tmp.iteritems(), data) + # TODO: self.oc is None ?! self.m.setInfoResults(self.oc, data) def fetchForPlugin(self, plugin, urls, cb): diff --git a/pyload/web/app/scripts/views/input/clickInput.js b/pyload/web/app/scripts/views/input/clickInput.js new file mode 100644 index 000000000..ca8a954b8 --- /dev/null +++ b/pyload/web/app/scripts/views/input/clickInput.js @@ -0,0 +1,43 @@ +define(['jquery', 'backbone', 'underscore', 'helpers/gettext', './inputView'], function($, Backbone, _, gettext, inputView) { + 'use strict'; + + return inputView.extend({ + + tagName: 'input', + events: { + 'keyup': 'onChange', + 'focus': 'showTooltip', + 'focusout': 'hideTooltip' + }, + + renderInput: function() { + this.$el.attr('disabled', 'on'); + this.$el.attr('type', 'text'); + this.$el.attr('name', 'textInput'); + + if (this.default_value) + this.$el.attr('placeholder', this.default_value); + else + this.$el.attr('placeholder', gettext('Please click on the right position in the captcha.')); + + if (this.value) + this.$el.val(this.value); + + return this; + }, + + onClick: function(x,y) { + this.$el.val(x + ',' + y); + this.onChange(); + }, + + clear: function() { + this.$el.val(''); + }, + + onChange: function(e) { + this.setVal(this.$el.val()); + } + + }); +}); diff --git a/pyload/web/app/scripts/views/input/inputLoader.js b/pyload/web/app/scripts/views/input/inputLoader.js index 04d591d30..c28572c6c 100644 --- a/pyload/web/app/scripts/views/input/inputLoader.js +++ b/pyload/web/app/scripts/views/input/inputLoader.js @@ -1,8 +1,13 @@ -define(['./textInput'], function(textInput) { +define(['utils/apitypes', './textInput', './clickInput'], function(Api, textInput, clickInput) { 'use strict'; // selects appropriate input element return function(input) { + console.log('Select input', input); + + if (input.type == Api.InputType.Click) + return clickInput; + return textInput; }; });
\ No newline at end of file diff --git a/pyload/web/app/scripts/views/input/inputView.js b/pyload/web/app/scripts/views/input/inputView.js index 1860fcaf1..394e33aef 100644 --- a/pyload/web/app/scripts/views/input/inputView.js +++ b/pyload/web/app/scripts/views/input/inputView.js @@ -38,6 +38,11 @@ define(['jquery', 'backbone', 'underscore'], function($, Backbone, _) { return this; }, + // triggered by captcha clicks + onClick: function(x,y) { + + }, + renderInput: function() { // Overwrite this }, diff --git a/pyload/web/app/scripts/views/queryModal.js b/pyload/web/app/scripts/views/queryModal.js index ce624814a..6877687b3 100644 --- a/pyload/web/app/scripts/views/queryModal.js +++ b/pyload/web/app/scripts/views/queryModal.js @@ -1,9 +1,12 @@ -define(['jquery', 'underscore', 'app', 'views/abstract/modalView', './input/inputLoader', 'hbs!tpl/dialogs/interactionTask'], - function($, _, App, modalView, load_input, template) { +define(['jquery', 'underscore', 'app', 'utils/apitypes', 'views/abstract/modalView', './input/inputLoader', 'hbs!tpl/dialogs/interactionTask'], + function($, _, App, Api, modalView, load_input, template) { 'use strict'; return modalView.extend({ + className: 'query-modal', + events: { + 'click #captchaImage': 'onClick', 'click .btn-success': 'submit', 'submit form': 'submit' }, @@ -40,10 +43,22 @@ define(['jquery', 'underscore', 'app', 'views/abstract/modalView', './input/inpu var input = this.model.get('input'); var InputView = load_input(input); this.input = new InputView({input: input}); + if (input.type == Api.InputType.Click) + this.$('#captchaImage').css('cursor', 'crosshair'); + // only renders after wards this.$('#inputField').append(this.input.render().el); }, + onClick: function(e) { + var el = $(e.target); + var posX = el.offset().left, + posY = el.offset().top; + + // TODO: calculate image size, scale positions to displayed / real image size + this.input.onClick(Math.round(e.pageX - posX), Math.round(e.pageY - posY)); + }, + submit: function(e) { e.stopPropagation(); // TODO: load next task diff --git a/pyload/web/app/styles/default/style.less b/pyload/web/app/styles/default/style.less index ad60e5b59..fb441b882 100644 --- a/pyload/web/app/styles/default/style.less +++ b/pyload/web/app/styles/default/style.less @@ -222,6 +222,12 @@ header { // background-color: @greyDark; } +.query-modal { + img { + max-width: none; + } +} + /* Actionbar */ |