Fix strip issues

Signed-off-by: anasty17 <e.anastayyar@gmail.com>
This commit is contained in:
anasty17 2024-01-05 10:26:05 +02:00
parent 007740bd81
commit 1188760e0d
7 changed files with 19 additions and 15 deletions

View File

@ -274,10 +274,10 @@ class TaskConfig:
)
if not isinstance(self.upDest, int):
if self.upDest.startswith("b:"):
self.upDest = self.upDest.lstrip("b:")
self.upDest = self.upDest.replace("b:", "", 1)
self.userTransmission = False
elif self.upDest.startswith("u:"):
self.upDest = self.upDest.lstrip("u:")
self.upDest = self.upDest.replace("u:", "", 1)
self.userTransmission = IS_PREMIUM_USER
if self.upDest.isdigit() or self.upDest.startswith("-"):
self.upDest = int(self.upDest)

View File

@ -29,15 +29,15 @@ class gdClone(GoogleDriveHelper):
"mtp:"
):
self.token_path = f"tokens/{self.listener.user_id}.pickle"
self.listener.upDest = self.listener.upDest.lstrip("mtp:")
self.listener.upDest = self.listener.upDest.replace("mtp:", "", 1)
self.use_sa = False
elif self.listener.upDest.startswith("tp:"):
self.listener.upDest = self.listener.upDest.lstrip("tp:")
self.listener.upDest = self.listener.upDest.replave("tp:", "", 1)
self.use_sa = False
elif self.listener.upDest.startswith("sa:") or self.listener.link.startswith(
"sa:"
):
self.listener.upDest = self.listener.upDest.lstrip("sa:")
self.listener.upDest = self.listener.upDest.replace("sa:", "", 1)
self.use_sa = True
def clone(self):

View File

@ -99,11 +99,13 @@ class GoogleDriveHelper:
if user_id and link.startswith("mtp:"):
self.use_sa = False
self.token_path = f"tokens/{user_id}.pickle"
link = link.replace("mtp:", "", 1)
elif link.startswith("sa:"):
self.use_sa = True
link = link.replace("sa:", "", 1)
elif link.startswith("tp:"):
self.use_sa = False
link = link.lstrip("mtp:").lstrip("sa:").lstrip("tp:")
link = link.replace("tp:", "", 1)
if is_gdrive_id(link):
return link
if "folders" in link or "file" in link:

View File

@ -105,7 +105,7 @@ class gdSearch(GoogleDriveHelper):
drives = [
(
"From Owner",
target_id.lstrip("tp:"),
target_id.replace("tp:", "", 1),
INDEX_URLS[0] if INDEX_URLS else "",
)
]
@ -174,7 +174,7 @@ class gdSearch(GoogleDriveHelper):
return telegraph_content, contents_no
def get_user_drive(self, target_id, user_id):
dest_id = target_id.lstrip("mtp:")
dest_id = target_id.replace("mtp:", "", 1)
self.token_path = f"tokens/{user_id}.pickle"
self.use_sa = False
user_dict = user_data.get(user_id, {})

View File

@ -30,13 +30,13 @@ class gdUpload(GoogleDriveHelper):
def user_setting(self):
if self.listener.upDest.startswith("mtp:"):
self.token_path = f"tokens/{self.listener.user_id}.pickle"
self.listener.upDest = self.listener.upDest.lstrip("mtp:")
self.listener.upDest = self.listener.upDest.replace("mtp:", "", 1)
self.use_sa = False
elif self.listener.upDest.startswith("tp:"):
self.listener.upDest = self.listener.upDest.lstrip("tp:")
self.listener.upDest = self.listener.upDest.replace("tp:", "", 1)
self.use_sa = False
elif self.listener.upDest.startswith("sa:"):
self.listener.upDest = self.listener.upDest.lstrip("sa:")
self.listener.upDest = self.listener.upDest.replace("sa:", "", 1)
self.use_sa = True
def upload(self, size):

View File

@ -164,8 +164,8 @@ class Clone(TaskListener):
LOGGER.info(f"Cloning Done: {self.name}")
elif is_rclone_path(self.link):
if self.link.startswith("mrcc:"):
self.link = self.link.lstrip("mrcc:")
self.upDest = self.upDest.lstrip("mrcc:")
self.link = self.link.replace("mrcc:", "", 1)
self.upDest = self.upDest.replace("mrcc:", "", 1)
config_path = f"rclone/{self.user_id}.conf"
else:
config_path = "rclone.conf"
@ -192,7 +192,9 @@ class Clone(TaskListener):
rstat = loads(res[0])
if rstat["IsDir"]:
self.name = src_path.rsplit("/", 1)[-1] if src_path else remote
self.upDest += self.name if self.upDest.endswith(":") else f"/{self.name}"
self.upDest += (
self.name if self.upDest.endswith(":") else f"/{self.name}"
)
mime_type = "Folder"
else:

View File

@ -267,7 +267,7 @@ async def rssList(query, start, all_users=False):
list_feed += f"<b>Inf:</b> <code>{data['inf']}</code>\n"
list_feed += f"<b>Exf:</b> <code>{data['exf']}</code>\n"
list_feed += f"<b>Paused:</b> <code>{data['paused']}</code>\n"
list_feed += f"<b>User:</b> {data['tag'].lstrip('@')}"
list_feed += f"<b>User:</b> {data['tag'].replace('@', '', 1)}"
index += 1
if index == 5:
break