Skip to content

Commit

Permalink
Update yggtorrent.py URL and authentification mechanism
Browse files Browse the repository at this point in the history
Update yggtorrent.py URL and authentification mechanism
  • Loading branch information
StudioEtrange committed Nov 2, 2024
1 parent cb1fa74 commit b13f185
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions medusa/providers/torrent/html/yggtorrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import logging
import re
import json
from requests.utils import dict_from_cookiejar

from medusa import tv
from medusa.bs4_parser import BS4Parser
Expand Down Expand Up @@ -36,10 +38,11 @@ def __init__(self):
self.password = None

# URLs
self.url = 'https://yggtorrent.wtf'
# check URL change here : https://yggland.fr/FAQ-Tutos/#status
self.url = 'https://ygg.re/'
self.urls = {
'auth': urljoin(self.url, 'user/ajax_usermenu'),
'login': urljoin(self.url, 'user/login'),
'login': urljoin(self.url, 'auth/process_login'),
'search': urljoin(self.url, 'engine/search'),
'download': urljoin(self.url, 'engine/download_torrent?id={0}')
}
Expand All @@ -56,6 +59,9 @@ def __init__(self):
# Cache
self.cache = tv.Cache(self, min_time=20)

# Required cookies to check authentification
self.required_cookies=('ygg_',)

def search(self, search_strings, age=0, ep_obj=None, **kwargs):
"""
Search a provider and parse the results.
Expand Down Expand Up @@ -194,8 +200,21 @@ def login(self):
return True

def _is_authenticated(self):
if not any(dict_from_cookiejar(self.session.cookies).values()) or not self.check_required_cookies():
return False

response = self.session.get(self.urls['auth'])
if not response:
if not response or response is None or not response.status_code == 200:
log.debug("cannot reach account information page")
return False

try:
j = json.loads(response.text)
except:
return False
nickname = j.get('nickname')
if nickname is None or nickname == '':
log.debug("nickname information missing")
return False

return True
Expand Down

0 comments on commit b13f185

Please sign in to comment.