Fix typos and remove newlines since they're broken

This commit is contained in:
2024-02-27 11:57:31 +01:00
parent e1cad6b74d
commit c70872a0e5

View File

@@ -23,26 +23,27 @@ class TikTokUploadEngine(BaseUploadEngine):
return return
title: str = self.ctx.title title: str = self.ctx.title
description: str = self.ctx.description description: str = self.ctx.description
hastags = self.hashtags.strip().split(" ") hashtags = self.hashtags.strip().split(" ")
# extract any hashtags from the description / title and remove them from the description # extract any hashtags from the description / title and remove them from the description
for word in title.split(): for word in title.split():
if word.startswith("#"): if word.startswith("#"):
hastags.append(word) hashtags.append(word)
title = title.replace(word, "") title = title.replace(word, "")
for word in description.split(): for word in description.split():
if word.startswith("#"): if word.startswith("#"):
hastags.append(word) hashtags.append(word)
description = description.replace(word, "") description = description.replace(word, "")
title = title.strip() title = title.strip()
description = description.strip() description = description.strip().replace("\n", " ") # Newlines are not supported by this uploader
hastags_str = " ".join(hastags) + " " if hastags else "" hashtags_str = " ".join(hashtags) + " " if hashtags else ""
failed = upload_video( failed = upload_video(
filename=self.ctx.get_file_path("final.mp4"), filename=self.ctx.get_file_path("final.mp4"),
description=f"{title} {description} {hastags_str}", description=f"{title} {description} {hashtags_str}",
cookies_str=cookies, cookies_str=cookies,
browser="firefox", browser="chrome",
comment=True, stitch=False, duet=False
) )
for _ in failed: for _ in failed:
gr.Error(f"Failed to upload to TikTok") gr.Error(f"Failed to upload to TikTok")