samir72 commited on
Commit
5c45d3a
·
1 Parent(s): f3e52a7

Resolve cookies expiry issue

Browse files
app.py CHANGED
@@ -160,6 +160,7 @@ def fetch_audio_from_youtube(youtube_url: str) -> str:
160
  - Accepts either JSON {"audio_url": "..."} or a plain string URL.
161
  """
162
  EXTRACT_API = os.getenv("AZURE_CONTAINER_APP_FQDN") ## Fast API endpoint for youtube extraction "https://<your-app-fqdn>/extract"
 
163
  base = EXTRACT_API.rstrip("/")
164
  endpoint = base if base.endswith("/extract") else f"{base}/extract"
165
 
 
160
  - Accepts either JSON {"audio_url": "..."} or a plain string URL.
161
  """
162
  EXTRACT_API = os.getenv("AZURE_CONTAINER_APP_FQDN") ## Fast API endpoint for youtube extraction "https://<your-app-fqdn>/extract"
163
+ print(f"Extract_API value: {EXTRACT_API}")
164
  base = EXTRACT_API.rstrip("/")
165
  endpoint = base if base.endswith("/extract") else f"{base}/extract"
166
 
extract/Dockerfile CHANGED
@@ -29,6 +29,11 @@ ENV HOST=0.0.0.0
29
  ENV PORT=8080
30
  ENV AZURE_STORAGE_ACCOUNT=__SET_AT_DEPLOY__
31
  ENV AZURE_BLOB_CONTAINER=__SET_AT_DEPLOY__
 
 
 
 
 
32
 
33
  EXPOSE 8080
34
 
 
29
  ENV PORT=8080
30
  ENV AZURE_STORAGE_ACCOUNT=__SET_AT_DEPLOY__
31
  ENV AZURE_BLOB_CONTAINER=__SET_AT_DEPLOY__
32
+ ENV COOKIES_ACCOUNT=__SET_AT_DEPLOY__
33
+ ENV COOKIES_CONTAINER=__SET_AT_DEPLOY__
34
+ ENV COOKIES_BLOB=__SET_AT_DEPLOY__
35
+ ENV COOKIES_PATH=__SET_AT_DEPLOY__
36
+ ENV COOKIES_REFRESH_SEC=__SET_AT_DEPLOY__
37
 
38
  EXPOSE 8080
39
 
extract/app/Youtubeextraction.py CHANGED
@@ -97,6 +97,7 @@ def extract(
97
  # Call the cookies refresher to start refreshing cookies in background
98
  start_cookies_refresher()
99
  cookies_path = os.getenv("COOKIES_PATH")
 
100
  if not cookies_path:
101
  cookies_path = None
102
  print("Cookie file NOT found in container!")
 
97
  # Call the cookies refresher to start refreshing cookies in background
98
  start_cookies_refresher()
99
  cookies_path = os.getenv("COOKIES_PATH")
100
+ print(f"cookies_path value: {cookies_path}")
101
  if not cookies_path:
102
  cookies_path = None
103
  print("Cookie file NOT found in container!")
extract/app/__pycache__/Youtubeextraction.cpython-313.pyc CHANGED
Binary files a/extract/app/__pycache__/Youtubeextraction.cpython-313.pyc and b/extract/app/__pycache__/Youtubeextraction.cpython-313.pyc differ
 
extract/utils/__pycache__/cookies_refresher.cpython-313.pyc CHANGED
Binary files a/extract/utils/__pycache__/cookies_refresher.cpython-313.pyc and b/extract/utils/__pycache__/cookies_refresher.cpython-313.pyc differ
 
extract/utils/__pycache__/storage.cpython-313.pyc CHANGED
Binary files a/extract/utils/__pycache__/storage.cpython-313.pyc and b/extract/utils/__pycache__/storage.cpython-313.pyc differ
 
extract/utils/cookies_refresher.py CHANGED
@@ -4,11 +4,11 @@ from azure.storage.blob import BlobClient
4
  from dotenv import load_dotenv
5
 
6
  load_dotenv()
7
- ACCOUNT = os.getenv("AZURE_STORAGE_ACCOUNT") # storage account name
8
- CONTAINER= os.getenv("COOKIES_CONTAINER")
9
- BLOB = os.getenv("COOKIES_BLOB")
10
- OUT_PATH = os.getenv("COOKIES_PATH")
11
- REFRESH = int(os.getenv("COOKIES_REFRESH_SEC"))
12
 
13
  def _sha256(b: bytes) -> str: return hashlib.sha256(b).hexdigest()
14
  def _read(path: str) -> bytes:
 
4
  from dotenv import load_dotenv
5
 
6
  load_dotenv()
7
+ ACCOUNT = os.getenv("AZURE_STORAGE_ACCOUNT","yt-extractor-rg") # storage account name
8
+ CONTAINER= os.getenv("COOKIES_CONTAINER","cookies") # container name
9
+ BLOB = os.getenv("COOKIES_BLOB","cookies.txt") # blob name
10
+ OUT_PATH = os.getenv("COOKIES_PATH","/tmp/cookies.txt") # local path to write cookies
11
+ REFRESH = int(os.getenv("COOKIES_REFRESH_SEC", "600")) # Default to 10 minutes
12
 
13
  def _sha256(b: bytes) -> str: return hashlib.sha256(b).hexdigest()
14
  def _read(path: str) -> bytes:
extract/utils/storage.py CHANGED
@@ -7,8 +7,8 @@ from azure.storage.blob import (
7
  )
8
 
9
  load_dotenv()
10
- ACCOUNT_NAME = os.getenv("AZURE_STORAGE_ACCOUNT")
11
- CONTAINER = os.getenv("AZURE_BLOB_CONTAINER")
12
 
13
  # Use Managed Identity in Azure; locally DefaultAzureCredential also works
14
  def _credential():
 
7
  )
8
 
9
  load_dotenv()
10
+ ACCOUNT_NAME = os.getenv("AZURE_STORAGE_ACCOUNT","ytstore7135")
11
+ CONTAINER = os.getenv("AZURE_BLOB_CONTAINER","audio")
12
 
13
  # Use Managed Identity in Azure; locally DefaultAzureCredential also works
14
  def _credential():