Skip to content

Commit

Permalink
Update 1337x to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
hemantapkh committed Feb 17, 2025
1 parent f884f68 commit 955e2e4
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 72 deletions.
8 changes: 4 additions & 4 deletions app/plugins/blueprint/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def search_message(self, response, language):
size=item.get("size"),
seeders=item.get("seeders"),
leechers=item.get("leechers"),
torrent_id=item.get("torrentId"),
torrent_id=item.get("torrent_id") or item.get("torrentId"),
link_str=self.Client.language.STR("link", language),
)
+ message
Expand All @@ -42,8 +42,8 @@ def content_message(self, data, language, restricted_mode, bookmarked=False):
size=data.get("size"),
seeders=data.get("seeders"),
leechers=data.get("leechers"),
uploaded_on=data.get("uploadDate") or data.get("uploaded_on"),
magnet=data.get("magnetLink") or data.get("magnet"),
uploaded_on=data.get("date_uploaded") or data.get("uploadDate") or data.get("uploaded_on"),
magnet=data.get("magnet_link") or data.get("magnetLink") or data.get("magnet"),
size_str=self.Client.language.STR("size", language),
seeders_str=self.Client.language.STR("seeders", language),
leechers_str=self.Client.language.STR("leechers", language),
Expand All @@ -53,7 +53,7 @@ def content_message(self, data, language, restricted_mode, bookmarked=False):

markup = self.Client.keyboard.torrent_info(
language,
data.get("infoHash") or data.get("hash"),
data.get("info_hash") or data.get("infoHash") or data.get("hash"),
bookmarked=bookmarked,
)

Expand Down
4 changes: 2 additions & 2 deletions app/plugins/py1337x/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ async def results(Client, message):
reply_to_message_id=message.id,
)

response = Client.py1337x.info(torrentId=torrent_id)
response = await Client.py1337x.info(torrent_id=torrent_id)

text, markup = Client.struct.content_message(
response,
response.to_dict(),
language=user_lang,
restricted_mode=restricted_mode,
)
Expand Down
6 changes: 3 additions & 3 deletions app/plugins/py1337x/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
& filters.custom.init
& ~filters.command("settings"),
)
async def search(Client, message):
async def search(Client: Client, message):
user_lang = await Client.misc.user_lang(message)

msg = await Client.send_message(
Expand All @@ -17,9 +17,9 @@ async def search(Client, message):
reply_to_message_id=message.id,
)

response = Client.py1337x.search(message.text)
response = await Client.py1337x.search(message.text)

text = Client.struct.search_message(response, user_lang)
text = Client.struct.search_message(response.to_dict(), user_lang)

await Client.edit_message_text(
chat_id=message.chat.id,
Expand Down
6 changes: 3 additions & 3 deletions app/torrenthunt.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from plugins.functions.init import Init
from plugins.functions.keyboards import KeyBoard
from plugins.functions.misc import Misc
from py1337x import py1337x
from py1337x import AsyncPy1337x
from pyrogram import Client, filters

# Initializing sentry for error tracking
Expand Down Expand Up @@ -63,12 +63,12 @@
Client.keyboard = KeyBoard(bot)
Client.language = Lang("langs/string.json", "langs/lang.json")
Client.requests = Requests()
Client.py1337x = py1337x()
Client.py1337x = AsyncPy1337x()
Client.struct = Schema(bot)
filters.custom = Filter(bot)
Client.explicit_detector = ExplicitDetector()


async def main():
async with bot:
await init_models()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "🏴‍☠️ The ultimate torrent bot on telegram"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"1337x==1.2.6",
"1337x==2.0.0",
"aiohttp==3.11.9",
"aiosqlite==0.20.0",
"asyncpg==0.30.0",
Expand Down
94 changes: 35 additions & 59 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 955e2e4

Please sign in to comment.