Skip to content

NameError: name 'asyncio' is not defined #2635

@PsycheCE

Description

@PsycheCE

System OS

Windows

Python Version

3.10 (CPython)

Install Source

pip / PyPi

Install version / commit hash

pip install git+https://github.com/TzurSoffer/spotify-downloader

Expected Behavior vs Actual Behavior

  1. I download a playlist
  2. I get NameError: name 'asyncio' is not defined

Steps to reproduce - Ensure to include actual links!

spotdl https://open.spotify.com/playlist/7MclfklT6CD9y2IId7LXk3?si=a0db3d4ada814740

Traceback

An error occurred
╭───────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────╮
│ C:\Users\Gem\AppData\Local\Programs\Python\Python313\Lib\site-packages\spotdl\console\entry_point.py:160 in          │
│ entry_point                                                                                                          │
│                                                                                                                      │
│   157 │   try:                                                                                                       │
│   158 │   │   # Pick the operation to perform                                                                        │
│   159 │   │   # based on the name and run it!                                                                        │
│ ❱ 160 │   │   OPERATIONS[arguments.operation](                                                                       │
│   161 │   │   │   query=arguments.query,                                                                             │
│   162 │   │   │   downloader=downloader,                                                                             │
│   163 │   │   )                                                                                                      │
│                                                                                                                      │
│ C:\Users\Gem\AppData\Local\Programs\Python\Python313\Lib\site-packages\spotdl\console\download.py:25 in download     │
│                                                                                                                      │
│   22 │   """                                                                                                         │
│   23 │                                                                                                               │
│   24 │   # Parse the query                                                                                           │
│ ❱ 25 │   songs = get_simple_songs(                                                                                   │
│   26 │   │   query,                                                                                                  │
│   27 │   │   use_ytm_data=downloader.settings["ytm_data"],                                                           │
│   28 │   │   playlist_numbering=downloader.settings["playlist_numbering"],                                           │
│                                                                                                                      │
│ C:\Users\Gem\AppData\Local\Programs\Python\Python313\Lib\site-packages\spotdl\utils\search.py:264 in                 │
│ get_simple_songs                                                                                                     │
│                                                                                                                      │
│   261 │   │   │   )                                                                                                  │
│   262 │   │   │   songs.extend(full_lists)                                                                           │
│   263 │   │   elif "open.spotify.com" in request and "playlist" in request:                                          │
│ ❱ 264 │   │   │   lists.append(Playlist.from_url(request, fetch_songs=False))                                        │
│   265 │   │   elif "open.spotify.com" in request and "album" in request:                                             │
│   266 │   │   │   lists.append(Album.from_url(request, fetch_songs=False))                                           │
│   267 │   │   elif "open.spotify.com" in request and "artist" in request:                                            │
│                                                                                                                      │
│ C:\Users\Gem\AppData\Local\Programs\Python\Python313\Lib\site-packages\spotdl\types\song.py:306 in from_url          │
│                                                                                                                      │
│   303 │   │   - The SongList object.                                                                                 │
│   304 │   │   """                                                                                                    │
│   305 │   │                                                                                                          │
│ ❱ 306 │   │   metadata, songs = cls.get_metadata(url)                                                                │
│   307 │   │   urls = [song.url for song in songs]                                                                    │
│   308 │   │                                                                                                          │
│   309 │   │   if fetch_songs:                                                                                        │
│                                                                                                                      │
│ C:\Users\Gem\AppData\Local\Programs\Python\Python313\Lib\site-packages\spotdl\types\playlist.py:72 in get_metadata   │
│                                                                                                                      │
│    69 │   │   │   ),                                                                                                 │
│    70 │   │   }                                                                                                      │
│    71 │   │                                                                                                          │
│ ❱  72 │   │   playlist_response = spotify_client.playlist_items(url)                                                 │
│    73 │   │   if playlist_response is None:                                                                          │
│    74 │   │   │   raise PlaylistError(f"Wrong playlist id: {url}")                                                   │
│    75                                                                                                                │
│                                                                                                                      │
│ C:\Users\Gem\AppData\Local\Programs\Python\Python313\Lib\site-packages\SpotipyFree\Spotify.py:279 in playlist_items  │
│                                                                                                                      │
│   276 │                                                                                                              │
│   277 │   def playlist_items(self, *args, **kwargs):                                                                 │
│   278 │   │   try:                                                                                                   │
│ ❱ 279 │   │   │   loop = asyncio.get_event_loop()   #< bind to async thread if already exists                        │
│       # type: ignore                                                                                                 │
│   280 │   │   │   return(loop.run_until_complete(                                                                    │
│   281 │   │   │   │   self.playlist_items_async(*args, **kwargs)                                                     │
│   282 │   │   │   ))                                                                                                 │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
NameError: name 'asyncio' is not defined

Other details

I imported asyncio to fix 👍

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugUnexpected problem or unintended behavior that needs to be fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions