Skip to content

Commit

Permalink
Properly fix Premium+ Detection (#19)
Browse files Browse the repository at this point in the history
* Properly fix Premium+ Detection

Move the Premium+ check to outside the Premium check (regex is looking
for exact match).

* Expand login fail check

Add status code 200 as a possible success response code.  200 is really
only applicible to Guest logins so we also check that too.  Logging in
normally still responds with 302 so we don't want to change that at all.
  • Loading branch information
shinji257 authored and jaw20 committed Apr 21, 2017
1 parent 929e76a commit 616521c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions crunchy-xml-decoder/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ def getuserstatus(session=''):
if re.search(re.escape(' ga(\'set\', \'dimension5\', \'registered\');'), site):
status = 'Free Member'
elif re.search(re.escape(' ga(\'set\', \'dimension6\', \'premium\');'), site):
if re.search(re.escape(' ga(\'set\', \'dimension6\', \'premiumplus\');'), site):
status = 'Premium+ Member'
else:
status = 'Premium Member'
status = 'Premium Member'
elif re.search(re.escape(' ga(\'set\', \'dimension6\', \'premiumplus\');'), site):
status = 'Premium+ Member'
if status != 'Guest':
user1 = re.findall('<a href=\"/user/(.+)\" ', site).pop()
return [status,user1]
Expand All @@ -48,7 +47,7 @@ def login(username, password):
'login_form[_token]': token}

res_post = session.post('https://www.crunchyroll.com/login', data=payload, headers=headers, allow_redirects = False)
if res_post.status_code != 302:
if not (res_post.status_code == 302 or (res_post.status_code == 200 and username == '')):
print 'Login failed'
sys.exit()

Expand Down

0 comments on commit 616521c

Please sign in to comment.