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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -6
app.py CHANGED
@@ -253,15 +253,14 @@ async def get_track_download_url(video_url: str) -> str:
253
 
254
 
255
 
256
- async def process_url(video_url: str) -> str:
257
  try:
258
  # Step 1: Download the URL
259
- api_url = "https://www.saveporn.net/convert/"
260
  session = cloudscraper.create_scraper()
261
- form_data = {"url": video_url}
262
-
263
  # Use the correct API endpoint
264
- response = session.post(api_url, data=form_data)
265
 
266
  # Check if the request was successful
267
  response.raise_for_status()
@@ -303,7 +302,18 @@ async def extract_video_info(video_url: str) -> str:
303
  "cookies": p_cookies
304
  })
305
  title = json_response.get('title')
306
- return result
 
 
 
 
 
 
 
 
 
 
 
307
  else:
308
  return {"error": "No formats available"}
309
  else:
 
253
 
254
 
255
 
256
+ async def process_url(title: str) -> str:
257
  try:
258
  # Step 1: Download the URL
259
+ api_url = f"https://www.saveporn.net/{title}/"
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()
 
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)
308
+ # Replace multiple spaces with a single space
309
+ title = re.sub(r'\s+', ' ', title)
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
317
  else:
318
  return {"error": "No formats available"}
319
  else: