seawolf2357
commited on
Commit
โข
f05454f
1
Parent(s):
1e3100b
Update app.py
Browse files
app.py
CHANGED
@@ -12,6 +12,7 @@ from huggingface_hub import InferenceClient
|
|
12 |
from youtube_transcript_api import YouTubeTranscriptApi
|
13 |
from youtube_transcript_api.formatters import TextFormatter
|
14 |
from dotenv import load_dotenv
|
|
|
15 |
|
16 |
# ํ๊ฒฝ ๋ณ์ ๋ก๋
|
17 |
load_dotenv()
|
@@ -44,12 +45,13 @@ def authorize():
|
|
44 |
auth_url, _ = flow.authorization_url(prompt='consent')
|
45 |
print('Please go to this URL and finish the authentication: {}'.format(auth_url))
|
46 |
|
47 |
-
print(f'Enter the authorization code in the file {auth_code_path}
|
48 |
-
input('Press Enter after saving the authorization code...')
|
49 |
-
|
50 |
-
if not os.path.exists(auth_code_path):
|
51 |
-
raise FileNotFoundError(f"'{auth_code_path}' ํ์ผ์ด ์กด์ฌํ์ง ์์ต๋๋ค.")
|
52 |
|
|
|
|
|
|
|
|
|
|
|
53 |
with open(auth_code_path, 'r') as file:
|
54 |
code = file.read().strip()
|
55 |
|
@@ -59,6 +61,9 @@ def authorize():
|
|
59 |
with open(token_path, 'w') as token:
|
60 |
token.write(creds.to_json())
|
61 |
|
|
|
|
|
|
|
62 |
return creds
|
63 |
|
64 |
# ๊ธฐ์กด ํ ํฐ์ ๋ก๋ํ๊ฑฐ๋ ์๋ก ์ธ์ฆ
|
|
|
12 |
from youtube_transcript_api import YouTubeTranscriptApi
|
13 |
from youtube_transcript_api.formatters import TextFormatter
|
14 |
from dotenv import load_dotenv
|
15 |
+
import time
|
16 |
|
17 |
# ํ๊ฒฝ ๋ณ์ ๋ก๋
|
18 |
load_dotenv()
|
|
|
45 |
auth_url, _ = flow.authorization_url(prompt='consent')
|
46 |
print('Please go to this URL and finish the authentication: {}'.format(auth_url))
|
47 |
|
48 |
+
print(f'Enter the authorization code in the file {auth_code_path}')
|
|
|
|
|
|
|
|
|
49 |
|
50 |
+
# ํ์ผ์ ์ธ์ฆ ์ฝ๋๊ฐ ์ ์ฅ๋ ๋๊น์ง ๊ธฐ๋ค๋ฆผ
|
51 |
+
while not os.path.exists(auth_code_path):
|
52 |
+
print("Waiting for authorization code...")
|
53 |
+
time.sleep(5)
|
54 |
+
|
55 |
with open(auth_code_path, 'r') as file:
|
56 |
code = file.read().strip()
|
57 |
|
|
|
61 |
with open(token_path, 'w') as token:
|
62 |
token.write(creds.to_json())
|
63 |
|
64 |
+
# ์ธ์ฆ ์ฝ๋ ํ์ผ ์ญ์ (๋ณด์)
|
65 |
+
os.remove(auth_code_path)
|
66 |
+
|
67 |
return creds
|
68 |
|
69 |
# ๊ธฐ์กด ํ ํฐ์ ๋ก๋ํ๊ฑฐ๋ ์๋ก ์ธ์ฆ
|