mirror of
https://github.com/evilhero/mylar
synced 2025-03-15 08:18:44 +00:00
IMP(#2170): Added Deluge Test Button, FIX: "Error fetching data from WWT (https://worldwidetorrents.to/download.php): global name 'newurl' is not defined"
This commit is contained in:
parent
f847ac6f04
commit
14c933594b
4 changed files with 83 additions and 27 deletions
48
data/interfaces/default/config.html
Executable file → Normal file
48
data/interfaces/default/config.html
Executable file → Normal file
|
@ -502,8 +502,8 @@
|
|||
|
||||
</td>
|
||||
<td>
|
||||
<legend>Torrents</legend>
|
||||
<fieldset>
|
||||
<legend>Torrents</legend>
|
||||
<div class="row checkbox">
|
||||
<input id="enable_torrents" type="checkbox" onclick="initConfigCheckbox($(this));" name="enable_torrents" value=1 ${config['enable_torrents']} /><label>Use Torrents</label>
|
||||
</div>
|
||||
|
@ -654,27 +654,30 @@
|
|||
<small>Folder path where torrent download will be assigned</small>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset id="deluge_options">
|
||||
<fieldset id="deluge_options">
|
||||
<div class="row">
|
||||
<label>Deluge Host:Port </label>
|
||||
<input type="text" name="deluge_host" value="${config['deluge_host']}" size="30">
|
||||
<small>(ie. 192.168.1.2:58846) port uses the deluge daemon port (remote connection to daemon has to be enabled)</small>
|
||||
<input type="text" id="deluge_host" name="deluge_host" value="${config['deluge_host']}" size="30">
|
||||
<small>(ie. 192.168.1.2:58846) port uses the deluge daemon port (remote connection to daemon has to be enabled)</small>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>Deluge Username</label>
|
||||
<input type="text" name="deluge_username" value="${config['deluge_username']}" size="30">
|
||||
<input type="text" id="deluge_username" name="deluge_username" value="${config['deluge_username']}" size="30">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>Deluge Password</label>
|
||||
<input type="password" name="deluge_password" value="${config['deluge_password']}" size="30">
|
||||
<input type="password" id="deluge_password" name="deluge_password" value="${config['deluge_password']}" size="30">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>Deluge Label</label>
|
||||
<input type="text" name="deluge_label" value="${config['deluge_label']}" size="30"><br/>
|
||||
<small>Label to be used on the torrents</small>
|
||||
</div>
|
||||
<div class="row">
|
||||
<img name="deluge_status_icon" id="deluge_status_icon" src="interfaces/default/images/successs.png" style="float:right;visibility:hidden;" height="20" width="20" />
|
||||
<input type="button" value="Test Connection" id="deluge_test" /><br/>
|
||||
</div>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
<fieldset id="qbittorrent_options">
|
||||
<div class="row">
|
||||
<label>qBittorrent Host:Port </label>
|
||||
|
@ -716,8 +719,9 @@
|
|||
<img name="qbittorrent_statusicon" id="qbittorrent_statusicon" src="interfaces/default/images/successs.png" style="float:right;visibility:hidden;" height="20" width="20" />
|
||||
<input type="button" value="Test Connection" id="qbittorrent_test" />
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -2226,6 +2230,32 @@
|
|||
$('#ajaxMsg').addClass('success').fadeIn().delay(3000).fadeOut();
|
||||
});
|
||||
|
||||
$('#deluge_test').click(function () {
|
||||
var imagechk = document.getElementById("deluge_status_icon");
|
||||
var host = document.getElementById("deluge_host").value;
|
||||
var username = document.getElementById("deluge_username").value;
|
||||
var password = document.getElementById("deluge_password").value;
|
||||
$.get("testdeluge",
|
||||
{ host: host, username: username, password: password },
|
||||
function(data){
|
||||
if (data.error != undefined) {
|
||||
alert(data.error);
|
||||
return;
|
||||
}
|
||||
$('#ajaxMsg').html("<div class='msg'><span class='ui-icon ui-icon-check'></span>"+data+"</div>");
|
||||
if ( data.indexOf("Successfully") > -1){
|
||||
imagechk.src = "";
|
||||
imagechk.src = "interfaces/default/images/success.png";
|
||||
imagechk.style.visibility = "visible";
|
||||
} else {
|
||||
imagechk.src = "";
|
||||
imagechk.src = "interfaces/default/images/fail.png";
|
||||
imagechk.style.visibility = "visible";
|
||||
}
|
||||
});
|
||||
$('#ajaxMsg').addClass('success').fadeIn().delay(3000).fadeOut();
|
||||
});
|
||||
|
||||
$(".newznabtest").click(function () {
|
||||
var newznab = this.attributes["name"].value.replace('newznab_test', '');
|
||||
if ( newznab.indexOf("test_dognzb") > -1) {
|
||||
|
|
|
@ -1102,7 +1102,7 @@ def torsend2client(seriesname, issue, seriesyear, linkit, site, pubhash=None):
|
|||
scraper = cfscrape.create_scraper()
|
||||
if site == 'WWT':
|
||||
if mylar.WWT_CF_COOKIEVALUE is None:
|
||||
cf_cookievalue, cf_user_agent = scraper.get_tokens(newurl, user_agent=mylar.CV_HEADERS['User-Agent'])
|
||||
cf_cookievalue, cf_user_agent = scraper.get_tokens(url, user_agent=mylar.CV_HEADERS['User-Agent'])
|
||||
mylar.WWT_CF_COOKIEVALUE = cf_cookievalue
|
||||
r = scraper.get(url, params=payload, cookies=mylar.WWT_CF_COOKIEVALUE, verify=verify, stream=True, headers=headers)
|
||||
else:
|
||||
|
|
|
@ -8,33 +8,43 @@ from deluge_client import DelugeRPCClient
|
|||
class TorrentClient(object):
|
||||
def __init__(self):
|
||||
self.conn = None
|
||||
|
||||
def connect(self, host, username, password):
|
||||
|
||||
def connect(self, host, username, password, test=False):
|
||||
if self.conn is not None:
|
||||
return self.connect
|
||||
|
||||
|
||||
if not host:
|
||||
return False
|
||||
return {'status': False, 'error': 'No host specified'}
|
||||
|
||||
if not username:
|
||||
return {'status': False, 'error': 'No username specified'}
|
||||
|
||||
if not password:
|
||||
return {'status': False, 'error': 'No password specified'}
|
||||
|
||||
# Get port from the config
|
||||
host,portnr = host.split(':')
|
||||
|
||||
|
||||
#if username and password:
|
||||
# logger.info('Connecting to ' + host + ':' + portnr + ' Username: ' + username + ' Password: ' + password )
|
||||
try:
|
||||
self.client = DelugeRPCClient(host,int(portnr),username,password)
|
||||
except Exception as e:
|
||||
logger.error('Could not create DelugeRPCClient Object' + e)
|
||||
return False
|
||||
logger.error('Could not create DelugeRPCClient Object %s' % e)
|
||||
return {'status': False, 'error': e}
|
||||
else:
|
||||
try:
|
||||
self.client.connect()
|
||||
except Exception as e:
|
||||
logger.error('Could not connect to Deluge ' + host)
|
||||
logger.error('Could not connect to Deluge: %s' % host)
|
||||
return {'status': False, 'error': e}
|
||||
else:
|
||||
return self.client
|
||||
|
||||
if test is True:
|
||||
daemon_version = self.client.call('daemon.info')
|
||||
libtorrent_version = self.client.call('core.get_libtorrent_version')
|
||||
return {'status': True, 'daemon_version': daemon_version, 'libtorrent_version': libtorrent_version}
|
||||
else:
|
||||
return self.client
|
||||
|
||||
def find_torrent(self, hash):
|
||||
logger.debug('Finding Torrent hash: ' + hash)
|
||||
torrent_info = self.get_torrent(hash)
|
||||
|
@ -85,16 +95,16 @@ class TorrentClient(object):
|
|||
else:
|
||||
logger.info('Torrent ' + hash + ' was stopped')
|
||||
return True
|
||||
|
||||
|
||||
|
||||
def load_torrent(self, filepath):
|
||||
|
||||
|
||||
logger.info('filepath to torrent file set to : ' + filepath)
|
||||
torrent_id = False
|
||||
|
||||
|
||||
if self.client.connected is True:
|
||||
logger.info('Checking if Torrent Exists!')
|
||||
|
||||
|
||||
if not filepath.startswith('magnet'):
|
||||
torrentcontent = open(filepath, 'rb').read()
|
||||
hash = str.lower(self.get_the_hash(filepath)) # Deluge expects a lower case hash
|
||||
|
|
|
@ -5959,13 +5959,29 @@ class WebInterface(object):
|
|||
return 'Error establishing connection to Qbittorrent'
|
||||
else:
|
||||
if qclient['status'] is False:
|
||||
logger.warn('[qBittorrent] Could not establish connection to %s. Error returned:' % (host, qclient['error']))
|
||||
logger.warn('[qBittorrent] Could not establish connection to %s. Error returned: %s' % (host, qclient['error']))
|
||||
return 'Error establishing connection to Qbittorrent'
|
||||
else:
|
||||
logger.info('[qBittorrent] Successfully validated connection to %s [%s]' % (host, qclient['version']))
|
||||
logger.info('[qBittorrent] Successfully validated connection to %s [v%s]' % (host, qclient['version']))
|
||||
return 'Successfully validated qBittorrent connection'
|
||||
testqbit.exposed = True
|
||||
|
||||
def testdeluge(self, host, username, password):
|
||||
import torrent.clients.deluge as DelugeClient
|
||||
client = DelugeClient.TorrentClient()
|
||||
dclient = client.connect(host, username, password, True)
|
||||
if not dclient:
|
||||
logger.warn('[Deluge] Could not establish connection to %s' % host)
|
||||
return 'Error establishing connection to Deluge'
|
||||
else:
|
||||
if dclient['status'] is False:
|
||||
logger.warn('[Deluge] Could not establish connection to %s. Error returned: %s' % (host, dclient['error']))
|
||||
return 'Error establishing connection to Deluge'
|
||||
else:
|
||||
logger.info('[Deluge] Successfully validated connection to %s [daemon v%s; libtorrent v%s]' % (host, dclient['daemon_version'], dclient['libtorrent_version']))
|
||||
return 'Successfully validated Deluge connection'
|
||||
testdeluge.exposed = True
|
||||
|
||||
def testnewznab(self, name, host, ssl, apikey):
|
||||
logger.fdebug('ssl/verify: %s' % ssl)
|
||||
if 'ssl' == '0' or ssl == '1':
|
||||
|
|
Loading…
Add table
Reference in a new issue