parent
c5defad261
commit
40deb9969b
|
|
@ -169,12 +169,28 @@ class TorrentSearch:
|
||||||
app.add_handler(CallbackQueryHandler(self.previous, filters.regex(f"{self.command}_previous")))
|
app.add_handler(CallbackQueryHandler(self.previous, filters.regex(f"{self.command}_previous")))
|
||||||
app.add_handler(CallbackQueryHandler(self.delete, filters.regex(f"{self.command}_delete")))
|
app.add_handler(CallbackQueryHandler(self.delete, filters.regex(f"{self.command}_delete")))
|
||||||
app.add_handler(CallbackQueryHandler(self.next, filters.regex(f"{self.command}_next")))
|
app.add_handler(CallbackQueryHandler(self.next, filters.regex(f"{self.command}_next")))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def format_magnet(string: str):
|
||||||
|
if not string:
|
||||||
|
return ""
|
||||||
|
return string.split('&tr', 1)[0]
|
||||||
|
|
||||||
def get_formatted_string(self, values):
|
def get_formatted_string(self, values):
|
||||||
string = self.RESULT_STR.format(**values)
|
string = self.RESULT_STR.format(**values)
|
||||||
magnet = values.get('magnet', values.get('Magnet')) # Avoid updating source dict
|
extra = ""
|
||||||
if (magnet):
|
if "Files" in values:
|
||||||
string += f"➲Magnet: `{magnet.split('&tr', 1)[0]}`"
|
tmp_str = "➲[{Quality} - {Type} ({Size})]({Torrent}): `{magnet}`"
|
||||||
|
extra += "\n".join(
|
||||||
|
tmp_str.format(**f, magnet=self.format_magnet(f['Magnet']))
|
||||||
|
for f in values['Files']
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
magnet = values.get('magnet', values.get('Magnet')) # Avoid updating source dict
|
||||||
|
if magnet:
|
||||||
|
extra += f"➲Magnet: `{self.format_magnet(magnet)}`"
|
||||||
|
if (extra):
|
||||||
|
string += "\n" + extra
|
||||||
return string
|
return string
|
||||||
|
|
||||||
async def update_message(self):
|
async def update_message(self):
|
||||||
|
|
@ -242,55 +258,51 @@ class TorrentSearch:
|
||||||
RESULT_STR_1337 = (
|
RESULT_STR_1337 = (
|
||||||
"➲Name: `{Name}`\n"
|
"➲Name: `{Name}`\n"
|
||||||
"➲Size: {Size}\n"
|
"➲Size: {Size}\n"
|
||||||
"➲Seeders: {Seeders} || ➲Leechers: {Leechers}\n"
|
"➲Seeders: {Seeders} || ➲Leechers: {Leechers}"
|
||||||
)
|
)
|
||||||
RESULT_STR_PIRATEBAY = (
|
RESULT_STR_PIRATEBAY = (
|
||||||
"➲Name: `{Name}`\n"
|
"➲Name: `{Name}`\n"
|
||||||
"➲Size: {Size}\n"
|
"➲Size: {Size}\n"
|
||||||
"➲Seeders: {Seeders} || ➲Leechers: {Leechers}\n"
|
"➲Seeders: {Seeders} || ➲Leechers: {Leechers}"
|
||||||
)
|
)
|
||||||
RESULT_STR_TGX = (
|
RESULT_STR_TGX = (
|
||||||
"➲Name: `{Name}`\n"
|
"➲Name: `{Name}`\n"
|
||||||
"➲Size: {Size}\n"
|
"➲Size: {Size}\n"
|
||||||
"➲Seeders: {Seeders} || ➲Leechers: {Leechers}\n"
|
"➲Seeders: {Seeders} || ➲Leechers: {Leechers}"
|
||||||
)
|
)
|
||||||
RESULT_STR_YTS = (
|
RESULT_STR_YTS = (
|
||||||
"➲Name: `{Name}`\n"
|
"➲Name: `{Name}`"
|
||||||
"➲1st Link: `{Dwnload1}`\n"
|
|
||||||
"➲2nd Link: `{Download2}`"
|
|
||||||
)
|
)
|
||||||
RESULT_STR_EZTV = (
|
RESULT_STR_EZTV = (
|
||||||
"➲Name: `{Name}`\n"
|
"➲Name: `{Name}`\n"
|
||||||
"➲Size: {Size}\n"
|
"➲Size: {Size}\n"
|
||||||
"➲Seeders: {Seeders}\n"
|
"➲Seeders: {Seeders}"
|
||||||
"➲Torrent: `{Torrent}`\n"
|
|
||||||
)
|
)
|
||||||
RESULT_STR_TORLOCK = (
|
RESULT_STR_TORLOCK = (
|
||||||
"➲Name: `{Name}`\n"
|
"➲Name: `{Name}`\n"
|
||||||
"➲Size: {Size}\n"
|
"➲Size: {Size}\n"
|
||||||
"➲Seeders: {Seeders} || ➲Leechers: {Leechers}\n"
|
"➲Seeders: {Seeders} || ➲Leechers: {Leechers}"
|
||||||
"➲Torrent: `{Torrent}`\n"
|
|
||||||
)
|
)
|
||||||
RESULT_STR_RARBG = (
|
RESULT_STR_RARBG = (
|
||||||
"➲Name: `{Name}`\n"
|
"➲Name: `{Name}`\n"
|
||||||
"➲Size: {Size}\n"
|
"➲Size: {Size}\n"
|
||||||
"➲Seeders: {Seeders} || ➲Leechers: {Leechers}\n"
|
"➲Seeders: {Seeders} || ➲Leechers: {Leechers}"
|
||||||
)
|
)
|
||||||
RESULT_STR_ALL = (
|
RESULT_STR_ALL = (
|
||||||
"➲Name: `{Name}`\n"
|
"➲Name: `{Name}`\n"
|
||||||
"➲Size: {Size}\n"
|
"➲Size: {Size}\n"
|
||||||
"➲Seeders: {Seeders} || ➲Leechers: {Leechers}\n"
|
"➲Seeders: {Seeders} || ➲Leechers: {Leechers}"
|
||||||
)
|
)
|
||||||
|
|
||||||
torrents_dict = {
|
torrents_dict = {
|
||||||
'1337x': {'source': "https://torrenter-api.herokuapp.com/api/1337x/", 'result_str': RESULT_STR_1337},
|
'1337x': {'source': "https://slam-api.herokuapp.com/api/1337x/", 'result_str': RESULT_STR_1337},
|
||||||
'piratebay': {'source': "https://torrenter-api.herokuapp.com/api/piratebay/", 'result_str': RESULT_STR_PIRATEBAY},
|
'piratebay': {'source': "https://slam-api.herokuapp.com/api/piratebay/", 'result_str': RESULT_STR_PIRATEBAY},
|
||||||
'tgx': {'source': "https://torrenter-api.herokuapp.com/api/tgx/", 'result_str': RESULT_STR_TGX},
|
'tgx': {'source': "https://slam-api.herokuapp.com/api/tgx/", 'result_str': RESULT_STR_TGX},
|
||||||
'yts': {'source': "https://torrenter-api.herokuapp.com/api/yts/", 'result_str': RESULT_STR_YTS},
|
'yts': {'source': "https://slam-api.herokuapp.com/api/yts/", 'result_str': RESULT_STR_YTS},
|
||||||
'eztv': {'source': "https://torrenter-api.herokuapp.com/api/eztv/", 'result_str': RESULT_STR_EZTV},
|
'eztv': {'source': "https://slam-api.herokuapp.com/api/eztv/", 'result_str': RESULT_STR_EZTV},
|
||||||
'torlock': {'source': "https://torrenter-api.herokuapp.com/api/torlock/", 'result_str': RESULT_STR_TORLOCK},
|
'torlock': {'source': "https://slam-api.herokuapp.com/api/torlock/", 'result_str': RESULT_STR_TORLOCK},
|
||||||
'rarbg': {'source': "https://torrenter-api.herokuapp.com/api/rarbg/", 'result_str': RESULT_STR_RARBG},
|
'rarbg': {'source': "https://slam-api.herokuapp.com/api/rarbg/", 'result_str': RESULT_STR_RARBG},
|
||||||
'ts': {'source': "https://torrenter-api.herokuapp.com/api/all/", 'result_str': RESULT_STR_ALL}
|
'ts': {'source': "https://slam-api.herokuapp.com/api/all/", 'result_str': RESULT_STR_ALL}
|
||||||
}
|
}
|
||||||
|
|
||||||
torrent_handlers = []
|
torrent_handlers = []
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue