Skip to content

Commit

Permalink
get video feed from cache and better attribute check
Browse files Browse the repository at this point in the history
  • Loading branch information
pablouser1 committed Aug 20, 2024
1 parent b13a1a0 commit c8540e5
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 16 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6.0.2
2.6.0.3
9 changes: 7 additions & 2 deletions src/Items/Hashtag.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ public function info(): self {

$info = Info::fromReq($req);
if ($info->meta->success && isset($req->jsonBody->challengeInfo)) {
$info->setDetail($req->jsonBody->challengeInfo->challenge);
$info->setStats($req->jsonBody->challengeInfo->stats);
if (isset($req->jsonBody->challengeInfo->challenge)) {
$info->setDetail($req->jsonBody->challengeInfo->challenge);
}

if (isset($req->jsonBody->challengeInfo->stats)) {
$info->setStats($req->jsonBody->challengeInfo->stats);
}
}

$this->info = $info;
Expand Down
9 changes: 7 additions & 2 deletions src/Items/Music.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ public function info(): self {

$info = Info::fromReq($req);
if ($info->meta->success && isset($req->jsonBody->musicInfo)) {
$info->setDetail($req->jsonBody->musicInfo->music);
$info->setStats($req->jsonBody->musicInfo->stats);
if (isset($req->jsonBody->musicInfo->music)) {
$info->setDetail($req->jsonBody->musicInfo->music);
}

if (isset($req->jsonBody->musicInfo->stats)) {
$info->setStats($req->jsonBody->musicInfo->stats);
}
}

$this->info = $info;
Expand Down
14 changes: 11 additions & 3 deletions src/Items/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,17 @@ public function info(): self {

$info = Info::fromReq($req);
if ($info->meta->success) {
if (isset($req->jsonBody->userInfo)) {
$info->setDetail($req->jsonBody->userInfo->user);
$info->setStats($req->jsonBody->userInfo->stats);
if (isset($req->jsonBody->userInfo, $req->jsonBody->userInfo->user)) {
// userInfo is available
if (isset($req->jsonBody->userInfo->user)) {
// Set details
$info->setDetail($req->jsonBody->userInfo->user);
}

if (isset($req->jsonBody->userInfo->stats)) {
// Set stats
$info->setStats($req->jsonBody->userInfo->stats);
}
}
}
$this->info = $info;
Expand Down
18 changes: 10 additions & 8 deletions src/Items/Video.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
namespace TikScraper\Items;

use TikScraper\Cache;
use TikScraper\Constants\Responses;
use TikScraper\Models\Feed;
use TikScraper\Models\Info;
use TikScraper\Sender;
Expand Down Expand Up @@ -47,13 +46,16 @@ public function info(): self {

public function feed(): self {
$this->cursor = 0;
if ($this->item !== null) {
$this->feed = Feed::fromCache((object) [
"items" => [$this->item],
"hasMore" => false,
"minCursor" => 0,
"maxCursor" => ""
]);
if ($this->infoOk()) {
$preloaded = $this->handleFeedCache();
if (!$preloaded && $this->item !== null) {
$this->feed = Feed::fromCache((object) [
"items" => [$this->item],
"hasMore" => false,
"minCursor" => 0,
"maxCursor" => ""
]);
}
}
return $this;
}
Expand Down

0 comments on commit c8540e5

Please sign in to comment.