Skip to content

Commit

Permalink
Hide Name
Browse files Browse the repository at this point in the history
  • Loading branch information
AnshumanPM committed Apr 15, 2024
1 parent 3e4838b commit 2e45889
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from config import NEW_DL_BASE_URL, OLD_DL_BASE_URL_1, OLD_DL_BASE_URL_2
from database import collection, new_collection
from helper import decode_string, extract_gdrive_id, hashids, is_valid_url
from helper import decode_string, extract_gdrive_id, hashids, hide_name, is_valid_url

app = Flask(__name__)
app.jinja_env.filters["quote_plus"] = lambda u: quote_plus(u)
Expand Down Expand Up @@ -56,9 +56,9 @@ def tg_stream():
if video_url != "" and metadata != "":
try:
data = decode_string(unquote_plus(metadata)).split("|")
f_name = data[0]
f_name = hide_name(data[0])
f_size = data[1]
f_owner = data[2]
f_owner = hide_name(data[2])
f_time = data[3]
try:
tg_file_url = data[4]
Expand Down Expand Up @@ -101,9 +101,9 @@ def view(url_id):
OLD_DL_BASE_URL_2, NEW_DL_BASE_URL
)
data = decode_string(unquote_plus(metadata)).split("|")
f_name = data[0]
f_name = hide_name(data[0])
f_size = data[1]
f_owner = data[2]
f_owner = hide_name(data[2])
f_time = data[3]
tg_file_url = data[4]
return render_template(
Expand Down
7 changes: 7 additions & 0 deletions helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
hashids = Hashids(salt=HASH_SALT)


def hide_name(name):
if len(name) <= 4:
return name
else:
return name[:2] + "*" * (len(name) - 4) + name[-2:]


def decode_string(encoded):
decoded = "".join([chr(i) for i in hashids.decode(encoded)])
return decoded
Expand Down

0 comments on commit 2e45889

Please sign in to comment.