chore(yt-long): set daily quota to 14x3 (42 global)
Raise defaults and API caps so each of 14 channels can ship at least 3 long videos per Beijing day, with concurrency/sample batch tuned to keep up. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
a6ede5619c
commit
31228a0410
@ -507,13 +507,13 @@ def _seed_defaults(conn: sqlite3.Connection) -> None:
|
|||||||
"yt_long_auto_upload": True,
|
"yt_long_auto_upload": True,
|
||||||
"yt_long_live_sample": True,
|
"yt_long_live_sample": True,
|
||||||
"yt_long_live_sample_interval_sec": 180,
|
"yt_long_live_sample_interval_sec": 180,
|
||||||
"yt_long_live_sample_batch": 1,
|
"yt_long_live_sample_batch": 2,
|
||||||
"yt_long_daily_max": 3,
|
"yt_long_daily_max": 42,
|
||||||
"yt_long_channel_daily_max": 1,
|
"yt_long_channel_daily_max": 3,
|
||||||
"yt_long_min_sec": 180,
|
"yt_long_min_sec": 180,
|
||||||
"yt_long_max_sec": 480,
|
"yt_long_max_sec": 480,
|
||||||
"yt_long_dedupe_room_day": True,
|
"yt_long_dedupe_room_day": True,
|
||||||
"yt_long_max_concurrent": 1,
|
"yt_long_max_concurrent": 2,
|
||||||
"yt_long_upload_min_gap_sec": 900,
|
"yt_long_upload_min_gap_sec": 900,
|
||||||
"yt_long_delete_clip_after_upload": True,
|
"yt_long_delete_clip_after_upload": True,
|
||||||
"yt_long_title_template": "",
|
"yt_long_title_template": "",
|
||||||
|
|||||||
@ -1220,12 +1220,12 @@ async def yt_long_settings_update(body: dict[str, Any] | None = None) -> dict[st
|
|||||||
patch[k] = bool(raw[k])
|
patch[k] = bool(raw[k])
|
||||||
if "yt_long_daily_max" in raw:
|
if "yt_long_daily_max" in raw:
|
||||||
try:
|
try:
|
||||||
patch["yt_long_daily_max"] = max(0, min(50, int(raw["yt_long_daily_max"])))
|
patch["yt_long_daily_max"] = max(0, min(200, int(raw["yt_long_daily_max"])))
|
||||||
except Exception:
|
except Exception:
|
||||||
raise HTTPException(400, "daily_max 无效") from None
|
raise HTTPException(400, "daily_max 无效") from None
|
||||||
if "yt_long_channel_daily_max" in raw:
|
if "yt_long_channel_daily_max" in raw:
|
||||||
try:
|
try:
|
||||||
patch["yt_long_channel_daily_max"] = max(0, min(20, int(raw["yt_long_channel_daily_max"])))
|
patch["yt_long_channel_daily_max"] = max(0, min(50, int(raw["yt_long_channel_daily_max"])))
|
||||||
except Exception:
|
except Exception:
|
||||||
raise HTTPException(400, "channel_daily_max 无效") from None
|
raise HTTPException(400, "channel_daily_max 无效") from None
|
||||||
if "yt_long_min_sec" in raw:
|
if "yt_long_min_sec" in raw:
|
||||||
|
|||||||
@ -20,7 +20,8 @@ _QUOTA_STATUSES = (
|
|||||||
"uploaded",
|
"uploaded",
|
||||||
)
|
)
|
||||||
|
|
||||||
YT_LONG_DAILY_DEFAULT = 3
|
YT_LONG_DAILY_DEFAULT = 42 # 14 channels × 3 long videos
|
||||||
|
YT_LONG_CHANNEL_DEFAULT = 3
|
||||||
YT_LONG_MIN_SEC = 180 # 3 min
|
YT_LONG_MIN_SEC = 180 # 3 min
|
||||||
YT_LONG_MAX_SEC = 480 # 8 min
|
YT_LONG_MAX_SEC = 480 # 8 min
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ def ensure_yt_long_tables(conn: sqlite3.Connection) -> None:
|
|||||||
client_secret TEXT NOT NULL DEFAULT '',
|
client_secret TEXT NOT NULL DEFAULT '',
|
||||||
refresh_token TEXT NOT NULL DEFAULT '',
|
refresh_token TEXT NOT NULL DEFAULT '',
|
||||||
enabled INTEGER NOT NULL DEFAULT 1,
|
enabled INTEGER NOT NULL DEFAULT 1,
|
||||||
daily_max INTEGER NOT NULL DEFAULT 1,
|
daily_max INTEGER NOT NULL DEFAULT 3,
|
||||||
title_template TEXT NOT NULL DEFAULT '{anchor} street food live',
|
title_template TEXT NOT NULL DEFAULT '{anchor} street food live',
|
||||||
description_template TEXT NOT NULL DEFAULT '{anchor}\n{url}\n#StreetFood #Live',
|
description_template TEXT NOT NULL DEFAULT '{anchor}\n{url}\n#StreetFood #Live',
|
||||||
privacy TEXT NOT NULL DEFAULT 'public',
|
privacy TEXT NOT NULL DEFAULT 'public',
|
||||||
@ -109,7 +110,7 @@ def yt_long_daily_max(cfg: dict[str, Any] | None = None) -> int:
|
|||||||
v = int(settings.get("yt_long_daily_max") or YT_LONG_DAILY_DEFAULT)
|
v = int(settings.get("yt_long_daily_max") or YT_LONG_DAILY_DEFAULT)
|
||||||
except Exception:
|
except Exception:
|
||||||
v = YT_LONG_DAILY_DEFAULT
|
v = YT_LONG_DAILY_DEFAULT
|
||||||
return max(0, min(50, v))
|
return max(0, min(200, v))
|
||||||
|
|
||||||
|
|
||||||
def yt_long_channel_daily_max(cfg: dict[str, Any] | None = None) -> int:
|
def yt_long_channel_daily_max(cfg: dict[str, Any] | None = None) -> int:
|
||||||
@ -117,10 +118,10 @@ def yt_long_channel_daily_max(cfg: dict[str, Any] | None = None) -> int:
|
|||||||
|
|
||||||
settings = cfg if cfg is not None else db.get_settings_map()
|
settings = cfg if cfg is not None else db.get_settings_map()
|
||||||
try:
|
try:
|
||||||
v = int(settings.get("yt_long_channel_daily_max") or 1)
|
v = int(settings.get("yt_long_channel_daily_max") or YT_LONG_CHANNEL_DEFAULT)
|
||||||
except Exception:
|
except Exception:
|
||||||
v = 1
|
v = YT_LONG_CHANNEL_DEFAULT
|
||||||
return max(0, min(20, v))
|
return max(0, min(50, v))
|
||||||
|
|
||||||
|
|
||||||
def yt_long_quota_used(push_date: str = "") -> int:
|
def yt_long_quota_used(push_date: str = "") -> int:
|
||||||
@ -559,16 +560,16 @@ def create_yt_long_channel(
|
|||||||
client_secret: str = "",
|
client_secret: str = "",
|
||||||
refresh_token: str = "",
|
refresh_token: str = "",
|
||||||
enabled: bool = True,
|
enabled: bool = True,
|
||||||
daily_max: int = 1,
|
daily_max: int = YT_LONG_CHANNEL_DEFAULT,
|
||||||
title_template: str = "{anchor} street food live",
|
title_template: str = "",
|
||||||
description_template: str = "{anchor}\n{url}\n#StreetFood #Live",
|
description_template: str = "",
|
||||||
privacy: str = "public",
|
privacy: str = "public",
|
||||||
note: str = "",
|
note: str = "",
|
||||||
source_shorts_channel_pk: str = "",
|
source_shorts_channel_pk: str = "",
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
now = time.time()
|
now = time.time()
|
||||||
cid = str(uuid.uuid4())
|
cid = str(uuid.uuid4())
|
||||||
dmax = max(0, min(20, int(daily_max or 1)))
|
dmax = max(0, min(50, int(daily_max if daily_max is not None else YT_LONG_CHANNEL_DEFAULT)))
|
||||||
with _lock:
|
with _lock:
|
||||||
conn = _connect()
|
conn = _connect()
|
||||||
try:
|
try:
|
||||||
@ -637,7 +638,7 @@ def update_yt_long_channel(channel_pk: str, **fields: Any) -> dict[str, Any]:
|
|||||||
v = 1 if v else 0
|
v = 1 if v else 0
|
||||||
if k == "daily_max":
|
if k == "daily_max":
|
||||||
try:
|
try:
|
||||||
v = max(0, min(20, int(v)))
|
v = max(0, min(50, int(v)))
|
||||||
except Exception:
|
except Exception:
|
||||||
continue
|
continue
|
||||||
if k == "oauth_profile_id":
|
if k == "oauth_profile_id":
|
||||||
@ -706,9 +707,9 @@ def sync_channels_from_shorts() -> dict[str, Any]:
|
|||||||
).fetchone()
|
).fetchone()
|
||||||
if row:
|
if row:
|
||||||
existing_id = str(row["id"])
|
existing_id = str(row["id"])
|
||||||
keep_dmax = int(row["daily_max"] or 1)
|
keep_dmax = int(row["daily_max"] or YT_LONG_CHANNEL_DEFAULT)
|
||||||
else:
|
else:
|
||||||
keep_dmax = 1
|
keep_dmax = yt_long_channel_daily_max()
|
||||||
finally:
|
finally:
|
||||||
conn.close()
|
conn.close()
|
||||||
name = str(ch.get("name") or "频道").strip() or "频道"
|
name = str(ch.get("name") or "频道").strip() or "频道"
|
||||||
@ -720,7 +721,7 @@ def sync_channels_from_shorts() -> dict[str, Any]:
|
|||||||
"client_secret": str(ch.get("client_secret") or ""),
|
"client_secret": str(ch.get("client_secret") or ""),
|
||||||
"refresh_token": str(ch.get("refresh_token") or ""),
|
"refresh_token": str(ch.get("refresh_token") or ""),
|
||||||
"enabled": bool(ch.get("enabled", True)),
|
"enabled": bool(ch.get("enabled", True)),
|
||||||
"daily_max": keep_dmax,
|
"daily_max": max(YT_LONG_CHANNEL_DEFAULT, keep_dmax) if not existing_id else keep_dmax,
|
||||||
"privacy": str(ch.get("privacy") or "public"),
|
"privacy": str(ch.get("privacy") or "public"),
|
||||||
"note": f"synced from shorts:{src}",
|
"note": f"synced from shorts:{src}",
|
||||||
"source_shorts_channel_pk": src,
|
"source_shorts_channel_pk": src,
|
||||||
|
|||||||
@ -73,7 +73,7 @@ type Job = {
|
|||||||
const emptyForm = {
|
const emptyForm = {
|
||||||
name: "",
|
name: "",
|
||||||
enabled: true,
|
enabled: true,
|
||||||
daily_max: 1,
|
daily_max: 3,
|
||||||
title_template: "",
|
title_template: "",
|
||||||
description_template: "",
|
description_template: "",
|
||||||
privacy: "public",
|
privacy: "public",
|
||||||
@ -209,14 +209,14 @@ export default function YtLongPage() {
|
|||||||
youtube_channel_id: c.youtube_channel_id,
|
youtube_channel_id: c.youtube_channel_id,
|
||||||
oauth_profile_id: c.oauth_profile_id,
|
oauth_profile_id: c.oauth_profile_id,
|
||||||
enabled: c.enabled,
|
enabled: c.enabled,
|
||||||
daily_max: Number(c.daily_max ?? 1),
|
daily_max: Number(c.daily_max ?? 3),
|
||||||
authorized: Boolean(c.authorized || c.has_refresh_token),
|
authorized: Boolean(c.authorized || c.has_refresh_token),
|
||||||
used: 0,
|
used: 0,
|
||||||
scheduled: 0,
|
scheduled: 0,
|
||||||
uploaded: 0,
|
uploaded: 0,
|
||||||
pending: 0,
|
pending: 0,
|
||||||
failed: 0,
|
failed: 0,
|
||||||
gap: Number(c.daily_max ?? 1),
|
gap: Number(c.daily_max ?? 3),
|
||||||
}));
|
}));
|
||||||
return base.map((ch) => ({
|
return base.map((ch) => ({
|
||||||
...ch,
|
...ch,
|
||||||
@ -348,7 +348,7 @@ export default function YtLongPage() {
|
|||||||
setForm({
|
setForm({
|
||||||
name: ch.name || "",
|
name: ch.name || "",
|
||||||
enabled: ch.enabled !== false,
|
enabled: ch.enabled !== false,
|
||||||
daily_max: Number(ch.daily_max ?? 1),
|
daily_max: Number(ch.daily_max ?? 3),
|
||||||
title_template: ch.title_template || "{anchor} street food live",
|
title_template: ch.title_template || "{anchor} street food live",
|
||||||
description_template: ch.description_template || "",
|
description_template: ch.description_template || "",
|
||||||
privacy: ch.privacy || "public",
|
privacy: ch.privacy || "public",
|
||||||
@ -710,7 +710,7 @@ export default function YtLongPage() {
|
|||||||
type="number"
|
type="number"
|
||||||
min={0}
|
min={0}
|
||||||
max={50}
|
max={50}
|
||||||
value={Number(form.daily_max ?? 1)}
|
value={Number(form.daily_max ?? 3)}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
setForm((p) => ({ ...p, daily_max: Math.max(0, Number(e.target.value) || 0) }))
|
setForm((p) => ({ ...p, daily_max: Math.max(0, Number(e.target.value) || 0) }))
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user