seawolf2357 commited on
Commit
f05454f
โ€ข
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
  # ๊ธฐ์กด ํ† ํฐ์„ ๋กœ๋“œํ•˜๊ฑฐ๋‚˜ ์ƒˆ๋กœ ์ธ์ฆ