Spaces:
Sleeping
Sleeping
Delete app.py
Browse files
app.py
DELETED
@@ -1,41 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
from googleapiclient.discovery import build
|
3 |
-
from google_auth_oauthlib.flow import InstalledAppFlow
|
4 |
-
from google.auth.transport.requests import Request
|
5 |
-
from google.oauth2.credentials import Credentials
|
6 |
-
|
7 |
-
# YouTube API ์ค์ฝํ ๋ฐ ํ์ํ ์ธ์ฆ ์ ๋ณด
|
8 |
-
SCOPES = ['https://www.googleapis.com/auth/youtube.force-ssl']
|
9 |
-
CLIENT_SECRETS_FILE = 'YOUR_CLIENT_SECRETS_FILE.json'
|
10 |
-
|
11 |
-
def update_video_descriptions(additional_text):
|
12 |
-
# ์ฌ์ฉ์ ์ธ์ฆ ๋ฐ YouTube API ํด๋ผ์ด์ธํธ ์ด๊ธฐํ
|
13 |
-
creds = None
|
14 |
-
flow = InstalledAppFlow.from_client_secrets_file(CLIENT_SECRETS_FILE, SCOPES)
|
15 |
-
creds = flow.run_local_server(port=0)
|
16 |
-
youtube = build('youtube', 'v3', credentials=creds)
|
17 |
-
|
18 |
-
# ์ฌ์ฉ์์ YouTube ์ฑ๋ ๋์์ ๋ชฉ๋ก ๊ฐ์ ธ์ค๊ธฐ
|
19 |
-
request = youtube.videos().list(part='snippet', mine=True)
|
20 |
-
response = request.execute()
|
21 |
-
|
22 |
-
for video in response.get('items', []):
|
23 |
-
video_id = video['id']
|
24 |
-
snippet = video['snippet']
|
25 |
-
original_description = snippet['description']
|
26 |
-
|
27 |
-
# ์ค๋ช
๋ ์
๋ฐ์ดํธ
|
28 |
-
updated_description = f"{original_description}\n\n{additional_text}"
|
29 |
-
snippet['description'] = updated_description
|
30 |
-
|
31 |
-
update_request = youtube.videos().update(part='snippet', body={'id': video_id, 'snippet': snippet})
|
32 |
-
update_request.execute()
|
33 |
-
|
34 |
-
return f"Updated descriptions for {len(response.get('items', []))} videos."
|
35 |
-
|
36 |
-
# Gradio ์ธํฐํ์ด์ค
|
37 |
-
def add_text_to_videos(text):
|
38 |
-
return update_video_descriptions(text)
|
39 |
-
|
40 |
-
interface = gr.Interface(fn=add_text_to_videos, inputs="text", outputs="text")
|
41 |
-
interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|