Spaces:
Paused
Paused
| #!/usr/bin/env python3 | |
| """ | |
| Run this ONCE on your Mac to generate token.pickle. | |
| Then upload it to HF Dataset: arshitmalik/yt-pipeline-data | |
| """ | |
| import pickle, json | |
| from pathlib import Path | |
| from google_auth_oauthlib.flow import InstalledAppFlow | |
| SCOPES = ["https://www.googleapis.com/auth/youtube.upload"] | |
| import os | |
| cid = os.environ.get("YOUTUBE_CLIENT_ID", "") | |
| cs = os.environ.get("YOUTUBE_CLIENT_SECRET", "") | |
| if cid and cs and not Path("client_secrets.json").exists(): | |
| Path("client_secrets.json").write_text(json.dumps({"installed": { | |
| "client_id": cid, "project_id": "yt-ai-bot", | |
| "auth_uri": "https://accounts.google.com/o/oauth2/auth", | |
| "token_uri": "https://oauth2.googleapis.com/token", | |
| "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", | |
| "client_secret": cs, "redirect_uris": ["http://localhost"]}})) | |
| flow = InstalledAppFlow.from_client_secrets_file("client_secrets.json", SCOPES) | |
| creds = flow.run_local_server(port=0) | |
| with open("token.pickle", "wb") as f: | |
| pickle.dump(creds, f) | |
| print("token.pickle saved! Now run the upload command below.") | |