Skip to content

Commit

Permalink
Merge pull request #339 from davidteather/nightly
Browse files Browse the repository at this point in the history
Fix #338
  • Loading branch information
davidteather authored Nov 11, 2020
2 parents 644a059 + 1feb07c commit 6e35d5e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
28 changes: 17 additions & 11 deletions TikTokApi/tiktok.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand All @@ -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,
Expand All @@ -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)
)
Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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
#
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions TikTokApi/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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+")
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 6e35d5e

Please sign in to comment.