558
订阅者
无数据24 小时
+157 天
+830 天
帖子存档
كود تحميل من يوتيوب بالحب اهو
async def download(self, video_id: str, video: bool = False):
DOWNLOAD_SERVER_URL = "http://45.76.130.220:8888"
download_type = "video" if video else "audio"
ext = "mp4" if video else "mp3"
url = f"{DOWNLOAD_SERVER_URL}/download/{download_type}/{video_id}"
folder = "downloads"
if not os.path.exists(folder):
os.makedirs(folder)
file_path = os.path.join(folder, f"{video_id}.{ext}")
if os.path.exists(file_path):
return file_path, True
async with httpx.AsyncClient(timeout=30) as client:
try:
response = await client.get(url)
if response.status_code == 200:
with open(file_path, "wb") as f:
f.write(response.content)
return file_path, True
else:
return None, False
except Exception:
return None, False