Spaces:
No application file
No application file
Create youtube/metadata.py
Browse files- bot/youtube/metadata.py +19 -0
bot/youtube/metadata.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# PATH: bot/youtube/metadata.py
|
| 2 |
+
def normalize_privacy(p: str) -> str:
|
| 3 |
+
p = (p or "private").lower().strip()
|
| 4 |
+
if p not in ("private", "unlisted", "public"):
|
| 5 |
+
return "private"
|
| 6 |
+
return p
|
| 7 |
+
|
| 8 |
+
def build_metadata(title: str, description: str, privacy: str = "private") -> dict:
|
| 9 |
+
privacy = normalize_privacy(privacy)
|
| 10 |
+
return {
|
| 11 |
+
"snippet": {
|
| 12 |
+
"title": title[:95],
|
| 13 |
+
"description": description[:4900],
|
| 14 |
+
"categoryId": "22", # People & Blogs default
|
| 15 |
+
},
|
| 16 |
+
"status": {
|
| 17 |
+
"privacyStatus": privacy
|
| 18 |
+
}
|
| 19 |
+
}
|