Skip to content

Commit

Permalink
Added validation for V.I.P. account status in titulky provider
Browse files Browse the repository at this point in the history
  • Loading branch information
sambartik committed Jan 2, 2022
1 parent 68a9f2f commit 3653ef1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions libs/subliminal_patch/providers/titulky.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import re
import zipfile
from random import randint
from urllib.parse import urlparse, parse_qs
from threading import Thread

import rarfile
Expand Down Expand Up @@ -266,9 +267,14 @@ def login(self):
allow_redirects=False,
timeout=self.timeout)

location_qs = parse_qs(urlparse(res.headers['Location']).query)

# If the response is a redirect and doesnt point to an error message page, then we are logged in
if res.status_code == 302 and 'msg_type=i' in res.headers['Location']:
return True
if res.status_code == 302 and location_qs['msg_type'][0] == 'i':
if 'omezené' in location_qs['msg'][0]:
raise AuthenticationError("V.I.P. account is required for this provider to work!")
else:
return True
else:
raise AuthenticationError("Login failed")

Expand All @@ -279,8 +285,10 @@ def logout(self):
allow_redirects=False,
timeout=self.timeout)

location_qs = parse_qs(urlparse(res.headers['Location']).query)

# If the response is a redirect and doesnt point to an error message page, then we are logged out
if res.status_code == 302 and 'msg_type=i' in res.headers['Location']:
if res.status_code == 302 and location_qs['msg_type'][0] == 'i':
return True
else:
raise AuthenticationError("Logout failed.")
Expand Down

0 comments on commit 3653ef1

Please sign in to comment.