Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions freesound.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,23 @@ def previous_page(self):
Get a Pager with the previous results page.
"""
return FSRequest.request(self.previous, {}, self.client, Pager)
def get_page(self, n):
url = self.next
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail if self.next is None (which could happen if there are no other pages)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Mon, 29 Aug 2016 08:07:56 -0700
Frederic Font [email protected] wrote:

@@ -281,6 +281,23 @@ def previous_page(self):
Get a Pager with the previous results page.
"""
return FSRequest.request(self.previous, {}, self.client, Pager)

  • def get_page(self, n):
  •    url = self.next
    

This will fail if self.next is None (which could happen if there are no other
pages)

True, but it's not going to fail because I do check the boundaries and this is
not called

Salvatore


uri = urlparse(url)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see urlparse being imported anywhere so I guess this won't work out of the box.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Mon, 29 Aug 2016 08:09:05 -0700
Frederic Font [email protected] wrote:

@@ -281,6 +281,23 @@ def previous_page(self):
Get a Pager with the previous results page.
"""
return FSRequest.request(self.previous, {}, self.client, Pager)

  • def get_page(self, n):
  •    url = self.next
    
  •    uri = urlparse(url)
    

I don't see urlparse being imported anywhere so I guess this won't work out
of the box.

I've already commit and test and it works nice. urlparse is defined in freesound_api.py

Salvatore

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Mon, 29 Aug 2016 08:09:05 -0700
Frederic Font [email protected] wrote:

I don't see urlparse being imported anywhere so I guess this won't work out
of the box.

But you're right..I think I forgot to add this in the commit, I will fix it. I will also check
if next is null

Salvatore

for index,item in enumerate(uri):
if ('query' in item):
urid=index

query = uri[urid].split("&")

for index,item in enumerate(query):
if ("page" in item):
query[index] = 'page=' + str(n)

url = uri[0] + '://' + uri[1] + uri[2] + '?' + "&".join(query)
return FSRequest.request(url, {}, self.client, Pager)



class GenericPager(Pager):
Expand Down