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

feature: Accept offset in search_track #48

Closed
cc00010 opened this issue Jan 23, 2023 · 4 comments · Fixed by #57
Closed

feature: Accept offset in search_track #48

cc00010 opened this issue Jan 23, 2023 · 4 comments · Fixed by #57

Comments

@cc00010
Copy link

cc00010 commented Jan 23, 2023

Please consider adding offset parameter to search_track

@cc00010
Copy link
Author

cc00010 commented Jan 23, 2023

Here's the patch:

diff --git a/shazamio/api.py b/shazamio/api.py
index 0feaa0d..21653ad 100644
--- a/shazamio/api.py
+++ b/shazamio/api.py
@@ -274,7 +274,7 @@ class Shazam(Converter, Geo, Request):
             headers=self.headers(),
         )
 
-    async def search_track(self, query: str, limit: int = 10) -> Dict[str, Any]:
+    async def search_track(self, query: str, limit: int = 10, start_from: int = 0) -> Dict[str, Any]:
         """
         Search all tracks by prefix
             :param query: Track full title or prefix title
@@ -287,6 +287,7 @@ class Shazam(Converter, Geo, Request):
             ShazamUrl.SEARCH_MUSIC.format(
                 query,
                 limit,
+                start_from,
                 language=self.language,
             ),
             headers=self.headers(),
diff --git a/shazamio/misc.py b/shazamio/misc.py
index b8e4742..d4fcb19 100644
--- a/shazamio/misc.py
+++ b/shazamio/misc.py
@@ -49,7 +49,7 @@ class ShazamUrl:
     )
     SEARCH_MUSIC = (
         "https://www.shazam.com/services/search/v3/en/GB/web/search?query={}"
-        "&numResults={}&offset=0&types=songs"
+        "&numResults={}&offset={}&types=songs"
     )
     LISTENING_COUNTER = "https://www.shazam.com/services/count/v2/web/track/{}"
 

@dotX12
Copy link
Collaborator

dotX12 commented Jan 31, 2023

Please consider adding offset parameter to search_track

Thanks for your input, I don't have much time right now and would be grateful if you could release a PR with this change! I will accept it.

dotX12 added a commit that referenced this issue May 5, 2023
@dotX12 dotX12 mentioned this issue May 5, 2023
@dotX12
Copy link
Collaborator

dotX12 commented May 5, 2023

Here's the patch:

diff --git a/shazamio/api.py b/shazamio/api.py
index 0feaa0d..21653ad 100644
--- a/shazamio/api.py
+++ b/shazamio/api.py
@@ -274,7 +274,7 @@ class Shazam(Converter, Geo, Request):
             headers=self.headers(),
         )
 
-    async def search_track(self, query: str, limit: int = 10) -> Dict[str, Any]:
+    async def search_track(self, query: str, limit: int = 10, start_from: int = 0) -> Dict[str, Any]:
         """
         Search all tracks by prefix
             :param query: Track full title or prefix title
@@ -287,6 +287,7 @@ class Shazam(Converter, Geo, Request):
             ShazamUrl.SEARCH_MUSIC.format(
                 query,
                 limit,
+                start_from,
                 language=self.language,
             ),
             headers=self.headers(),
diff --git a/shazamio/misc.py b/shazamio/misc.py
index b8e4742..d4fcb19 100644
--- a/shazamio/misc.py
+++ b/shazamio/misc.py
@@ -49,7 +49,7 @@ class ShazamUrl:
     )
     SEARCH_MUSIC = (
         "https://www.shazam.com/services/search/v3/en/GB/web/search?query={}"
-        "&numResults={}&offset=0&types=songs"
+        "&numResults={}&offset={}&types=songs"
     )
     LISTENING_COUNTER = "https://www.shazam.com/services/count/v2/web/track/{}"
 

Hello! Added and renamed start_from to offset.

@dotX12 dotX12 closed this as completed in #57 May 5, 2023
@dotX12
Copy link
Collaborator

dotX12 commented May 5, 2023

Released: https://pypi.org/project/shazamio/0.4.0.0/

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

Successfully merging a pull request may close this issue.

2 participants