Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown format code 'd' for object of type 'float' #2037

Open
R3TRO04 opened this issue Mar 3, 2024 · 2 comments
Open

Unknown format code 'd' for object of type 'float' #2037

R3TRO04 opened this issue Mar 3, 2024 · 2 comments
Labels
Bug Unexpected problem or unintended behavior that needs to be fixed

Comments

@R3TRO04
Copy link

R3TRO04 commented Mar 3, 2024

System OS

Windows

Python Version

3.11 (CPython)

Install Source

Termux Installation Script (spotDL provided)

Install version / commit hash

4.2.4

Expected Behavior vs Actual Behavior

Everytime i want to download a song, nevertheless i use an url or a song name i get:
Unknown format code 'd' for object of type 'float' in formatter.py

Steps to reproduce - Ensure to include actual links!

  1. type spotdl "trackname" in cmd

Traceback

During handling of the above exception, another exception occurred:

╭──────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────╮
│ C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\spotdl\console\entry_point.py:137 in console_entry_point │
│                                                                                                                                   │
│   134 │   try:                                                                                                                    │
│   135 │   │   # Pick the operation to perform                                                                                     │
│   136 │   │   # based on the name and run it!                                                                                     │
│ ❱ 137 │   │   OPERATIONS[arguments.operation](                                                                                    │
│   138 │   │   │   query=arguments.query,                                                                                          │
│   139 │   │   │   downloader=downloader,                                                                                          │
│   140 │   │   )                                                                                                                   │
│                                                                                                                                   │
│ C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\spotdl\console\download.py:33 in download                │
│                                                                                                                                   │
│   30 │   )                                                                                                                        │
│   31 │                                                                                                                            │
│   32 │   # Download the songs                                                                                                     │
│ ❱ 33 │   downloader.download_multiple_songs(songs)                                                                                │
│   34                                                                                                                              │
│                                                                                                                                   │
│ C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\spotdl\download\downloader.py:291 in                     │
│ download_multiple_songs                                                                                                           │
│                                                                                                                                   │
│   288 │   │   tasks = [self.pool_download(song) for song in songs]                                                                │
│   289 │   │                                                                                                                       │
│   290 │   │   # Call all task asynchronously, and wait until all are finished                                                     │
│ ❱ 291 │   │   results = list(self.loop.run_until_complete(asyncio.gather(*tasks)))                                                │
│   292 │   │                                                                                                                       │
│   293 │   │   # Print errors                                                                                                      │
│   294 │   │   if self.settings["print_errors"]:                                                                                   │
│                                                                                                                                   │
│ C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py:664 in run_until_complete                       │
│                                                                                                                                   │
│    661 │   │   if not future.done():                                                                                              │
│    662 │   │   │   raise RuntimeError('Event loop stopped before Future completed.')                                              │
│    663 │   │                                                                                                                      │
│ ❱  664 │   │   return future.result()                                                                                             │
│    665 │                                                                                                                          │
│    666 │   def stop(self):                                                                                                        │
│    667 │   │   """Stop running the event loop.                                                                                    │
│                                                                                                                                   │
│ C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\spotdl\download\downloader.py:363 in pool_download       │
│                                                                                                                                   │
│   360 │   │   # tasks that cannot acquire semaphore will wait here until it's free                                                │
│   361 │   │   # only certain amount of tasks can acquire the semaphore at the same time                                           │
│   362 │   │   async with self.semaphore:                                                                                          │
│ ❱ 363 │   │   │   return await self.loop.run_in_executor(None, self.search_and_download, song)                                    │
│   364 │                                                                                                                           │
│   365 │   def search(self, song: Song) -> str:                                                                                    │
│   366 │   │   """                                                                                                                 │
│                                                                                                                                   │
│ C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\concurrent\futures\thread.py:58 in run                                 │
│                                                                                                                                   │
│    55 │   │   │   return                                                                                                          │
│    56 │   │                                                                                                                       │
│    57 │   │   try:                                                                                                                │
│ ❱  58 │   │   │   result = self.fn(*self.args, **self.kwargs)                                                                     │
│    59 │   │   except BaseException as exc:                                                                                        │
│    60 │   │   │   self.future.set_exception(exc)                                                                                  │
│    61 │   │   │   # Break a reference cycle with the exception 'exc'                                                              │
│                                                                                                                                   │
│ C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\spotdl\download\downloader.py:449 in search_and_download │
│                                                                                                                                   │
│   446 │   │   except Exception:                                                                                                   │
│   447 │   │   │   song = reinit_song(song)                                                                                        │
│   448 │   │   │                                                                                                                   │
│ ❱ 449 │   │   │   output_file = create_file_name(                                                                                 │
│   450 │   │   │   │   song=song,                                                                                                  │
│   451 │   │   │   │   template=self.settings["output"],                                                                           │
│   452 │   │   │   │   file_extension=self.settings["format"],                                                                     │
│                                                                                                                                   │
│ C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\spotdl\utils\formatter.py:332 in create_file_name        │
│                                                                                                                                   │
│   329 │   if not template.endswith(".{output-ext}"):                                                                              │
│   330 │   │   template += ".{output-ext}"                                                                                         │
│   331 │                                                                                                                           │
│ ❱ 332 │   formatted_string = format_query(                                                                                        │
│   333 │   │   song=song,                                                                                                          │
│   334 │   │   template=template,                                                                                                  │
│   335 │   │   santitize=True,                                                                                                     │
│                                                                                                                                   │
│ C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\spotdl\utils\formatter.py:235 in format_query            │
│                                                                                                                                   │
│   232 │   │   "{duration}": song.duration,                                                                                        │
│   233 │   │   "{year}": song.year,                                                                                                │
│   234 │   │   "{original-date}": song.date,                                                                                       │
│ ❱ 235 │   │   "{track-number}": f"{song.track_number:02d}" if song.track_number else "",                                          │
│   236 │   │   "{tracks-count}": song.tracks_count,                                                                                │
│   237 │   │   "{isrc}": song.isrc,                                                                                                │
│   238 │   │   "{track-id}": song.song_id,
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: Unknown format code 'd' for object of type 'float'

Other details

An easy fix would be to change line 235 from
"{track-number}": f"{song.track_number:02d}" if song.track_number else "",
to
"{track-number}": f"{song.track_number:02f}" if song.track_number else "",

@R3TRO04 R3TRO04 added the Bug Unexpected problem or unintended behavior that needs to be fixed label Mar 3, 2024
@ilyas121
Copy link

ilyas121 commented Mar 5, 2024

ran into the same issue when I was bulk-syncing all my albums today, @R3TRO04 did you build manually with the change at line 235 to fix?

@R3TRO04
Copy link
Author

R3TRO04 commented Mar 6, 2024

@ilyas121 yes i did and it works for me 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Unexpected problem or unintended behavior that needs to be fixed
Projects
None yet
Development

No branches or pull requests

2 participants