seawolf2357 commited on
Commit
f05454f
·
verified ·
1 Parent(s): 1e3100b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
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} and press Enter')
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
  # 기존 토큰을 로드하거나 새로 인증