Fix HTTP 422 error when using Plex Username and Password.

Change support mapping Linux to Windows paths.
Change remove redundancy from PiSexy.
This commit is contained in:
JackDandy 2018-05-07 21:09:31 +01:00
parent 5d11c3456c
commit c0c793e015
4 changed files with 17 additions and 12 deletions

View file

@ -1,4 +1,9 @@
### 0.16.4 (2018-05-03 12:00:00 UTC)
### 0.16.5 (2018-05-07 21:15:00 UTC)
* Fix HTTP 422 error when using Plex Username and Password
### 0.16.4 (2018-05-03 12:00:00 UTC)
* Fix PiSexy torrent provider

View file

@ -132,7 +132,7 @@ class Plex:
'X-Plex-Username': user
},
json=True,
data=urlencode({b'user[login]': user, b'user[password]': passw}).encode('utf-8')
post_data=urlencode({b'user[login]': user, b'user[password]': passw}).encode('utf-8')
)['user']['authentication_token']
except IndexError:
self.log('Error getting Plex Token')
@ -181,8 +181,7 @@ class Plex:
if None is not home_users:
for user in home_users.findall('User'):
user_id = user.get('id')
# use empty byte data to force POST
switch_page = self.get_url_x('https://plex.tv/api/home/users/%s/switch' % user_id, data=b'')
switch_page = self.get_url_x('https://plex.tv/api/home/users/%s/switch' % user_id, post_data=True)
if None is not switch_page:
home_token = 'user' == switch_page.tag and switch_page.get('authenticationToken')
if home_token:

View file

@ -1164,6 +1164,9 @@ def getURL(url, post_data=None, params=None, headers=None, timeout=30, session=N
# decide if we get or post data to server
if post_data or 'post_json' in kwargs:
if True is post_data:
post_data = None
if post_data:
kwargs.setdefault('data', post_data)
@ -1697,8 +1700,6 @@ def path_mapper(search, replace, subject):
replace = re.sub(r'[\\]', delim, replace)
path = re.sub(r'[\\]', delim, subject)
result = re.sub('(?i)^%s' % search, replace, path)
if re.search(delim, path):
result = os.path.normpath(re.sub(delim, '/', result))
result = os.path.normpath(re.sub(delim, '/', result))
return result, result != subject

View file

@ -51,8 +51,8 @@ class PiSexyProvider(generic.TorrentProvider):
items = {'Cache': [], 'Season': [], 'Episode': [], 'Propers': []}
rc = dict((k, re.compile('(?i)' + v)) for (k, v) in {
'info': 'download', 'get': 'info.php\?id', 'valid_cat': 'cat=(?:0|50[12])', 'filter': 'free',
'title': r'Download\s([^\s]+).*', 'seeders': r'(^\d+)', 'leechers': r'(\d+)$'}.items())
'get': 'info.php\?id', 'valid_cat': 'cat=(?:0|50[12])', 'filter': 'free',
'title': r'Download\s*([^\s]+).*', 'seeders': r'(^\d+)', 'leechers': r'(\d+)$'}.items())
for mode in search_params.keys():
for search_string in search_params[mode]:
search_string = isinstance(search_string, unicode) and unidecode(search_string) or search_string
@ -88,10 +88,10 @@ class PiSexyProvider(generic.TorrentProvider):
or (self.freeleech and not tr.find('img', src=rc['filter'])):
continue
info = tr.find('a', href=rc['info']) or tr.find('a', href=rc['get'])
title = (rc['title'].sub('', info.attrs.get('title', '')) or info.get_text()).strip()
info = tr.find('a', href=rc['get'])
title = (rc['title'].sub(r'\1', info.attrs.get('title', '')) or info.get_text()).strip()
size = cells[head['size']].get_text().strip()
download_url = self._link(tr.find('a', href=rc['get'])['href'])
download_url = self._link(info['href'])
except (AttributeError, TypeError, ValueError, KeyError, IndexError):
continue