Patching system, video by id
This commit is contained in:
parent
38fa75402b
commit
c6b0f1e812
19 changed files with 305 additions and 60 deletions
40
patches/0001-Fixed-getUser.patch
Normal file
40
patches/0001-Fixed-getUser.patch
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
From 7c52f9291fbd15d912fa78d0301939e3aa9deec4 Mon Sep 17 00:00:00 2001
|
||||
From: attend-dunce <96889312+attend-dunce@users.noreply.github.com>
|
||||
Date: Thu, 30 Dec 2021 21:35:14 +0100
|
||||
Subject: [PATCH 1/3] Fixed `getUser`
|
||||
|
||||
---
|
||||
lib/TikTok/Api.php | 16 +++++++---------
|
||||
1 file changed, 7 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/lib/TikTok/Api.php b/lib/TikTok/Api.php
|
||||
index e605eef..4a35f61 100644
|
||||
--- a/lib/TikTok/Api.php
|
||||
+++ b/lib/TikTok/Api.php
|
||||
@@ -385,16 +385,14 @@ if (!\class_exists('\Sovit\TikTok\Api')) {
|
||||
}
|
||||
}
|
||||
$username = urlencode($username);
|
||||
- $result = $this->remote_call("https://www.tiktok.com/@{$username}?lang=en", false);
|
||||
- if (preg_match('/<script id="__NEXT_DATA__"([^>]+)>([^<]+)<\/script>/', $result, $matches)) {
|
||||
- $result = json_decode($matches[2], false);
|
||||
- if (isset($result->props->pageProps->userInfo)) {
|
||||
- $result = $result->props->pageProps->userInfo;
|
||||
- if ($this->cacheEnabled) {
|
||||
- $this->cacheEngine->set($cacheKey, $result, $this->_config['cache-timeout']);
|
||||
- }
|
||||
- return $result;
|
||||
+ $result = $this->remote_call("https://www.tiktok.com/api/user/detail/?userId={$username}", false);
|
||||
+ $result = json_decode($result, false);
|
||||
+ if (isset($result->userInfo)) {
|
||||
+ $result = $result->userInfo;
|
||||
+ if ($this->cacheEnabled) {
|
||||
+ $this->cacheEngine->set($cacheKey, $result, $this->_config['cache-timeout']);
|
||||
}
|
||||
+ return $result;
|
||||
}
|
||||
return $this->failure();
|
||||
}
|
||||
--
|
||||
2.34.1
|
||||
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
From c948bda5d6f30929b448fe78a0920739d5792d4b Mon Sep 17 00:00:00 2001
|
||||
From: attend-dunce <96889312+attend-dunce@users.noreply.github.com>
|
||||
Date: Fri, 31 Dec 2021 00:55:23 +0100
|
||||
Subject: [PATCH 2/3] Added support for username as well as user id
|
||||
|
||||
---
|
||||
lib/TikTok/Api.php | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/lib/TikTok/Api.php b/lib/TikTok/Api.php
|
||||
index 4a35f61..8fd42ae 100644
|
||||
--- a/lib/TikTok/Api.php
|
||||
+++ b/lib/TikTok/Api.php
|
||||
@@ -385,7 +385,8 @@ if (!\class_exists('\Sovit\TikTok\Api')) {
|
||||
}
|
||||
}
|
||||
$username = urlencode($username);
|
||||
- $result = $this->remote_call("https://www.tiktok.com/api/user/detail/?userId={$username}", false);
|
||||
+ $param = is_numeric($username) ? "userId" : "uniqueId";
|
||||
+ $result = $this->remote_call("https://www.tiktok.com/api/user/detail/?{$param}={$username}", false);
|
||||
$result = json_decode($result, false);
|
||||
if (isset($result->userInfo)) {
|
||||
$result = $result->userInfo;
|
||||
--
|
||||
2.34.1
|
||||
|
||||
50
patches/0003-Fixed-getVideoByUrl.patch
Normal file
50
patches/0003-Fixed-getVideoByUrl.patch
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
From c23e8dbf0bd722799cf19182142d4b177f8fd933 Mon Sep 17 00:00:00 2001
|
||||
From: Pablo Ferreiro <pferreiromero@gmail.com>
|
||||
Date: Sat, 8 Jan 2022 15:47:21 +0100
|
||||
Subject: [PATCH 3/3] Fixed getVideoByUrl
|
||||
|
||||
---
|
||||
lib/TikTok/Api.php | 19 +++++++++++++------
|
||||
1 file changed, 13 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/lib/TikTok/Api.php b/lib/TikTok/Api.php
|
||||
index 8fd42ae..f800555 100644
|
||||
--- a/lib/TikTok/Api.php
|
||||
+++ b/lib/TikTok/Api.php
|
||||
@@ -483,20 +483,27 @@ if (!\class_exists('\Sovit\TikTok\Api')) {
|
||||
throw new \Exception("Invalid VIDEO URL");
|
||||
}
|
||||
$result = $this->remote_call($url, false);
|
||||
- $result = Helper::string_between($result, '{"props":{"initialProps":{', "</script>");
|
||||
+ $result = Helper::string_between($result, "window['SIGI_STATE']=", ";window['SIGI_RETRY']=");
|
||||
if (!empty($result)) {
|
||||
- $jsonData = json_decode('{"props":{"initialProps":{' . $result);
|
||||
- if (isset($jsonData->props->pageProps->itemInfo->itemStruct)) {
|
||||
+ $jsonData = json_decode($result);
|
||||
+ if (isset($jsonData->ItemModule, $jsonData->ItemList, $jsonData->UserModule)) {
|
||||
+ $id = $jsonData->ItemList->video->keyword;
|
||||
+ $item = $jsonData->ItemModule->{$id};
|
||||
+ $username = $item->author;
|
||||
$result = (object) [
|
||||
'statusCode' => 0,
|
||||
'info' => (object) [
|
||||
'type' => 'video',
|
||||
- 'detail' => $url,
|
||||
+ 'detail' => (object) [
|
||||
+ "url" => $url,
|
||||
+ "user" => $jsonData->UserModule->users->{$username},
|
||||
+ "stats" => $item->stats
|
||||
+ ],
|
||||
],
|
||||
- "items" => [$jsonData->props->pageProps->itemInfo->itemStruct],
|
||||
+ "items" => [$item],
|
||||
"hasMore" => false,
|
||||
"minCursor" => '0',
|
||||
- "maxCursor" => ' 0',
|
||||
+ "maxCursor" => '0'
|
||||
];
|
||||
if ($this->cacheEnabled) {
|
||||
$this->cacheEngine->set($cacheKey, $result, $this->_config['cache-timeout']);
|
||||
--
|
||||
2.34.1
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue