Check login after 1 hour
This commit is contained in:
@@ -86,6 +86,7 @@ class YarrProvider(Provider):
|
|||||||
sizeKb = ['kb', 'kib']
|
sizeKb = ['kb', 'kib']
|
||||||
|
|
||||||
login_opener = None
|
login_opener = None
|
||||||
|
last_login_check = 0
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
addEvent('provider.enabled_types', self.getEnabledProviderType)
|
addEvent('provider.enabled_types', self.getEnabledProviderType)
|
||||||
@@ -101,6 +102,22 @@ class YarrProvider(Provider):
|
|||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
|
|
||||||
|
# Check if we are still logged in every hour
|
||||||
|
now = time.time()
|
||||||
|
if self.login_opener and self.last_login_check < (now - 3600):
|
||||||
|
try:
|
||||||
|
output = self.urlopen(self.urls['login_check'])
|
||||||
|
if self.loginCheckSuccess(output):
|
||||||
|
self.last_login_check = now
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
self.login_opener = None
|
||||||
|
except:
|
||||||
|
self.login_opener = None
|
||||||
|
|
||||||
|
if self.login_opener:
|
||||||
|
return True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cookiejar = cookielib.CookieJar()
|
cookiejar = cookielib.CookieJar()
|
||||||
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))
|
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))
|
||||||
@@ -119,15 +136,19 @@ class YarrProvider(Provider):
|
|||||||
except:
|
except:
|
||||||
error = traceback.format_exc()
|
error = traceback.format_exc()
|
||||||
|
|
||||||
|
self.login_opener = None
|
||||||
log.error('Failed to login %s: %s', (self.getName(), error))
|
log.error('Failed to login %s: %s', (self.getName(), error))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def loginSuccess(self, output):
|
def loginSuccess(self, output):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def loginCheckSuccess(self, output):
|
||||||
|
return True
|
||||||
|
|
||||||
def loginDownload(self, url = '', nzb_id = ''):
|
def loginDownload(self, url = '', nzb_id = ''):
|
||||||
try:
|
try:
|
||||||
if not self.login_opener and not self.login():
|
if not self.login():
|
||||||
log.error('Failed downloading from %s', self.getName())
|
log.error('Failed downloading from %s', self.getName())
|
||||||
return self.urlopen(url, opener = self.login_opener)
|
return self.urlopen(url, opener = self.login_opener)
|
||||||
except:
|
except:
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class FTDWorld(NZBProvider):
|
|||||||
'detail': 'http://ftdworld.net/spotinfo.php?id=%s',
|
'detail': 'http://ftdworld.net/spotinfo.php?id=%s',
|
||||||
'download': 'http://ftdworld.net/cgi-bin/nzbdown.pl?fileID=%s',
|
'download': 'http://ftdworld.net/cgi-bin/nzbdown.pl?fileID=%s',
|
||||||
'login': 'http://ftdworld.net/api/login.php',
|
'login': 'http://ftdworld.net/api/login.php',
|
||||||
|
'login_check': 'http://ftdworld.net/api/login.php',
|
||||||
}
|
}
|
||||||
|
|
||||||
http_time_between_calls = 3 #seconds
|
http_time_between_calls = 3 #seconds
|
||||||
@@ -78,3 +79,6 @@ class FTDWorld(NZBProvider):
|
|||||||
return json.loads(output).get('goodToGo', False)
|
return json.loads(output).get('goodToGo', False)
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
loginCheckSuccess = loginSuccess
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class HDBits(TorrentProvider):
|
|||||||
'detail' : 'https://hdbits.org/details.php?id=%s&source=browse',
|
'detail' : 'https://hdbits.org/details.php?id=%s&source=browse',
|
||||||
'search' : 'https://hdbits.org/json_search.php?imdb=%s',
|
'search' : 'https://hdbits.org/json_search.php?imdb=%s',
|
||||||
'download' : 'https://hdbits.org/download.php/%s.torrent?id=%s&passkey=%s&source=details.browse',
|
'download' : 'https://hdbits.org/download.php/%s.torrent?id=%s&passkey=%s&source=details.browse',
|
||||||
|
'login_check': 'http://hdbits.org/inbox.php',
|
||||||
}
|
}
|
||||||
|
|
||||||
http_time_between_calls = 1 #seconds
|
http_time_between_calls = 1 #seconds
|
||||||
@@ -53,3 +54,5 @@ class HDBits(TorrentProvider):
|
|||||||
|
|
||||||
def loginSuccess(self, output):
|
def loginSuccess(self, output):
|
||||||
return '/logout.php' in output.lower()
|
return '/logout.php' in output.lower()
|
||||||
|
|
||||||
|
loginCheckSuccess = loginSuccess
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class IPTorrents(TorrentProvider):
|
|||||||
'base_url' : 'http://www.iptorrents.com',
|
'base_url' : 'http://www.iptorrents.com',
|
||||||
'login' : 'http://www.iptorrents.com/torrents/',
|
'login' : 'http://www.iptorrents.com/torrents/',
|
||||||
'search' : 'http://www.iptorrents.com/torrents/?l%d=1%s&q=%s&qf=ti',
|
'search' : 'http://www.iptorrents.com/torrents/?l%d=1%s&q=%s&qf=ti',
|
||||||
|
'login_check': 'http://www.iptorrents.com/inbox.php',
|
||||||
}
|
}
|
||||||
|
|
||||||
cat_ids = [
|
cat_ids = [
|
||||||
@@ -72,12 +73,15 @@ class IPTorrents(TorrentProvider):
|
|||||||
except:
|
except:
|
||||||
log.error('Failed to parsing %s: %s', (self.getName(), traceback.format_exc()))
|
log.error('Failed to parsing %s: %s', (self.getName(), traceback.format_exc()))
|
||||||
|
|
||||||
def loginSuccess(self, output):
|
|
||||||
return 'don\'t have an account' not in output.lower()
|
|
||||||
|
|
||||||
def getLoginParams(self):
|
def getLoginParams(self):
|
||||||
return tryUrlencode({
|
return tryUrlencode({
|
||||||
'username': self.conf('username'),
|
'username': self.conf('username'),
|
||||||
'password': self.conf('password'),
|
'password': self.conf('password'),
|
||||||
'login': 'submit',
|
'login': 'submit',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def loginSuccess(self, output):
|
||||||
|
return 'don\'t have an account' not in output.lower()
|
||||||
|
|
||||||
|
def loginCheckSuccess(self, output):
|
||||||
|
return '/logout.php' in output.lower()
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ class PassThePopcorn(TorrentProvider):
|
|||||||
'detail': 'https://tls.passthepopcorn.me/torrents.php?torrentid=%s',
|
'detail': 'https://tls.passthepopcorn.me/torrents.php?torrentid=%s',
|
||||||
'torrent': 'https://tls.passthepopcorn.me/torrents.php',
|
'torrent': 'https://tls.passthepopcorn.me/torrents.php',
|
||||||
'login': 'https://tls.passthepopcorn.me/ajax.php?action=login',
|
'login': 'https://tls.passthepopcorn.me/ajax.php?action=login',
|
||||||
|
'login_check': 'https://tls.passthepopcorn.me/ajax.php?action=login',
|
||||||
'search': 'https://tls.passthepopcorn.me/search/%s/0/7/%d'
|
'search': 'https://tls.passthepopcorn.me/search/%s/0/7/%d'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,18 +53,6 @@ class PassThePopcorn(TorrentProvider):
|
|||||||
'cam': {'Source': ['CAM']}
|
'cam': {'Source': ['CAM']}
|
||||||
}
|
}
|
||||||
|
|
||||||
class NotLoggedInHTTPError(urllib2.HTTPError):
|
|
||||||
def __init__(self, url, code, msg, headers, fp):
|
|
||||||
urllib2.HTTPError.__init__(self, url, code, msg, headers, fp)
|
|
||||||
|
|
||||||
class PTPHTTPRedirectHandler(urllib2.HTTPRedirectHandler):
|
|
||||||
def http_error_302(self, req, fp, code, msg, headers):
|
|
||||||
log.debug("302 detected; redirected to %s", headers['Location'])
|
|
||||||
if (headers['Location'] != 'login.php'):
|
|
||||||
return urllib2.HTTPRedirectHandler.http_error_302(self, req, fp, code, msg, headers)
|
|
||||||
else:
|
|
||||||
raise PassThePopcorn.NotLoggedInHTTPError(req.get_full_url(), code, msg, headers, fp)
|
|
||||||
|
|
||||||
def _search(self, movie, quality, results):
|
def _search(self, movie, quality, results):
|
||||||
|
|
||||||
movie_title = getTitle(movie['library'])
|
movie_title = getTitle(movie['library'])
|
||||||
@@ -76,7 +65,7 @@ class PassThePopcorn(TorrentProvider):
|
|||||||
})
|
})
|
||||||
|
|
||||||
# Do login for the cookies
|
# Do login for the cookies
|
||||||
if not self.login_opener and not self.login():
|
if not self.login():
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -142,34 +131,6 @@ class PassThePopcorn(TorrentProvider):
|
|||||||
except:
|
except:
|
||||||
log.error('Failed getting results from %s: %s', (self.getName(), traceback.format_exc()))
|
log.error('Failed getting results from %s: %s', (self.getName(), traceback.format_exc()))
|
||||||
|
|
||||||
def login(self):
|
|
||||||
|
|
||||||
cookieprocessor = urllib2.HTTPCookieProcessor(cookielib.CookieJar())
|
|
||||||
opener = urllib2.build_opener(cookieprocessor, PassThePopcorn.PTPHTTPRedirectHandler())
|
|
||||||
opener.addheaders = [
|
|
||||||
('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.75 Safari/537.1'),
|
|
||||||
('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'),
|
|
||||||
('Accept-Language', 'en-gb,en;q=0.5'),
|
|
||||||
('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'),
|
|
||||||
('Keep-Alive', '115'),
|
|
||||||
('Connection', 'keep-alive'),
|
|
||||||
('Cache-Control', 'max-age=0'),
|
|
||||||
]
|
|
||||||
|
|
||||||
try:
|
|
||||||
response = opener.open(self.urls['login'], self.getLoginParams())
|
|
||||||
except urllib2.URLError as e:
|
|
||||||
log.error('Login to PassThePopcorn failed: %s', e)
|
|
||||||
return False
|
|
||||||
|
|
||||||
if response.getcode() == 200:
|
|
||||||
log.debug('Login HTTP status 200; seems successful')
|
|
||||||
self.login_opener = opener
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
log.error('Login to PassThePopcorn failed: returned code %d', response.getcode())
|
|
||||||
return False
|
|
||||||
|
|
||||||
def torrentMeetsQualitySpec(self, torrent, quality):
|
def torrentMeetsQualitySpec(self, torrent, quality):
|
||||||
|
|
||||||
if not quality in self.post_search_filters:
|
if not quality in self.post_search_filters:
|
||||||
@@ -244,3 +205,11 @@ class PassThePopcorn(TorrentProvider):
|
|||||||
'keeplogged': '1',
|
'keeplogged': '1',
|
||||||
'login': 'Login'
|
'login': 'Login'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def loginSuccess(self, output):
|
||||||
|
try:
|
||||||
|
return json.loads(output).get('Result', '').lower() == 'ok'
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
|
||||||
|
loginCheckSuccess = loginSuccess
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ class SceneAccess(TorrentProvider):
|
|||||||
|
|
||||||
urls = {
|
urls = {
|
||||||
'test': 'https://www.sceneaccess.eu/',
|
'test': 'https://www.sceneaccess.eu/',
|
||||||
'login' : 'https://www.sceneaccess.eu/login',
|
'login': 'https://www.sceneaccess.eu/login',
|
||||||
|
'login_check': 'https://sceneaccess.eu/inbox',
|
||||||
'detail': 'https://www.sceneaccess.eu/details?id=%s',
|
'detail': 'https://www.sceneaccess.eu/details?id=%s',
|
||||||
'search': 'https://www.sceneaccess.eu/browse?method=2&c%d=%d',
|
'search': 'https://www.sceneaccess.eu/browse?method=2&c%d=%d',
|
||||||
'download': 'https://www.sceneaccess.eu/%s',
|
'download': 'https://www.sceneaccess.eu/%s',
|
||||||
@@ -40,7 +41,7 @@ class SceneAccess(TorrentProvider):
|
|||||||
url = "%s&%s" % (url, arguments)
|
url = "%s&%s" % (url, arguments)
|
||||||
|
|
||||||
# Do login for the cookies
|
# Do login for the cookies
|
||||||
if not self.login_opener and not self.login():
|
if not self.login():
|
||||||
return
|
return
|
||||||
|
|
||||||
data = self.getHTMLData(url, opener = self.login_opener)
|
data = self.getHTMLData(url, opener = self.login_opener)
|
||||||
@@ -91,3 +92,8 @@ class SceneAccess(TorrentProvider):
|
|||||||
|
|
||||||
item['description'] = description
|
item['description'] = description
|
||||||
return item
|
return item
|
||||||
|
|
||||||
|
def loginSuccess(self, output):
|
||||||
|
return '/inbox' in output.lower()
|
||||||
|
|
||||||
|
loginCheckSuccess = loginSuccess
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class SceneHD(TorrentProvider):
|
|||||||
url = "%s&%s" % (self.urls['search'], arguments)
|
url = "%s&%s" % (self.urls['search'], arguments)
|
||||||
|
|
||||||
# Cookie login
|
# Cookie login
|
||||||
if not self.login_opener and not self.login():
|
if not self.login():
|
||||||
return
|
return
|
||||||
|
|
||||||
data = self.getHTMLData(url, opener = self.login_opener)
|
data = self.getHTMLData(url, opener = self.login_opener)
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ class TorrentDay(TorrentProvider):
|
|||||||
|
|
||||||
urls = {
|
urls = {
|
||||||
'test': 'http://www.td.af/',
|
'test': 'http://www.td.af/',
|
||||||
'login' : 'http://www.td.af/torrents/',
|
'login': 'http://www.td.af/torrents/',
|
||||||
|
'login_check': 'http://www.torrentday.com/userdetails.php',
|
||||||
'detail': 'http://www.td.af/details.php?id=%s',
|
'detail': 'http://www.td.af/details.php?id=%s',
|
||||||
'search': 'http://www.td.af/V3/API/API.php',
|
'search': 'http://www.td.af/V3/API/API.php',
|
||||||
'download': 'http://www.td.af/download.php/%s/%s',
|
'download': 'http://www.td.af/download.php/%s/%s',
|
||||||
@@ -62,3 +63,6 @@ class TorrentDay(TorrentProvider):
|
|||||||
|
|
||||||
def loginSuccess(self, output):
|
def loginSuccess(self, output):
|
||||||
return 'Password not correct' not in output
|
return 'Password not correct' not in output
|
||||||
|
|
||||||
|
def loginCheckSuccess(self, output):
|
||||||
|
return 'logout.php' in output.lower()
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ class TorrentLeech(TorrentProvider):
|
|||||||
urls = {
|
urls = {
|
||||||
'test' : 'http://www.torrentleech.org/',
|
'test' : 'http://www.torrentleech.org/',
|
||||||
'login' : 'http://www.torrentleech.org/user/account/login/',
|
'login' : 'http://www.torrentleech.org/user/account/login/',
|
||||||
|
'login_check': 'http://torrentleech.org/user/messages',
|
||||||
'detail' : 'http://www.torrentleech.org/torrent/%s',
|
'detail' : 'http://www.torrentleech.org/torrent/%s',
|
||||||
'search' : 'http://www.torrentleech.org/torrents/browse/index/query/%s/categories/%d',
|
'search' : 'http://www.torrentleech.org/torrents/browse/index/query/%s/categories/%d',
|
||||||
'download' : 'http://www.torrentleech.org%s',
|
'download' : 'http://www.torrentleech.org%s',
|
||||||
@@ -77,3 +78,5 @@ class TorrentLeech(TorrentProvider):
|
|||||||
|
|
||||||
def loginSuccess(self, output):
|
def loginSuccess(self, output):
|
||||||
return '/user/account/logout' in output.lower() or 'welcome back' in output.lower()
|
return '/user/account/logout' in output.lower() or 'welcome back' in output.lower()
|
||||||
|
|
||||||
|
loginCheckSuccess = loginSuccess
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ class TorrentShack(TorrentProvider):
|
|||||||
urls = {
|
urls = {
|
||||||
'test' : 'http://www.torrentshack.net/',
|
'test' : 'http://www.torrentshack.net/',
|
||||||
'login' : 'http://www.torrentshack.net/login.php',
|
'login' : 'http://www.torrentshack.net/login.php',
|
||||||
|
'login_check': 'http://www.torrentshack.net/inbox.php',
|
||||||
'detail' : 'http://www.torrentshack.net/torrent/%s',
|
'detail' : 'http://www.torrentshack.net/torrent/%s',
|
||||||
'search' : 'http://www.torrentshack.net/torrents.php?searchstr=%s&filter_cat[%d]=1',
|
'search' : 'http://www.torrentshack.net/torrents.php?searchstr=%s&filter_cat[%d]=1',
|
||||||
'download' : 'http://www.torrentshack.net/%s',
|
'download' : 'http://www.torrentshack.net/%s',
|
||||||
@@ -79,3 +80,5 @@ class TorrentShack(TorrentProvider):
|
|||||||
|
|
||||||
def loginSuccess(self, output):
|
def loginSuccess(self, output):
|
||||||
return 'logout.php' in output.lower()
|
return 'logout.php' in output.lower()
|
||||||
|
|
||||||
|
loginCheckSuccess = loginSuccess
|
||||||
|
|||||||
Reference in New Issue
Block a user