FIX: (#1006) Fix Legacy mode for 32P not being able to properly pull in feed, FIX: Fix Auth mode for 32P erroring out when reading feed list

This commit is contained in:
evilhero 2015-05-14 05:33:40 -04:00
parent f41ee0f34e
commit 3528b88162
4 changed files with 65 additions and 49 deletions

View File

@ -646,36 +646,9 @@ def initialize():
PASSKEY_32P = check_setting_str(CFG, 'Torrents', 'passkey_32p', '')
if MODE_32P == 0 and RSSFEED_32P is not None:
#parse out the keys.
if ENABLE_32P and len(RSSFEED_32P) > 1:
userid_st = RSSFEED_32P.find('&user')
userid_en = RSSFEED_32P.find('&',userid_st+1)
if userid_en == -1:
USERID_32P = RSSFEED_32P[userid_st+6:]
else:
USERID_32P = RSSFEED_32P[userid_st+6:userid_en]
auth_st = RSSFEED_32P.find('&auth')
auth_en = RSSFEED_32P.find('&',auth_st+1)
if auth_en == -1:
AUTH_32P = RSSFEED_32P[auth_st+6:]
else:
AUTH_32P = RSSFEED_32P[auth_st+6:auth_en]
authkey_st = RSSFEED_32P.find('&authkey')
authkey_en = RSSFEED_32P.find('&',authkey_st+1)
if authkey_en == -1:
AUTHKEY_32P = RSSFEED_32P[authkey_st+9:]
else:
AUTHKEY_32P = RSSFEED_32P[authkey_st+9:authkey_en]
KEYS_32P = {}
KEYS_32P = {"user": USERID_32P,
"auth": AUTH_32P,
"authkey": AUTHKEY_32P,
"passkey": PASSKEY_32P}
KEYS_32P = helpers.parse_32pfeed(RSSFEED_32P)
USERNAME_32P = check_setting_str(CFG, 'Torrents', 'username_32p', '')
PASSWORD_32P = check_setting_str(CFG, 'Torrents', 'password_32p', '')

View File

@ -605,6 +605,7 @@ def apiremove(apistring, type):
#match = value_regex.search(apistring)
apiremoved = value_regex.sub("xUDONTNEEDTOKNOWTHISx", apistring)
#need to remove the urlencoded-portions as well in future
return apiremoved
def ComicSort(comicorder=None,sequence=None,imported=None):
@ -1700,6 +1701,38 @@ def torrent_create(site, linkid):
return url
def parse_32pfeed(rssfeedline):
KEYS_32P = {}
if mylar.ENABLE_32P and len(rssfeedline) > 1:
userid_st = rssfeedline.find('&user')
userid_en = rssfeedline.find('&',userid_st+1)
if userid_en == -1:
USERID_32P = rssfeedline[userid_st+6:]
else:
USERID_32P = rssfeedline[userid_st+6:userid_en]
auth_st = rssfeedline.find('&auth')
auth_en = rssfeedline.find('&',auth_st+1)
if auth_en == -1:
AUTH_32P = rssfeedline[auth_st+6:]
else:
AUTH_32P = rssfeedline[auth_st+6:auth_en]
authkey_st = rssfeedline.find('&authkey')
authkey_en = rssfeedline.find('&',authkey_st+1)
if authkey_en == -1:
AUTHKEY_32P = rssfeedline[authkey_st+9:]
else:
AUTHKEY_32P = rssfeedline[authkey_st+9:authkey_en]
KEYS_32P = {"user": USERID_32P,
"auth": AUTH_32P,
"authkey": AUTHKEY_32P,
"passkey": mylar.PASSKEY_32P}
return KEYS_32P
from threading import Thread
class ThreadWithReturnValue(Thread):

View File

@ -77,10 +77,6 @@ def torrents(pickfeed=None,seriesname=None,issue=None,feedinfo=None):
feedtype = None
if pickfeed == "1" and mylar.ENABLE_32P: # 32pages new releases feed.
if any( [mylar.USERNAME_32P is None, mylar.USERNAME_32P == '', mylar.PASSWORD_32P is None, mylar.PASSWORD_32P == ''] ):
logger.error('[RSS] Warning - you NEED to enter in your 32P Username and Password to use this option.')
lp=+1
continue
feed = 'https://32pag.es/feeds.php?feed=torrents_all&user=' + feedinfo['user'] + '&auth=' + feedinfo['auth'] + '&passkey=' + feedinfo['passkey'] + '&authkey=' + feedinfo['authkey']
feedtype = ' from the New Releases RSS Feed for comics'
elif pickfeed == "2" and srchterm is not None: # kat.ph search
@ -97,6 +93,9 @@ def torrents(pickfeed=None,seriesname=None,issue=None,feedinfo=None):
logger.warn('[32P] Searching is not available in 32p Legacy mode. Switch to Auth mode to use the search functionality.')
lp=+1
continue
#searchit = auth32p.info32p(searchterm=seriesname)
#searchresults = searchit.authenticate()
#logger.info('search results: ' + str(searchresults))
return
elif pickfeed == "5" and srchterm is not None: # kat.ph search (category:other since some 0-day comics initially get thrown there until categorized)
feed = kat_url + "usearch/" + str(srchterm) + "%20category%3Aother%20seeds%3A1/?rss=1"
@ -123,7 +122,7 @@ def torrents(pickfeed=None,seriesname=None,issue=None,feedinfo=None):
picksite = '32P'
i = 0
logger.fdebug('results: ' + str(feedme))
for entry in feedme['entries']:
if pickfeed == "3" or pickfeed == "6":
tmpsz = feedme.entries[i].enclosures[0]
@ -151,15 +150,15 @@ def torrents(pickfeed=None,seriesname=None,issue=None,feedinfo=None):
st_pub = feedme.entries[i].title.find('(')
st_end = feedme.entries[i].title.find(')')
pub = feedme.entries[i].title[st_pub+1:st_end] # +1 to not include (
logger.fdebug('publisher: ' + re.sub("'",'', pub).strip()) #publisher sometimes is given within quotes for some reason, strip 'em.
#logger.fdebug('publisher: ' + re.sub("'",'', pub).strip()) #publisher sometimes is given within quotes for some reason, strip 'em.
vol_find = feedme.entries[i].title.find('vol.')
series = feedme.entries[i].title[st_end+1:vol_find].strip()
logger.fdebug('series title: ' + series)
#logger.fdebug('series title: ' + series)
iss_st = feedme.entries[i].title.find(' - ', vol_find)
vol = re.sub('\.', '', feedme.entries[i].title[vol_find:iss_st]).strip()
logger.fdebug('volume #: ' + str(vol))
#logger.fdebug('volume #: ' + str(vol))
issue = feedme.entries[i].title[iss_st+3:].strip()
logger.fdebug('issue # : ' + str(issue))
#logger.fdebug('issue # : ' + str(issue))
#break it down to get the Size since it's available on THIS 32P feed only so far.
#when it becomes available in the new feeds, this will be working, for now it just nulls out.
@ -220,7 +219,7 @@ def torrents(pickfeed=None,seriesname=None,issue=None,feedinfo=None):
if feedtype is None:
logger.info('[' + picksite + '] there were ' + str(i) + ' results..')
else:
logger.info('[' + picksite + '] there were ' + str(i) + ' results ' + feedtype)
logger.info('[' + picksite + '] there were ' + str(i) + ' results' + feedtype)
totalcount += i
lp +=1
@ -697,18 +696,26 @@ def torsend2client(seriesname, issue, seriesyear, linkit, site):
verify = True
if any( [mylar.USERNAME_32P is None, mylar.USERNAME_32P == '', mylar.PASSWORD_32P is None, mylar.PASSWORD_32P == ''] ):
logger.error('[RSS] Unable to sign-on to 32P to validate settings and initiate download sequence. Please enter/check your username password in the configuration.')
return "fail"
elif mylar.PASSKEY_32P is None or mylar.AUTHKEY_32P is None or mylar.KEYS_32P is None:
if mylar.MODE_32P == 1:
if mylar.MODE_32P == 0:
if mylar.KEYS_32P is None or mylar.AUTHKEY_32P is None or mylar.PASSKEY_32P is None:
logger.warn('[32P] Unble to use to retrieve keys from provided RSS Feed. Make sure you have provided a CURRENT RSS Feed from 32P')
return "fail"
else:
logger.fdebug('[32P-AUTHENTICATION] 32P (Legacy) Authentication already done. Attempting to use existing keys.')
else:
if any( [mylar.USERNAME_32P is None, mylar.USERNAME_32P == '', mylar.PASSWORD_32P is None, mylar.PASSWORD_32P == ''] ):
logger.error('[RSS] Unable to sign-on to 32P to validate settings and initiate download sequence. Please enter/check your username password in the configuration.')
return "fail"
elif mylar.PASSKEY_32P is None or mylar.AUTHKEY_32P is None or mylar.KEYS_32P is None:
logger.fdebug('[32P-AUTHENTICATION] 32P (Auth Mode) Authentication enabled. Keys have not been established yet, attempting to gather.')
feed32p = auth32p.info32p(reauthenticate=True)
feedinfo = feed32p.authenticate()
if mylar.PASSKEY_32P is None or mylar.AUTHKEY_32P is None or mylar.KEYS_32P is None:
logger.error('[RSS] Unable to sign-on to 32P to validate settings and initiate download sequence. Please enter/check your username password in the configuration.')
return "fail"
else:
logger.warn('[32P] Unavailable to retrieve keys from provided RSS Feed. Make sure you have provided a CURRENT RSS Feed from 32P')
return "fail"
else:
logger.fdebug('[32P-AUTHENTICATION] 32P Authentication already done. Attempting to use existing keys.')
logger.fdebug('[32P-AUTHENTICATION] 32P (Auth Mode) Authentication already done. Attempting to use existing keys.')
payload = {'action': 'download',
'torrent_pass': mylar.PASSKEY_32P,

View File

@ -63,10 +63,10 @@ class tehMain():
if mylar.ENABLE_32P:
logger.info('[RSS] Initiating Torrent RSS Feed Check on 32P.')
if mylar.MODE_32P == 0:
logger.fdebug('[RSS] 32P mode set to Legacy mode. Monitoring New Releases feed only.')
if any( [mylar.PASSKEY_32P is None, mylar.PASSKEY_32P == '', mylar.RSSFEED_32P is None, mylar.RSSFEED_32P == ''] ):
logger.error('[RSS] Unable to validate information from provided RSS Feed. Verify that the feed provided is a current one.')
else:
logger.fdebug('[RSS] 32P mode set to Legacy mode. Monitoring New Releases feed only.')
rsscheck.torrents(pickfeed='1', feedinfo=mylar.KEYS_32P)
else:
logger.fdebug('[RSS] 32P mode set to Auth mode. Monitoring all personal notification feeds & New Releases feed')
@ -76,6 +76,9 @@ class tehMain():
if mylar.KEYS_32P is None:
feed32p = auth32p.info32p()
feedinfo = feed32p.authenticate()
else:
feedinfo = mylar.FEEDINFO_32P
if len(feedinfo) >0:
rsscheck.torrents(pickfeed='1', feedinfo=feedinfo[0])
x = 0