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

pick api changes breaks qobuz-dl #176

Closed
mokrafoka opened this issue Oct 28, 2022 · 5 comments
Closed

pick api changes breaks qobuz-dl #176

mokrafoka opened this issue Oct 28, 2022 · 5 comments

Comments

@mokrafoka
Copy link

Hi,
since pick 2.0.0 release the options_map_func parameter has been dropped.
qobuz-dl (Version: 0.9.9.7 according to pip3) still seems to rely on an older version of pick which causes it to fail on ubuntu 22.04 where pick is already updated to pick 2.0.2.

see:

options_map_func=get_title_text,

options_map_func=get_quality_text,

@mokrafoka
Copy link
Author

mokrafoka commented Oct 28, 2022

Btw,

my naive approach to fix this would look this. But I'm sure it can be done much more elegant.
update: fixed quality selection

--- core.py	2022-10-28 16:31:24.307065961 +0200
+++ /usr/local/lib/python3.10/dist-packages/qobuz_dl/core.py	2022-10-28 16:32:21.651706830 +0200
@@ -274,7 +274,7 @@
 
     def interactive(self, download=True):
         try:
-            from pick import pick
+            from pick import pick, Option
         except (ImportError, ModuleNotFoundError):
             if os.name == "nt":
                 sys.exit(
@@ -283,6 +283,13 @@
                 )
             raise
 
+        qualitiesOpts = [
+           Option("320", 5),
+           Option("Lossless", 6),
+           Option("Hi-res =< 96kHz", 7),
+           Option("Hi-Res > 96 kHz", 27),
+        ]
+         
         qualities = [
             {"q_string": "320", "q": 5},
             {"q_string": "Lossless", "q": 6},
@@ -320,15 +327,15 @@
                     "(one or more)\nPress Ctrl + c to quit\n"
                     "Don't select anything to try another search"
                 )
+                optionTexts = [ Option(i["text"], i["url"]) for i in options]
                 selected_items = pick(
-                    options,
+                    optionTexts,
                     title,
                     multiselect=True,
                     min_selection_count=0,
-                    options_map_func=get_title_text,
                 )
                 if len(selected_items) > 0:
-                    [final_url_list.append(i[0]["url"]) for i in selected_items]
+                    [final_url_list.append(i[0].value) for i in selected_items]
                     y_n = pick(
                         ["Yes", "No"],
                         "Items were added to queue to be downloaded. "
@@ -345,12 +352,11 @@
                     "be automatically\ndowngraded if the selected "
                     "is not found)"
                 )
-                self.quality = pick(
-                    qualities,
+                self.quality = pick(
+                    qualitiesOpts,
                     desc,
-                    default_index=1,
-                    options_map_func=get_quality_text,
-                )[0]["q"]
+                    default_index=1
+                )[0].value
 
                 if download:
                     self.download_list_of_urls(final_url_list)

@TheDonPaul
Copy link

I can confirm these changes solve the problem I also experienced.

@hv-dev
Copy link

hv-dev commented Nov 13, 2022

Hi, do you have the updated core.py? I'm having trouble implementing your fix myself as I'm not a python dev.

@mokrafoka
Copy link
Author

Hi, do you have the updated core.py? I'm having trouble implementing your fix myself as I'm not a python dev.

Yes, this is a patch for core.py.
Copy/paste this patch into a new file like mypatch.patch and then download the sources of qobuz-dl if necessary. Then go to the directory where core.py is stored in and apply this patch using patch -p0 path/to/mypatch.path

@vitiko98
Copy link
Owner

I updated the requirements to met pick's 1.6.0 version. Please re-open the issue if the error persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants