search_with_example.search_with_example()   A
last analyzed

Complexity

Conditions 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 14
rs 10
c 0
b 0
f 0
cc 3
nop 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