Chrunos commited on
Commit
b60b5b8
·
verified ·
1 Parent(s): 771847a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -260,7 +260,8 @@ async def process_url(title: str) -> str:
260
  session = cloudscraper.create_scraper()
261
 
262
  # Use the correct API endpoint
263
- response = session.get(api_url)
 
264
 
265
  # Check if the request was successful
266
  response.raise_for_status()
@@ -284,10 +285,9 @@ async def extract_video_info(video_url: str) -> str:
284
  session = cloudscraper.create_scraper()
285
  try:
286
  response = session.get(api_url, timeout=20)
287
- logger.info(response)
288
  if response.status_code == 200:
289
  json_response = response.json()
290
- logger.info(json_response)
291
  result = []
292
  # 检查 formats 列表是否存在且不为空
293
  if 'formats' in json_response:
@@ -302,6 +302,7 @@ async def extract_video_info(video_url: str) -> str:
302
  "cookies": p_cookies
303
  })
304
  title = json_response.get('title')
 
305
  if "pornhub.com" in video_url:
306
  # Remove special characters using a regular expression
307
  title = re.sub(r'[^a-zA-Z0-9\s]', '', title)
@@ -310,7 +311,7 @@ async def extract_video_info(video_url: str) -> str:
310
  title = title.lower()
311
  # Replace spaces with hyphens
312
  title = title.strip().replace(' ', '-')
313
- p_result = process_url(title)
314
  return p_result
315
  else:
316
  return result
 
260
  session = cloudscraper.create_scraper()
261
 
262
  # Use the correct API endpoint
263
+ response = await session.get(api_url)
264
+ logger.info(response)
265
 
266
  # Check if the request was successful
267
  response.raise_for_status()
 
285
  session = cloudscraper.create_scraper()
286
  try:
287
  response = session.get(api_url, timeout=20)
288
+
289
  if response.status_code == 200:
290
  json_response = response.json()
 
291
  result = []
292
  # 检查 formats 列表是否存在且不为空
293
  if 'formats' in json_response:
 
302
  "cookies": p_cookies
303
  })
304
  title = json_response.get('title')
305
+ logger.info(title)
306
  if "pornhub.com" in video_url:
307
  # Remove special characters using a regular expression
308
  title = re.sub(r'[^a-zA-Z0-9\s]', '', title)
 
311
  title = title.lower()
312
  # Replace spaces with hyphens
313
  title = title.strip().replace(' ', '-')
314
+ p_result = await process_url(title)
315
  return p_result
316
  else:
317
  return result