Skip to content

Commit

Permalink
get jstoken and logid automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
r0ld3x committed Dec 14, 2023
1 parent f4a5e68 commit 6cfe1a8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
config.py
__pycache__
*.session
*.session-journal
chromedriver.exe
*.ipynb
test*
tele.py
config.py
*.crdownload
*.mp4
*.mkv
11 changes: 5 additions & 6 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
api_id =
api_hash = ""
api_id = #my.telegram.org
api_hash = "" #my.telegram.org

bot_token = ""


headers = {}


cookies = {}
cookies = {
}

headers = {}
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ async def echo_message(_, m: Message):
download_and_send(bot, m, hm, data["file_name"], data["sizebytes"])
)


bot.run()
bot.run()
18 changes: 16 additions & 2 deletions terabox.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,21 @@
session.headers.update(headers)


def find_between(data, first, last):
try:
start = data.index(first) + len(first)
end = data.index(last, start)
return data[start:end]
except ValueError:
return None


def get_data(url: str):
a = session.get(url, headers=headers, cookies=cookies)
logid = find_between(a.text, "dp-logid=", "&")
jstoken = (
find_between(a.text, "window.jsToken%20%3D%20a%7D%3Bfn%28%22", "%22%29"),
)
shorturl = extract_surl_from_url(a.url)
if not shorturl:
return False
Expand All @@ -24,9 +37,9 @@ def get_data(url: str):
("clienttype", "0"),
(
"jsToken",
"806B937AC4C794FF6C6FC72CC9B1CEAF5D1A6FBC7BC77CDE52B01679B04901F97BA6F9E288091E97AE186BCF748BB81F71760F6269B034094B467FDDC9771AE6",
jstoken,
),
("dp-logid", "27843600477115380012"),
("dp-logid", logid),
("page", "1"),
("num", "20"),
("by", "name"),
Expand All @@ -37,6 +50,7 @@ def get_data(url: str):
)

response = session.get("https://www.terabox.app/share/list", params=params)
print(response.text)
if not response.status_code == 200:
return False
r_j = response.json()
Expand Down

0 comments on commit 6cfe1a8

Please sign in to comment.