Compare commits

...

6 Commits

Author SHA1 Message Date
Pablo Ferreiro 574ae51582 bump 2022-08-11 23:34:16 +02:00
Pablo Ferreiro 90a2d2ec28 Updated TikScrapper 2022-08-11 23:33:16 +02:00
Pablo Ferreiro 3880da35ea Merge pull request #63 from chrisnovakovic/tiktok-url
Accept TikTok URLs as search terms
2022-08-04 14:04:04 +02:00
Chris Novakovic 8d8fe43431 Add type declarations, fix function reference 2022-07-31 17:20:38 +01:00
Chris Novakovic e7ee03e3cc Accept TikTok URLs as search terms
On the home page, allow TikTok URLs to be entered as search terms for
the new category "TikTok URL", and redirect to a ProxiTok-compatible
URL when a valid one is entered.

Closes #58.
2022-07-27 00:49:14 +01:00
Pablo Ferreiro d0057e77e3 Fixing error message 2022-07-03 18:35:30 +02:00
7 changed files with 56 additions and 19 deletions
+1
View File
@@ -37,6 +37,7 @@ Apply to: Main window (address bar)
* Fix embed styling
* Fix crash when invalid vm.tiktok.com/CODE or www.tiktok.com/t/CODE is provided
* Add custom amount of videos per page
* Discover does not work
## Credits
[@TheFrenchGhosty](https://github.com/TheFrenchGhosty): Initial Dockerfile and fixes to a usable state. You can check his Docker image [here](https://github.com/PussTheCat-org/docker-proxitok-quay) on Github or [here](https://quay.io/repository/pussthecatorg/proxitok) on Quay
+37
View File
@@ -1,5 +1,6 @@
<?php
namespace App\Controllers;
use App\Helpers\ErrorHandler;
use App\Helpers\Misc;
/**
@@ -11,6 +12,13 @@ class RedirectController {
if (isset($_GET['type'], $_GET['term'])) {
$term = trim($_GET['term']);
switch ($_GET['type']) {
case 'url':
$endpoint = self::to_endpoint($term);
if (!$endpoint) {
echo 'Invalid or unknown TikTok URL format';
return;
}
break;
case 'user':
// Remove @ if sent
if ($term[0] === '@') {
@@ -39,4 +47,33 @@ class RedirectController {
$url = Misc::url($endpoint);
header("Location: {$url}");
}
/**
* to_endpoint maps a TikTok URL into a ProxiTok-compatible endpoint URL.
*/
static private function to_endpoint(string $url): string {
if (preg_match('%^https://vm\.tiktok\.com/([A-Za-z0-9]+)%', $url, $m)) {
// Short video URL
return '/@placeholder/video/' . $m[1];
} elseif (preg_match('%^https://www\.tiktok\.com/(.+)%', $url, $m)) {
// Username component (which may indicate a user profile URL or a video URL)
if (preg_match('%^(@[A-Za-z0-9_.]+)(?:/|$)(.*)%', $m[1], $u)) {
if ($u[2] == '') {
// User profile URL
return '/' . $u[1];
} elseif (preg_match('%^video/(\d+)%', $u[2], $v)) {
// Video URL
return '/' . $u[1] . '/video/' . $v[1];
}
} elseif (preg_match('%^tag/([^ ]+?)(?:/|$)%', $m[1], $t)) {
// Tag URL
return '/tag/' . $t[1];
} elseif (preg_match('%^music/([^ ]+?)(?:/|$)%', $m[1], $m)) {
// Music URL
return '/music/' . $m[1];
}
}
return '';
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "pablouser1/proxitok",
"description": "An alternative frontend for TikTok",
"version": "2.3.2.1",
"version": "2.3.2.2",
"license": "AGPL-3.0-or-later",
"type": "project",
"authors": [
Generated
+12 -12
View File
@@ -263,16 +263,16 @@
},
{
"name": "pablouser1/tikscraper",
"version": "v2.1.1.0",
"version": "v2.1.2.0",
"source": {
"type": "git",
"url": "https://github.com/pablouser1/TikScraperPHP.git",
"reference": "4aa97bbcb54f1d1677830acd2fae5b6c8f22c699"
"reference": "96326226e54de2d1feedcc708200ba023a0553e5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pablouser1/TikScraperPHP/zipball/4aa97bbcb54f1d1677830acd2fae5b6c8f22c699",
"reference": "4aa97bbcb54f1d1677830acd2fae5b6c8f22c699",
"url": "https://api.github.com/repos/pablouser1/TikScraperPHP/zipball/96326226e54de2d1feedcc708200ba023a0553e5",
"reference": "96326226e54de2d1feedcc708200ba023a0553e5",
"shasum": ""
},
"require": {
@@ -304,9 +304,9 @@
"description": "Get data from TikTok API",
"support": {
"issues": "https://github.com/pablouser1/TikScraperPHP/issues",
"source": "https://github.com/pablouser1/TikScraperPHP/tree/v2.1.1.0"
"source": "https://github.com/pablouser1/TikScraperPHP/tree/v2.1.2.0"
},
"time": "2022-07-03T16:07:00+00:00"
"time": "2022-08-11T21:32:02+00:00"
},
{
"name": "php-webdriver/webdriver",
@@ -571,16 +571,16 @@
},
{
"name": "symfony/process",
"version": "v5.4.8",
"version": "v5.4.11",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "597f3fff8e3e91836bb0bd38f5718b56ddbde2f3"
"reference": "6e75fe6874cbc7e4773d049616ab450eff537bf1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/597f3fff8e3e91836bb0bd38f5718b56ddbde2f3",
"reference": "597f3fff8e3e91836bb0bd38f5718b56ddbde2f3",
"url": "https://api.github.com/repos/symfony/process/zipball/6e75fe6874cbc7e4773d049616ab450eff537bf1",
"reference": "6e75fe6874cbc7e4773d049616ab450eff537bf1",
"shasum": ""
},
"require": {
@@ -613,7 +613,7 @@
"description": "Executes commands in sub-processes",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/process/tree/v5.4.8"
"source": "https://github.com/symfony/process/tree/v5.4.11"
},
"funding": [
{
@@ -629,7 +629,7 @@
"type": "tidelift"
}
],
"time": "2022-04-08T05:07:18+00:00"
"time": "2022-06-27T16:58:25+00:00"
}
],
"packages-dev": [],
+3 -5
View File
@@ -3,10 +3,8 @@
{block content}
<p class="title">There was an error processing your request!</p>
<p class="subtitle">HTTP Code: {$error->http_code}</p>
{if $error->tiktok_code}
<p class="subtitle">API error code {$error->tiktok_code} ({$error->tiktok_msg})</p>
{if $error->tiktok_code === 10000}
<a href="{path('/verify')}">What does this mean?</a>
{/if}
<p class="subtitle">API error code {$error->tiktok_code} ({$error->tiktok_msg})</p>
{if $error->tiktok_code === 10000 || $error->tiktok_code === -1}
<a href="{path('/verify')}">What does this mean?</a>
{/if}
{/block}
+1
View File
@@ -12,6 +12,7 @@
<div class="control">
<div class="select">
<select name="type">
<option value="url">TikTok URL</option>
<option value="user">Username</option>
<option value="tag">Tag</option>
<option value="music">Music ID</option>
+1 -1
View File
@@ -7,7 +7,7 @@
{block content}
<p>TL;DR You probably have to search for another instance or wait some hours (or even better, have your own self-hosted instance)</p>
<p>TikTok has some mecanisms in order to stop scraping on their latest api (/api/...):</p>
<p>TikTok has some mecanisms in order to stop scraping on their api:</p>
<hr />
<div class="block">
<p class="is-size-4">Rate limits</p>