Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update HDT #74

Merged
merged 1 commit into from
Oct 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading