Skip to content

Commit

Permalink
Update HDT
Browse files Browse the repository at this point in the history
Fixes from L4GSP1KE#310 (comment)

Requires manual cookie management, see instructions in the linked issue
  • Loading branch information
Audionut committed Oct 5, 2024
1 parent 1acf016 commit 9ee3e14
Showing 1 changed file with 4 additions and 33 deletions.
37 changes: 4 additions & 33 deletions src/trackers/HDT.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ async def upload(self, meta, disctype):
data['anonymous'] = 'true'

# Send
url = "https://hd-torrents.org/upload.php"
url = "https://hd-torrents.net/upload.php"
if meta['debug']:
console.print(url)
console.print(data)
Expand All @@ -184,7 +184,7 @@ async def upload(self, meta, disctype):
search = re.search(r"download\.php\?id\=([a-z0-9]+)", up.text).group(1)
if search:
# modding existing torrent for adding to client instead of downloading torrent from site.
await common.add_tracker_torrent(meta, self.tracker, self.source_flag, self.config['TRACKERS']['HDT'].get('my_announce_url'), "https://hd-torrents.org/details.php?id=" + search)
await common.add_tracker_torrent(meta, self.tracker, self.source_flag, self.config['TRACKERS']['HDT'].get('my_announce_url'), "")
else:
console.print(data)
console.print("\n\n")
Expand All @@ -199,7 +199,7 @@ async def search_existing(self, meta, disctype):
cookiefile = os.path.abspath(f"{meta['base_dir']}/data/cookies/HDT.txt")
session.cookies.update(await common.parseCookieFile(cookiefile))

search_url = "https://hd-torrents.org/torrents.php"
search_url = "https://hd-torrents.net/torrents.php"
csrfToken = await self.get_csrfToken(session, search_url)
if int(meta['imdb_id'].replace('tt', '')) != 0:
params = {
Expand Down Expand Up @@ -237,7 +237,7 @@ async def validate_credentials(self, meta):

async def validate_cookies(self, meta, cookiefile):
common = COMMON(config=self.config)
url = "https://hd-torrents.org/index.php"
url = "https://hd-torrents.net/index.php"
cookiefile = f"{meta['base_dir']}/data/cookies/HDT.txt"
if os.path.exists(cookiefile):
with requests.Session() as session:
Expand All @@ -254,35 +254,6 @@ async def validate_cookies(self, meta, cookiefile):
else:
return False

"""
Old login method, disabled because of site's DDOS protection. Better to use exported cookies.
async def login(self, cookiefile):
with requests.Session() as session:
url = "https://hd-torrents.org/login.php"
csrfToken = await self.get_csrfToken(session, url)
data = {
'csrfToken' : csrfToken,
'uid' : self.username,
'pwd' : self.password,
'submit' : 'Confirm'
}
response = session.post('https://hd-torrents.org/login.php', data=data)
await asyncio.sleep(0.5)
index = 'https://hd-torrents.org/index.php'
response = session.get(index)
if response.text.find("Logout") != -1:
console.print('[green]Successfully logged into HDT')
with open(cookiefile, 'wb') as cf:
pickle.dump(session.cookies, cf)
else:
console.print('[bold red]Something went wrong while trying to log into HDT. Make sure your username and password are correct')
await asyncio.sleep(1)
console.print(response.url)
return
"""

async def get_csrfToken(self, session, url):
r = session.get(url)
await asyncio.sleep(0.5)
Expand Down

0 comments on commit 9ee3e14

Please sign in to comment.