diff --git a/README.md b/README.md index 763f37e2..ae57ff98 100644 --- a/README.md +++ b/README.md @@ -65,11 +65,9 @@ pip install TikTokApi python -m playwright install ``` -If you run into any issue try the fix below before posting an issue. +If you're on MacOS you may need to install [XCode Developer Tools](https://webkit.org/build-tools/) -**If you still run into issues you may need to install chromedriver for your machine globally. Download it [here](https://sites.google.com/a/chromium.org/chromedriver/) and add it to your path.** - ### Common Issues Please don't open an issue if you're experiencing one of these just comment if the provided solution do not work for you. diff --git a/TikTokApi/tiktok.py b/TikTokApi/tiktok.py index 192ec2a7..31209d44 100644 --- a/TikTokApi/tiktok.py +++ b/TikTokApi/tiktok.py @@ -26,7 +26,7 @@ def __init__(self, **kwargs): TikTokApi.__instance = self else: raise Exception("Only one TikTokApi object is allowed") - logging.basicConfig(level=kwargs.get("logging_level", logging.CRITICAL)) + logging.basicConfig(level=kwargs.get("logging_level", logging.WARNING)) logging.info("Class initalized") self.executablePath = kwargs.get("executablePath", None) @@ -263,7 +263,6 @@ def trending(self, count=30, minCursor=0, maxCursor=0, **kwargs) -> dict: realCount = count - len(response) maxCursor = res["maxCursor"] - minCursor = res['minCursor'] first = False @@ -702,8 +701,8 @@ def getMusicObject(self, id, **kwargs) -> dict: kwargs['custom_did'] = did query = {"musicId": id, "language": language} - api_url = "{}api/music/detail/?{}&{}".format( - BASE_URL, self.__add_new_params__(), urlencode(query) + api_url = "{}node/share/music/{}?{}&{}".format( + BASE_URL, self.get_music_title(id) + "-" + str(id), self.__add_new_params__(), urlencode(query) ) return self.getData(url=api_url, **kwargs) @@ -777,9 +776,9 @@ def getHashtagObject(self, hashtag, **kwargs) -> dict: did, ) = self.__process_kwargs__(kwargs) kwargs['custom_did'] = did - query = {"challengeName": hashtag, "language": language} - api_url = "{}api/challenge/detail/?{}&{}".format( - BASE_URL, self.__add_new_params__(), urlencode(query) + query = {"name": hashtag, "isName": True, "lang": language} + api_url = "{}node/share/tag/{}?{}&{}".format( + BASE_URL, quote(hashtag), self.__add_new_params__(), urlencode(query) ) return self.getData(url=api_url, **kwargs) @@ -791,6 +790,7 @@ def getHashtagDetails(self, hashtag, **kwargs) -> dict: Note: Doesn't seem to have an affect. :param proxy: The IP address of a proxy to make requests from. """ + logging.warning("The getHashtagDetails will be deprecated in a future version. Replace it with getHashtagObject") ( region, language, @@ -799,7 +799,7 @@ def getHashtagDetails(self, hashtag, **kwargs) -> dict: did, ) = self.__process_kwargs__(kwargs) kwargs['custom_did'] = did - query = {"language": language} + query = {"lang": language} api_url = "{}node/share/tag/{}?{}&{}".format( BASE_URL, quote(hashtag), self.__add_new_params__(), urlencode(query) ) @@ -1001,9 +1001,9 @@ def getUser(self, username, **kwargs) -> dict: did, ) = self.__process_kwargs__(kwargs) kwargs['custom_did'] = did - query = {"uniqueId": username, "language": language} - api_url = "{}api/user/detail/?{}&{}".format( - BASE_URL, self.__add_new_params__(), urlencode(query) + query = {"uniqueId": username, "language": language, "isUniqueId": True, "validUniqueId": username} + api_url = "{}node/share/user/@{}?{}&{}".format( + BASE_URL, quote(username), self.__add_new_params__(), urlencode(query) ) return self.getData(url=api_url, **kwargs)["userInfo"] @@ -1333,6 +1333,11 @@ def get_Video_No_Watermark(self, video_url, return_bytes=0, **kwargs) -> bytes: r = requests.get(b.redirect_url, proxies=self.__format_proxy(proxy)) return r.content + def get_music_title(self, id): + r = requests.get("https://www.tiktok.com/music/-{}".format(id)) + text = r.text.split('TikTok","desc":')[0] + on_tiktok = text.split(" | ") + return on_tiktok[len(on_tiktok)-2].split(" ")[1] # # PRIVATE METHODS # @@ -1378,6 +1383,7 @@ def __add_new_params__(self) -> str: "isMobile": False, "isIOS": False, "OS": "windows", + "page_referer": "https://www.tiktok.com/" } return urlencode(query) diff --git a/TikTokApi/utilities.py b/TikTokApi/utilities.py index 7c01e353..d649945c 100644 --- a/TikTokApi/utilities.py +++ b/TikTokApi/utilities.py @@ -3,9 +3,9 @@ import pkg_resources def update_messager(): - #if not check("TikTokApi"): + if not check("TikTokApi"): # Outdated - # print("TikTokApi package is outdated, please consider upgrading! \n(You can suppress this by setting ignore_version to True while calling the TikTok Api class)") + print("TikTokApi package is outdated, please consider upgrading! \n(You can suppress this by setting ignore_version=True in the TikTokApi constructor)") if not check_future_deprecation(): print("Your version of python is going to be deprecated, for future updates upgrade to 3.7+") diff --git a/setup.py b/setup.py index 3df20b5f..77782b92 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name="TikTokApi", packages=["TikTokApi"], - version="3.7.5", + version="3.7.6", license="MIT", description="The Unofficial TikTok API Wrapper in Python 3.", author="David Teather",