IMP: 32P legacy mode (rss feed only) and Auth mode (user/pass) available now. With Auth mode, will monitor all of personal notification feeds, IMP: Changed access methods to 32P for retrieving links, FIX:(#1007) Fixed error for one-off downloading via weekly pull list, FIX: (#1004) Fix for post-processing errors (missing files), FIX: (#1001) Extra scripts & pre-scripts will now accept bash scripts, FIX: Annuals were being incorrectly tallied in Have total as well as not having status correctly updated, IMP: Fixed some discrepencies with the provider_order generation line, IMP: Made some additional adjustments to the file-checking to account for some additional variations in naming, FIX: Fixed traceback errors when folder monitor was running and wouldn't be able to complete the post-processing properly, FIX: Cleanup code and some other small fixes....
2015-05-09 02:39:28 +00:00
|
|
|
import urllib2
|
|
|
|
import lib.requests as requests
|
|
|
|
import re
|
|
|
|
from bs4 import BeautifulSoup
|
|
|
|
import mylar
|
|
|
|
from mylar import logger
|
|
|
|
|
2015-05-22 08:32:51 +00:00
|
|
|
|
IMP: 32P legacy mode (rss feed only) and Auth mode (user/pass) available now. With Auth mode, will monitor all of personal notification feeds, IMP: Changed access methods to 32P for retrieving links, FIX:(#1007) Fixed error for one-off downloading via weekly pull list, FIX: (#1004) Fix for post-processing errors (missing files), FIX: (#1001) Extra scripts & pre-scripts will now accept bash scripts, FIX: Annuals were being incorrectly tallied in Have total as well as not having status correctly updated, IMP: Fixed some discrepencies with the provider_order generation line, IMP: Made some additional adjustments to the file-checking to account for some additional variations in naming, FIX: Fixed traceback errors when folder monitor was running and wouldn't be able to complete the post-processing properly, FIX: Cleanup code and some other small fixes....
2015-05-09 02:39:28 +00:00
|
|
|
class info32p(object):
|
|
|
|
|
|
|
|
def __init__(self, reauthenticate=False, searchterm=None):
|
|
|
|
|
|
|
|
self.module = '[32P-AUTHENTICATION]'
|
|
|
|
self.url = 'https://32pag.es/login.php'
|
2015-05-22 08:32:51 +00:00
|
|
|
self.payload = {'username': mylar.USERNAME_32P,
|
IMP: 32P legacy mode (rss feed only) and Auth mode (user/pass) available now. With Auth mode, will monitor all of personal notification feeds, IMP: Changed access methods to 32P for retrieving links, FIX:(#1007) Fixed error for one-off downloading via weekly pull list, FIX: (#1004) Fix for post-processing errors (missing files), FIX: (#1001) Extra scripts & pre-scripts will now accept bash scripts, FIX: Annuals were being incorrectly tallied in Have total as well as not having status correctly updated, IMP: Fixed some discrepencies with the provider_order generation line, IMP: Made some additional adjustments to the file-checking to account for some additional variations in naming, FIX: Fixed traceback errors when folder monitor was running and wouldn't be able to complete the post-processing properly, FIX: Cleanup code and some other small fixes....
2015-05-09 02:39:28 +00:00
|
|
|
'password': mylar.PASSWORD_32P}
|
|
|
|
self.headers = {'Content-type': 'application/x-www-form-urlencoded',
|
|
|
|
'Accept-Charset': 'utf-8',
|
|
|
|
'User-Agent': 'Mozilla/5.0'}
|
|
|
|
self.reauthenticate = reauthenticate
|
|
|
|
self.searchterm = searchterm
|
|
|
|
|
|
|
|
def authenticate(self):
|
|
|
|
|
|
|
|
feedinfo = []
|
|
|
|
|
|
|
|
with requests.session() as s:
|
|
|
|
verify = True
|
|
|
|
|
|
|
|
if not verify:
|
|
|
|
#32P throws back an insecure warning because it can't validate against the CA. The below suppresses the message just for 32P instead of being displa$
|
|
|
|
from lib.requests.packages.urllib3.exceptions import InsecureRequestWarning
|
|
|
|
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
|
|
|
|
|
|
|
|
|
|
|
# fetch the login page
|
|
|
|
|
|
|
|
s.headers = self.headers
|
|
|
|
try:
|
|
|
|
s.get(self.url, verify=verify)
|
|
|
|
except requests.exceptions.SSLError as e:
|
|
|
|
logger.error(self.module + ' Unable to establish connection to 32P: ' + e)
|
|
|
|
|
|
|
|
# post to the login form
|
|
|
|
r = s.post(self.url, data=self.payload, verify=verify)
|
|
|
|
|
|
|
|
#need a way to find response code (200=OK), but returns 200 for everything even failed signons (returns a blank page)
|
|
|
|
#logger.info('[32P] response: ' + str(r.content))
|
|
|
|
|
|
|
|
if self.searchterm:
|
|
|
|
logger.info('[32P] Successfully authenticated. Initiating search for : ' + self.searchterm)
|
|
|
|
return self.search32p(s)
|
|
|
|
soup = BeautifulSoup(r.content)
|
2015-05-22 08:32:51 +00:00
|
|
|
all_script = soup.find_all("script", {"src": False})
|
|
|
|
all_script2 = soup.find_all("link", {"rel": "alternate"})
|
IMP: 32P legacy mode (rss feed only) and Auth mode (user/pass) available now. With Auth mode, will monitor all of personal notification feeds, IMP: Changed access methods to 32P for retrieving links, FIX:(#1007) Fixed error for one-off downloading via weekly pull list, FIX: (#1004) Fix for post-processing errors (missing files), FIX: (#1001) Extra scripts & pre-scripts will now accept bash scripts, FIX: Annuals were being incorrectly tallied in Have total as well as not having status correctly updated, IMP: Fixed some discrepencies with the provider_order generation line, IMP: Made some additional adjustments to the file-checking to account for some additional variations in naming, FIX: Fixed traceback errors when folder monitor was running and wouldn't be able to complete the post-processing properly, FIX: Cleanup code and some other small fixes....
2015-05-09 02:39:28 +00:00
|
|
|
|
|
|
|
for ind_s in all_script:
|
|
|
|
all_value = str(ind_s)
|
|
|
|
all_items = all_value.split()
|
|
|
|
auth_found = False
|
|
|
|
user_found = False
|
|
|
|
for al in all_items:
|
|
|
|
if al == 'authkey':
|
|
|
|
auth_found = True
|
|
|
|
elif auth_found == True and al != '=':
|
2015-05-22 08:32:51 +00:00
|
|
|
authkey = re.sub('["/;]', '', al).strip()
|
IMP: 32P legacy mode (rss feed only) and Auth mode (user/pass) available now. With Auth mode, will monitor all of personal notification feeds, IMP: Changed access methods to 32P for retrieving links, FIX:(#1007) Fixed error for one-off downloading via weekly pull list, FIX: (#1004) Fix for post-processing errors (missing files), FIX: (#1001) Extra scripts & pre-scripts will now accept bash scripts, FIX: Annuals were being incorrectly tallied in Have total as well as not having status correctly updated, IMP: Fixed some discrepencies with the provider_order generation line, IMP: Made some additional adjustments to the file-checking to account for some additional variations in naming, FIX: Fixed traceback errors when folder monitor was running and wouldn't be able to complete the post-processing properly, FIX: Cleanup code and some other small fixes....
2015-05-09 02:39:28 +00:00
|
|
|
auth_found = False
|
|
|
|
logger.fdebug(self.module + ' Authkey found: ' + str(authkey))
|
|
|
|
if al == 'userid':
|
|
|
|
user_found = True
|
|
|
|
elif user_found == True and al != '=':
|
2015-05-22 08:32:51 +00:00
|
|
|
userid = re.sub('["/;]', '', al).strip()
|
IMP: 32P legacy mode (rss feed only) and Auth mode (user/pass) available now. With Auth mode, will monitor all of personal notification feeds, IMP: Changed access methods to 32P for retrieving links, FIX:(#1007) Fixed error for one-off downloading via weekly pull list, FIX: (#1004) Fix for post-processing errors (missing files), FIX: (#1001) Extra scripts & pre-scripts will now accept bash scripts, FIX: Annuals were being incorrectly tallied in Have total as well as not having status correctly updated, IMP: Fixed some discrepencies with the provider_order generation line, IMP: Made some additional adjustments to the file-checking to account for some additional variations in naming, FIX: Fixed traceback errors when folder monitor was running and wouldn't be able to complete the post-processing properly, FIX: Cleanup code and some other small fixes....
2015-05-09 02:39:28 +00:00
|
|
|
user_found = False
|
|
|
|
logger.fdebug(self.module + ' Userid found: ' + str(userid))
|
|
|
|
|
|
|
|
authfound = False
|
|
|
|
logger.info(self.module + ' Atttempting to integrate with all of your 32P Notification feeds.')
|
|
|
|
|
|
|
|
for al in all_script2:
|
|
|
|
alurl = al['href']
|
|
|
|
if 'auth=' in alurl and 'torrents_notify' in alurl and not authfound:
|
|
|
|
f1 = alurl.find('auth=')
|
2015-05-22 08:32:51 +00:00
|
|
|
f2 = alurl.find('&', f1 + 1)
|
|
|
|
auth = alurl[f1 +5:f2]
|
IMP: 32P legacy mode (rss feed only) and Auth mode (user/pass) available now. With Auth mode, will monitor all of personal notification feeds, IMP: Changed access methods to 32P for retrieving links, FIX:(#1007) Fixed error for one-off downloading via weekly pull list, FIX: (#1004) Fix for post-processing errors (missing files), FIX: (#1001) Extra scripts & pre-scripts will now accept bash scripts, FIX: Annuals were being incorrectly tallied in Have total as well as not having status correctly updated, IMP: Fixed some discrepencies with the provider_order generation line, IMP: Made some additional adjustments to the file-checking to account for some additional variations in naming, FIX: Fixed traceback errors when folder monitor was running and wouldn't be able to complete the post-processing properly, FIX: Cleanup code and some other small fixes....
2015-05-09 02:39:28 +00:00
|
|
|
logger.fdebug(self.module + ' Auth:' + str(auth))
|
|
|
|
authfound = True
|
|
|
|
p1 = alurl.find('passkey=')
|
2015-05-22 08:32:51 +00:00
|
|
|
p2 = alurl.find('&', p1 + 1)
|
|
|
|
passkey = alurl[p1 +8:p2]
|
IMP: 32P legacy mode (rss feed only) and Auth mode (user/pass) available now. With Auth mode, will monitor all of personal notification feeds, IMP: Changed access methods to 32P for retrieving links, FIX:(#1007) Fixed error for one-off downloading via weekly pull list, FIX: (#1004) Fix for post-processing errors (missing files), FIX: (#1001) Extra scripts & pre-scripts will now accept bash scripts, FIX: Annuals were being incorrectly tallied in Have total as well as not having status correctly updated, IMP: Fixed some discrepencies with the provider_order generation line, IMP: Made some additional adjustments to the file-checking to account for some additional variations in naming, FIX: Fixed traceback errors when folder monitor was running and wouldn't be able to complete the post-processing properly, FIX: Cleanup code and some other small fixes....
2015-05-09 02:39:28 +00:00
|
|
|
logger.fdebug(self.module + ' Passkey:' + str(passkey))
|
|
|
|
if self.reauthenticate: break
|
|
|
|
|
|
|
|
if 'torrents_notify' in alurl and ('torrents_notify_' + str(passkey)) not in alurl:
|
|
|
|
notifyname_st = alurl.find('name=')
|
2015-05-22 08:32:51 +00:00
|
|
|
notifyname_en = alurl.find('&', notifyname_st +1)
|
IMP: 32P legacy mode (rss feed only) and Auth mode (user/pass) available now. With Auth mode, will monitor all of personal notification feeds, IMP: Changed access methods to 32P for retrieving links, FIX:(#1007) Fixed error for one-off downloading via weekly pull list, FIX: (#1004) Fix for post-processing errors (missing files), FIX: (#1001) Extra scripts & pre-scripts will now accept bash scripts, FIX: Annuals were being incorrectly tallied in Have total as well as not having status correctly updated, IMP: Fixed some discrepencies with the provider_order generation line, IMP: Made some additional adjustments to the file-checking to account for some additional variations in naming, FIX: Fixed traceback errors when folder monitor was running and wouldn't be able to complete the post-processing properly, FIX: Cleanup code and some other small fixes....
2015-05-09 02:39:28 +00:00
|
|
|
if notifyname_en == -1: notifyname_en = len(alurl)
|
2015-05-22 08:32:51 +00:00
|
|
|
notifyname = alurl[notifyname_st +5:notifyname_en]
|
IMP: 32P legacy mode (rss feed only) and Auth mode (user/pass) available now. With Auth mode, will monitor all of personal notification feeds, IMP: Changed access methods to 32P for retrieving links, FIX:(#1007) Fixed error for one-off downloading via weekly pull list, FIX: (#1004) Fix for post-processing errors (missing files), FIX: (#1001) Extra scripts & pre-scripts will now accept bash scripts, FIX: Annuals were being incorrectly tallied in Have total as well as not having status correctly updated, IMP: Fixed some discrepencies with the provider_order generation line, IMP: Made some additional adjustments to the file-checking to account for some additional variations in naming, FIX: Fixed traceback errors when folder monitor was running and wouldn't be able to complete the post-processing properly, FIX: Cleanup code and some other small fixes....
2015-05-09 02:39:28 +00:00
|
|
|
notifynumber_st = alurl.find('torrents_notify_')
|
2015-05-22 08:32:51 +00:00
|
|
|
notifynumber_en = alurl.find('_', notifynumber_st +17)
|
IMP: 32P legacy mode (rss feed only) and Auth mode (user/pass) available now. With Auth mode, will monitor all of personal notification feeds, IMP: Changed access methods to 32P for retrieving links, FIX:(#1007) Fixed error for one-off downloading via weekly pull list, FIX: (#1004) Fix for post-processing errors (missing files), FIX: (#1001) Extra scripts & pre-scripts will now accept bash scripts, FIX: Annuals were being incorrectly tallied in Have total as well as not having status correctly updated, IMP: Fixed some discrepencies with the provider_order generation line, IMP: Made some additional adjustments to the file-checking to account for some additional variations in naming, FIX: Fixed traceback errors when folder monitor was running and wouldn't be able to complete the post-processing properly, FIX: Cleanup code and some other small fixes....
2015-05-09 02:39:28 +00:00
|
|
|
notifynumber = alurl[notifynumber_st:notifynumber_en]
|
|
|
|
logger.fdebug(self.module + ' [NOTIFICATION: ' + str(notifyname) + '] Notification ID: ' + str(notifynumber))
|
|
|
|
|
|
|
|
#generate the rss-url here
|
|
|
|
feedinfo.append({'feed': notifynumber + '_' + str(passkey),
|
|
|
|
'feedname': notifyname,
|
|
|
|
'user': userid,
|
|
|
|
'auth': auth,
|
|
|
|
'passkey': passkey,
|
|
|
|
'authkey': authkey})
|
|
|
|
|
|
|
|
#set the keys here that will be used to download.
|
|
|
|
mylar.PASSKEY_32P = passkey
|
|
|
|
mylar.AUTHKEY_32P = authkey # probably not needed here.
|
|
|
|
mylar.KEYS_32P = {}
|
|
|
|
mylar.KEYS_32P = {"user": userid,
|
|
|
|
"auth": auth,
|
|
|
|
"passkey": passkey,
|
|
|
|
"authkey": authkey}
|
|
|
|
|
|
|
|
if self.reauthenticate:
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
mylar.FEEDINFO_32P = feedinfo
|
|
|
|
return feedinfo
|