Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP. Co-authored-by: Cursor <cursoragent@cursor.com>
67 lines
3.3 KiB
Python
67 lines
3.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Probe monetize payloads for Nomadro Hub latest video."""
|
|
from __future__ import annotations
|
|
import asyncio, json, sys
|
|
import paramiko
|
|
|
|
REMOTE = r"""
|
|
import asyncio, json
|
|
from app import db
|
|
from app import yt_long_db as yldb
|
|
from app.shorts_oauth import channel_oauth_creds
|
|
from app.shorts_upload import refresh_access_token
|
|
from app import yt_long_monetize as ym
|
|
|
|
async def main():
|
|
yl = yldb.get_yt_long_channel('9f51bb18-65dc-4f77-8d88-9c47fe191ad7')
|
|
src = str(yl.get('source_shorts_channel_pk') or '')
|
|
sch = db.get_shorts_channel(src) if src else {}
|
|
creds = channel_oauth_creds(sch if sch else yl)
|
|
access = await refresh_access_token(
|
|
client_id=str(creds['client_id']),
|
|
client_secret=str(creds['client_secret']),
|
|
refresh_token=str(creds['refresh_token']),
|
|
)
|
|
vid = 'w1mrCE6dmnI'
|
|
ch_id = str(yl.get('youtube_channel_id') or '')
|
|
print('channel', yl.get('name'), ch_id)
|
|
ypp = await ym.fetch_channel_ypp_status(access_token=access)
|
|
print('ypp_probe', json.dumps(ypp, ensure_ascii=False))
|
|
verify = await ym.verify_video_monetized(access_token=access, video_id=vid)
|
|
print('verify_before', verify)
|
|
|
|
base = {'encryptedVideoId': vid, 'videoReadMask': {'title': True}}
|
|
ad_formats = {
|
|
'newHasOverlayAds': 'ENABLED',
|
|
'newHasProductListingAds': 'ENABLED',
|
|
'newHasSkippableVideoAds': 'ENABLED',
|
|
'newHasNonSkippableVideoAds': 'ENABLED',
|
|
}
|
|
payloads = [
|
|
('skipped+ads+62', {**base, 'monetizationSettings': {'newMonetizeWithAds': True}, 'adFormats': ad_formats, 'selfCertification': ym._self_cert_skipped(), 'context': ym._context(channel_id=ch_id, client_name=62)}),
|
|
('none_above+web', {**base, 'monetizationSettings': {'newMonetizeWithAds': True}, 'selfCertification': ym._self_cert_none_above(), 'context': ym._context(channel_id=ch_id, client_name='WEB_CREATOR')}),
|
|
('no_int+web', {**base, 'monetizationSettings': {'newMonetizeWithAds': True}, 'selfCertification': ym._self_cert_no(), 'context': ym._context(channel_id=ch_id, client_name='WEB_CREATOR')}),
|
|
('no_legacy+web', {**base, 'monetizationSettings': {'newMonetizeWithAds': True}, 'selfCertification': ym._self_cert_no_legacy(), 'context': ym._context(channel_id=ch_id, client_name='WEB_CREATOR')}),
|
|
('plain+62', {**base, 'monetizationSettings': {'newMonetizeWithAds': True}, 'context': ym._context(channel_id=ch_id, client_name=62)}),
|
|
('plain+web', {**base, 'monetizationSettings': {'newMonetizeWithAds': True}, 'context': ym._context(channel_id=ch_id, client_name='WEB_CREATOR')}),
|
|
]
|
|
for name, body in payloads:
|
|
r = await ym._post_studio(access_token=access, body=body)
|
|
print(name, 'OK' if r.get('ok') else (r.get('error') or '')[:300])
|
|
|
|
verify2 = await ym.verify_video_monetized(access_token=access, video_id=vid)
|
|
print('verify_after', verify2)
|
|
|
|
asyncio.run(main())
|
|
"""
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=30, allow_agent=False, look_for_keys=False)
|
|
_, out, err = c.exec_command(f"cd /opt/douyinWEB/backend && .venv/bin/python - <<'PY'\n{REMOTE}\nPY", timeout=180)
|
|
print(out.read().decode("utf-8", "replace"))
|
|
e = err.read().decode("utf-8", "replace").strip()
|
|
if e:
|
|
print("ERR", e[:800])
|
|
c.close()
|