Private GIT

Skip to content
Snippets Groups Projects
Commit e8cabe88 authored by stef76's avatar stef76
Browse files

Update xthor.py

Mise à jour avec le nouveau CMS
parent 46cd3178
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,7 @@ class XTHORProvider(generic.TorrentProvider):
self.supportsBacklog = True
self.cj = cookielib.CookieJar()
self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cj))
......@@ -51,18 +52,13 @@ class XTHORProvider(generic.TorrentProvider):
def getSearchParams(self, searchString, audio_lang, french=None, fullSeason=False):
results = []
if audio_lang == "en" and french==None:
results.append( urllib.urlencode( {
'keywords': searchString ,
} ) + "&cid=43,69&[PARAMSTR]=" + searchString )
results.append("c16=1&c17=1&searchin=title&search=" + searchString )
elif audio_lang == "fr" or french:
results.append( urllib.urlencode( {
'keywords': searchString
} ) + "&cid=42,41&[PARAMSTR]=" + searchString)
results.append("c14=1&c15=1&searchin=title&search=" + searchString)
else:
results.append( urllib.urlencode( {
'keywords': searchString
} ) + "&cid=42,43,41,69&[PARAMSTR]=" + searchString)
results.append("c14=1&c15=1&c16=1&c17=1&searchin=title&search=" + searchString)
#Désactivé car on ne peut pas savoir la langue
#if fullSeason:
# results.append( urllib.urlencode( {
......@@ -116,12 +112,12 @@ class XTHORProvider(generic.TorrentProvider):
self.opener.addheaders = [('User-agent', random.choice(listeUserAgents))]
data = urllib.urlencode({'action':'login','loginbox_membername': login, 'loginbox_password' : password, 'loginbox_remember' : 'true'})
data = urllib.urlencode({'action':'takelogin.php','username': login, 'password' : password, 'submitme' : 'X'})
r = self.opener.open(self.url + '/ajax/login.php',data)
r = self.opener.open(self.url + '/takelogin.php',data)
for index, cookie in enumerate(self.cj):
if (cookie.name == "tsue_member"): self.login_done = True
if (cookie.name == "uid"): self.login_done = True
if not self.login_done and not self.failed_login_logged:
logger.log(u"Unable to login to XTHOR. Please check username and password.", logger.WARNING)
......@@ -139,7 +135,7 @@ class XTHORProvider(generic.TorrentProvider):
results = []
searchUrl = self.url + '?p=torrents&pid=10&search_type=name&' + searchString.replace('!','')
searchUrl = self.url + '/browse.php?' + searchString.replace('!','')
logger.log(u"Search string: " + searchUrl, logger.DEBUG)
......@@ -147,23 +143,25 @@ class XTHORProvider(generic.TorrentProvider):
soup = BeautifulSoup( r)
resultsTable = soup.find("table", { "id" : "torrents_table_classic" })
resultsTable = soup.find("table", { "class" : "table2" })
if resultsTable:
rows = resultsTable.findAll("tr")
for row in rows:
link = row.find("a",href=re.compile("action=details"))
link = row.find("a",href=re.compile("details.php"))
if link:
title = link.text
recherched=searchUrl.split("&[PARAMSTR]=")[1]
recherched=searchUrl.split("&search=")[1]
recherched=recherched.replace(" ","(.*)")
recherched= recherched + "(.*)"
logger.log(u"XTHOR TITLE : " + title, logger.DEBUG)
logger.log(u"XTHOR CHECK MATCH : " + recherched, logger.DEBUG)
if re.match(recherched,title , re.IGNORECASE):
downloadURL = row.find("a",href=re.compile("action=download"))['href']
downloadURL = row.find("a",href=re.compile("download.php"))['href']
downloadURL = self.url + '/'+ downloadURL
logger.log(u"XTHOR DOWNLOAD URL : " + downloadURL, logger.DEBUG)
else:
continue
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment