Spaces:
Running
Running
Fix Google Drive direct video downloads
Browse files305 unmodified lines3063073083093103113123133143159 unmodified lines325326327324328329330331248 unmodified lines580581582579583584585586305 unmodified lines return next(group for group in match.groups() if group)
def drive_download_url(file_id): return f"https://drive.usercontent.google.com/download?id={file_id}&export=download&confirm=t"
def drive_file_name(content_disposition, file_id): message = Message() if content_disposition:9 unmodified lines
async def download_drive_file(link, destination): file_id = drive_file_id(link) url = f"https://drive.google.com/uc?export=download&confirm=t&id={file_id}" url = drive_download_url(file_id) total = 0 async with httpx.AsyncClient(follow_redirects=True, timeout=300) as client: async with client.stream("GET", url) as response:248 unmodified lines result = {"link": str(link)} try: file_id = drive_file_id(str(link)) with httpx.stream("GET", f"https://drive.google.com/uc?export=download&confirm=t&id={file_id}", follow_redirects=True, timeout=30) as response: with httpx.stream("GET", drive_download_url(file_id), follow_redirects=True, timeout=30) as response: content_type = response.headers.get("content-type", "") content_disposition = response.headers.get("content-disposition", "") size = int(response.headers.get("content-length", "0") or 0)app.py+6-2