Skip to content

Commit

Permalink
Proper fix for tntvillage
Browse files Browse the repository at this point in the history
  • Loading branch information
medariox authored and labrys committed Mar 2, 2016
1 parent cccdb25 commit c8b83a2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sickbeard/providers/tntvillage.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ def _check_auth(self):
return True

def login(self):
if len(dict_from_cookiejar(self.session.cookies)) == 3:
return True
if len(self.session.cookies) > 1:
cookies_dict = dict_from_cookiejar(self.session.cookies)
if cookies_dict['pass_hash'] != '0' and cookies_dict['member_id'] != '0':
return True

login_params = {'UserName': self.username,
'PassWord': self.password,
Expand Down

1 comment on commit c8b83a2

@p0psicles
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This solution will not work for snatching torrents/magnet files, through the manual search. For this I have implemented an Auth Hook. I'm finetuning this. The idea is that all the cookie checks will be removed from login(), as login is just supposed to login.

Hi i'm using this commit to create some awareness: @pymedusa/developers, and to see if my change will also help you @medariox

Then a new dict will be added to GenericProvider, which you can use to configure your provider. For ex. if you know that the provider needs 4 cookies, and you want to check for expired cookies. You could set this:
self.auth_hooks = {'min_amount_cookies': 4, 'check_cookie_expired': True}

If you want to do something really fancy, you can overwrite and place the method the following method in your provider:

    def _custom_auth_check(self):
        """ Use this function if you'd like to have some control over the authentication checks
        before searching the provider or snatching a result. The _custom_auth_check is hooked through _get_auth_hook()
        to the helpers.getURL() function.
        """
        print('Do some fancy stuff here')
        return

The above function will also only be run just before it tries to perform the GET or POST.

Please sign in to comment.