Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions data/example-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"announce_url" : "https://hawke.uno/announce/customannounceurl",
# "anon" : False
},
"MTV": {
"MTV": {
'api_key' : 'get from security page',
'username' : '<USERNAME>',
'password' : '<PASSWORD>',
Expand Down Expand Up @@ -136,7 +136,7 @@
"announce_url" : "https://lst.gg/announce/customannounceurl",
# "anon" : False
},
"LT" : {
"LT" : {
"api_key" : "LT api key",
"announce_url" : "https://lat-team.com/announce/customannounceurl",
# "anon" : False
Expand All @@ -161,6 +161,7 @@
"username" : "username",
"password" : "password",
"announce_url" : "https://hdts-announce.ru/announce.php",
"my_announce_url": "https://hdts-announce.ru/announce.php?pid=<PASS_KEY/PID>",
# "anon" : "False"
},

Expand Down
9 changes: 9 additions & 0 deletions src/trackers/COMMON.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ async def edit_torrent(self, meta, tracker, source_flag):
new_torrent.metainfo['info']['source'] = source_flag
Torrent.copy(new_torrent).write(f"{meta['base_dir']}/tmp/{meta['uuid']}/[{tracker}]{meta['clean_name']}.torrent", overwrite=True)

# used to add tracker url, comment and source flag to torrent file
async def add_tracker_torrent(self, meta, tracker, source_flag, new_tracker, comment):
if os.path.exists(f"{meta['base_dir']}/tmp/{meta['uuid']}/BASE.torrent"):
new_torrent = Torrent.read(f"{meta['base_dir']}/tmp/{meta['uuid']}/BASE.torrent")
new_torrent.metainfo['announce'] = new_tracker
new_torrent.metainfo['comment'] = comment
new_torrent.metainfo['info']['source'] = source_flag
Torrent.copy(new_torrent).write(f"{meta['base_dir']}/tmp/{meta['uuid']}/[{tracker}]{meta['clean_name']}.torrent", overwrite=True)


async def unit3d_edit_desc(self, meta, tracker, signature, comparison=False, desc_header=""):
base = open(f"{meta['base_dir']}/tmp/{meta['uuid']}/DESCRIPTION.txt", 'r', encoding='utf8').read()
Expand Down
28 changes: 14 additions & 14 deletions src/trackers/HDT.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class HDT():
def __init__(self, config):
self.config = config
self.tracker = 'HDT'
self.source_flag = 'HDT'
self.source_flag = 'hd-torrents.org'
self.username = config['TRACKERS'][self.tracker].get('username', '').strip()
self.password = config['TRACKERS'][self.tracker].get('password', '').strip()
self.signature = None
Expand Down Expand Up @@ -194,8 +194,8 @@ async def upload(self, meta):
# Match url to verify successful upload
search = re.search(r"download\.php\?id\=([a-z0-9]+)", up.text).group(1)
if search:
id = search
await self.download_new_torrent(session, id, torrent_path)
# 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)
else:
console.print(data)
console.print("\n\n")
Expand Down Expand Up @@ -300,17 +300,17 @@ async def login(self, cookiefile):
await asyncio.sleep(1)
console.print(response.url)
return

async def download_new_torrent(self, session, id, torrent_path):
download_url = f"https://hd-torrents.org/download.php?id={id}"
r = session.get(url=download_url)
if r.status_code == 200:
with open(torrent_path, "wb") as tor:
tor.write(r.content)
else:
console.print("[red]There was an issue downloading the new .torrent from HDT")
console.print(r.text)
return
# No longer used as torrent is modified instead of downloaded.
# async def download_new_torrent(self, session, id, torrent_path):
# download_url = f"https://hd-torrents.org/download.php?id={id}"
# r = session.get(url=download_url)
# if r.status_code == 200:
# with open(torrent_path, "wb") as tor:
# tor.write(r.content)
# else:
# console.print("[red]There was an issue downloading the new .torrent from HDT")
# console.print(r.text)
# return

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