Skip to content

Commit

Permalink
Hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
bswck committed Jan 9, 2024
1 parent b556054 commit 0b30a41
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion redesc/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
DEFAULT_LIMIT: int = 1000000


def fix_tags(tags: list[str]) -> list[str]:
total = 0
all_tags = []
for tag in tags:
total += len(tag) + (2 * (" " in tag))
if total >= 350:
break
total += 1
all_tags.append(tag)
return all_tags


class YouTubeAPI:
def __init__(
self,
Expand Down Expand Up @@ -115,6 +127,7 @@ def update_video_description(
if video_category_id is None:
video_category_id = item["snippet"]["categoryId"]

tags[:] = fix_tags(tags)
request = self.client.videos().update(
part="snippet",
body={
Expand All @@ -123,7 +136,7 @@ def update_video_description(
"title": video_title,
"categoryId": video_category_id,
"description": description,
"tags": tags,
"tags": fix_tags(tags),
},
},
)
Expand Down

0 comments on commit 0b30a41

Please sign in to comment.