mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-23 19:50:40 -05:00
update: torrent api
- add keywords support
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
|
||||
namespace App\Http\Controllers\API;
|
||||
|
||||
use App\Models\Keyword;
|
||||
use App\Helpers\Bencode;
|
||||
use App\Helpers\MediaInfo;
|
||||
use App\Helpers\TorrentHelper;
|
||||
@@ -208,6 +209,15 @@ class TorrentController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
// Torrent Keywords System
|
||||
$keywords = self::parseKeywords($request->input('keywords'));
|
||||
foreach ($keywords as $keyword) {
|
||||
$tag = new Keyword();
|
||||
$tag->name = $keyword;
|
||||
$tag->torrent_id = $torrent->id;
|
||||
$tag->save();
|
||||
}
|
||||
|
||||
// check for trusted user and update torrent
|
||||
if ($user->group->is_trusted) {
|
||||
$appurl = \config('app.url');
|
||||
@@ -510,4 +520,25 @@ class TorrentController extends BaseController
|
||||
|
||||
return $mediainfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse Torrent Keywords.
|
||||
*
|
||||
* @param $text
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private static function parseKeywords($text)
|
||||
{
|
||||
$parts = explode(', ', $text);
|
||||
$result = [];
|
||||
foreach ($parts as $part) {
|
||||
$part = trim($part);
|
||||
if ($part != '') {
|
||||
$result[] = $part;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user