12345678910111213141516171819202122232425262728 |
- import asyncio
- import config
- from .download import download_playlist, download_video
- from .intervals import get_intervals
- from .info import get_video
- async def download(url, path, filename=None):
- """ Download a given url to path
- if url is video you may set output filename
- """
- is_video = "watch?" in url or ".be/" in url
- is_playlist = "playlist?" in url
- if is_playlist:
- return (await download_playlist(url, path)), None
- elif is_video:
- if config.tracklist:
- description = config.tracklist
- else:
- video = await get_video(url, path)
- description = video["description"]
- intervals = get_intervals(description)
- task = asyncio.create_task(download_video(url, path, filename))
- return [task], intervals
|