Skip to content

Commit

Permalink
Merge pull request davidteather#705 from MuffinFox/by_sound_page
Browse files Browse the repository at this point in the history
by_sound paginated version
  • Loading branch information
davidteather authored Sep 22, 2021
2 parents d7b4abe + 88944f0 commit bef2965
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions TikTokApi/tiktok.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,39 @@ def by_sound(self, id, count=30, offset=0, **kwargs) -> dict:

return response[:count]


def by_sound_page(self, id, page_size=30, cursor=0, **kwargs) -> dict:
"""Returns a page of tiktoks with a specific sound.
Parameters
----------
id: The sound id to search by
Note: Can be found in the URL of the sound specific page or with other methods.
cursor: offset for pagination
page_size: The number of posts to return
"""
(
region,
language,
proxy,
maxCount,
device_id,
) = self.__process_kwargs__(kwargs)
kwargs["custom_device_id"] = device_id

query = {
"musicID": str(id),
"count": str(page_size),
"cursor": cursor,
"language": language,
}
api_url = "{}api/music/item_list/?{}&{}".format(
BASE_URL, self.__add_url_params__(), urlencode(query)
)

return self.get_data(url=api_url, send_tt_params=True, **kwargs)


def get_music_object(self, id, **kwargs) -> dict:
"""Returns a music object for a specific sound id.
Expand Down

0 comments on commit bef2965

Please sign in to comment.