| Total Complexity | 3 |
| Total Lines | 22 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import asyncio |
||
| 2 | from univk_audio import AsyncVKMusic |
||
| 3 | |||
| 4 | # Example with 'async with' construction, that closes session automatically |
||
| 5 | |||
| 6 | async def search_with_example(): |
||
| 7 | cookies: str = "Your cookies from auth. See -> auth_example.py" |
||
| 8 | |||
| 9 | # user_agent is optional: |
||
| 10 | user_agent: str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36" |
||
| 11 | |||
| 12 | async with AsyncVKMusic(cookies = cookies, user_agent = user_agent) as music: |
||
| 13 | |||
| 14 | # .search Returns a Dict[str, str] |
||
| 15 | # {"*song-title*": "*download-link*"} |
||
| 16 | |||
| 17 | search_results = await music.search(query = "Imagine Dragons - Bones") |
||
| 18 | for title, download_link in search_results.items(): |
||
| 19 | print(f"{title}\n{download_link}\n" + "-" * 15) |
||
| 20 | |||
| 21 | asyncio.run(search_with_example()) |
||
| 22 |