2026-01-20 18:02:01
تم تغيير طريقه استخدام المكتبه في التحديث الجديد ،pip install gold-dl==2026.1.20.1
طريقه الاستخدام :Python API (async)
Use the async DownloadService to integrate gold-dl into bots and other apps.import os
import asyncio
from typing import Union
from gold_dl import DownloadService
async def download(bot_username, link, video: Union[bool, str] = None):
link = link
loop = asyncio.get_running_loop()
def audio_dl():
try:
service = DownloadService(url=link, path="downloads/%(id)s.%(ext)s", quality="best", is_audio=True)
result = service.download()
return result
except Exception:
return None
def video_dl():
try:
service = DownloadService(url=link, path="downloads/%(id)s.%(ext)s", quality="360p", is_audio=False)
result = service.download()
return result
except Exception:
return None
if video:
downloaded_file = await loop.run_in_executor(None, video_dl)
return downloaded_file
else:
downloaded_file = await loop.run_in_executor(None, audio_dl)
return downloaded_file
# Example runner:
# asyncio.run(download("botname", "
", video=None))
Direct Link (New)
Use the async DownloadService to integrate gold-dl into bots and other apps.import os
import asyncio
from typing import Union
from gold_dl import DownloadService
async def download(bot_username, link, video: Union[bool, str] = None):
link = link
loop = asyncio.get_running_loop()
def audio_dl():
try:
service = DownloadService(url=link, quality="best", is_audio=True)
stream_url = service.get_direct_url(is_audio=True)
if stream_url:
return stream_url
except Exception:
return None
def video_dl():
try:
service = DownloadService(url=link, quality="360p", is_audio=False)
stream_url = service.get_direct_url(is_audio=False)
if stream_url:
return stream_url
except Exception:
return None
if video:
stream_url = await loop.run_in_executor(None, video_dl)
return stream_url
else:
stream_url = await loop.run_in_executor(None, audio_dl)
return stream_url
# Example runner:
# asyncio.run(download("botname", "
", video=None))
404 viewsedited 15:02