Improved TorrServer integration (#1624)

* Improved TorrServer integration

* Updated

* Update showm3u.php

* Update showm3u.tpl

* Updated

* Update showm3u.php

* Updated

* Updated

* Updated

* Update showm3u.php

* Update showm3u.tpl

* Update main.php

* Updated

* Update show_m3u.php

* Update

* Update show_m3u.tpl

* Update show_m3u.tpl

* Updated

* Updated

* Update displaying_torrent.php

* Update show_m3u.php

* Updated

* Updated

* Update show_m3u.tpl

* Updated

* Update show_m3u.php

* Updated

* Update show_m3u.php

* Update show_m3u.php

* Update show_m3u.php

* Updated

* Updated

* Update show_m3u.tpl

* Updated

* Update show_m3u.tpl

* Update main.php

* Updated

* Updated

* Updated

* Update playback_m3u.php

* Update playback_m3u.tpl

* Update playback_m3u.tpl

* Update CHANGELOG.md
This commit is contained in:
Roman Kelesidis 2024-08-29 21:51:30 +07:00 committed by GitHub
commit c3d6d62a82
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 214 additions and 22 deletions

View file

@ -9,7 +9,7 @@
- [CLI] TorrentPier installer ☕️ [\#1576](https://github.com/torrentpier/torrentpier/pull/1576), [\#1582](https://github.com/torrentpier/torrentpier/pull/1582), [\#1585](https://github.com/torrentpier/torrentpier/pull/1585), [\#1591](https://github.com/torrentpier/torrentpier/pull/1591) ([belomaxorka](https://github.com/belomaxorka))
- Added some new HTML meta-tags [\#1562](https://github.com/torrentpier/torrentpier/pull/1562) ([belomaxorka](https://github.com/belomaxorka))
- Added robots meta-tag support 🤖 [\#1587](https://github.com/torrentpier/torrentpier/pull/1587) ([belomaxorka](https://github.com/belomaxorka))
- Added [TorrServer](https://github.com/YouROK/TorrServer) instance support! 🎞 [\#1603](https://github.com/torrentpier/torrentpier/pull/1603), [\#1623](https://github.com/torrentpier/torrentpier/pull/1623) ([belomaxorka](https://github.com/belomaxorka))
- Added [TorrServer](https://github.com/YouROK/TorrServer) instance support! 🎞 [\#1603](https://github.com/torrentpier/torrentpier/pull/1603), [\#1623](https://github.com/torrentpier/torrentpier/pull/1623), [\#1624](https://github.com/torrentpier/torrentpier/pull/1624) ([belomaxorka](https://github.com/belomaxorka))
- Newtopic: Added configuring robots indexing [\#1599](https://github.com/torrentpier/torrentpier/pull/1599) ([belomaxorka](https://github.com/belomaxorka))
- Added showing releaser stats in profile [\#1568](https://github.com/torrentpier/torrentpier/pull/1568) ([belomaxorka](https://github.com/belomaxorka))
- Improved `filelist.php` [\#1586](https://github.com/torrentpier/torrentpier/pull/1586) ([belomaxorka](https://github.com/belomaxorka))

View file

@ -59,6 +59,7 @@
"google/recaptcha": "^1.3",
"jacklul/monolog-telegram": "^3.1",
"josantonius/cookie": "^2.0",
"gemorroj/m3u-parser": "dev-master",
"php-curl-class/php-curl-class": "^11.0.0",
"league/flysystem": "^3.28",
"longman/ip-tools": "1.2.1",

82
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "26d2ba6114d7c2482dcf968c0530d259",
"content-hash": "67c39c20b9970112162ecb7f43172f9c",
"packages": [
{
"name": "arokettu/bencode",
@ -78,20 +78,20 @@
},
{
"name": "arokettu/is-resource",
"version": "1.0.3",
"version": "1.0.4",
"source": {
"type": "git",
"url": "https://github.com/arokettu/is-resource.git",
"reference": "1143639fb55e1430b518acda273c84c9fa98ff7b"
"reference": "6a4966bf4608c69d20b7bf01670b49901a51eb9d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/arokettu/is-resource/zipball/1143639fb55e1430b518acda273c84c9fa98ff7b",
"reference": "1143639fb55e1430b518acda273c84c9fa98ff7b",
"url": "https://api.github.com/repos/arokettu/is-resource/zipball/6a4966bf4608c69d20b7bf01670b49901a51eb9d",
"reference": "6a4966bf4608c69d20b7bf01670b49901a51eb9d",
"shasum": ""
},
"require": {
"php": ">= 5.3 < 8.4"
"php": ">= 5.3 < 8.5"
},
"type": "library",
"autoload": {
@ -114,7 +114,7 @@
"role": "developer"
}
],
"description": "Future compatible is_resource() and get_resource_type() that can understand opaque objects",
"description": "Future compatible is_resource() and get_resource_type() that can understand objects that replaced earlier resources",
"homepage": "https://sandfox.dev/php/is-resource.html",
"keywords": [
"compatibility",
@ -130,11 +130,12 @@
"sockets"
],
"support": {
"chat": "https://gitter.im/arokettu/community",
"docs": "https://is-resource.readthedocs.io/",
"issues": "https://gitlab.com/sandfox/is-resource/-/issues",
"source": "https://gitlab.com/sandfox/is-resource"
},
"time": "2023-08-28T12:32:54+00:00"
"time": "2024-08-27T04:34:45+00:00"
},
{
"name": "arokettu/monsterid",
@ -805,6 +806,56 @@
],
"time": "2023-11-03T12:00:00+00:00"
},
{
"name": "gemorroj/m3u-parser",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/Gemorroj/M3uParser.git",
"reference": "fcb37acd137a6e1d6aa2ef3745e1bc7a6e0b46e6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Gemorroj/M3uParser/zipball/fcb37acd137a6e1d6aa2ef3745e1bc7a6e0b46e6",
"reference": "fcb37acd137a6e1d6aa2ef3745e1bc7a6e0b46e6",
"shasum": ""
},
"require": {
"php": ">=8.0.2"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.46",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^9.6"
},
"default-branch": true,
"type": "library",
"autoload": {
"psr-4": {
"M3uParser\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0-or-later"
],
"authors": [
{
"name": "Gemorroj"
}
],
"description": "m3u playlist parser/generator",
"keywords": [
"m3u",
"m3u8",
"playlist"
],
"support": {
"issues": "https://github.com/Gemorroj/M3uParser/issues",
"source": "https://github.com/Gemorroj/M3uParser/tree/master"
},
"time": "2024-07-27T11:53:30+00:00"
},
{
"name": "gigablah/sphinxphp",
"version": "2.0.8",
@ -2534,16 +2585,16 @@
},
{
"name": "psr/log",
"version": "3.0.0",
"version": "3.0.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001"
"reference": "79dff0b268932c640297f5208d6298f71855c03e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001",
"reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001",
"url": "https://api.github.com/repos/php-fig/log/zipball/79dff0b268932c640297f5208d6298f71855c03e",
"reference": "79dff0b268932c640297f5208d6298f71855c03e",
"shasum": ""
},
"require": {
@ -2578,9 +2629,9 @@
"psr-3"
],
"support": {
"source": "https://github.com/php-fig/log/tree/3.0.0"
"source": "https://github.com/php-fig/log/tree/3.0.1"
},
"time": "2021-07-14T16:46:02+00:00"
"time": "2024-08-21T13:31:24+00:00"
},
{
"name": "psr/simple-cache",
@ -4141,7 +4192,8 @@
"aliases": [],
"minimum-stability": "dev",
"stability-flags": {
"arokettu/monsterid": 20
"arokettu/monsterid": 20,
"gemorroj/m3u-parser": 20
},
"prefer-stable": true,
"prefer-lowest": false,

View file

@ -224,9 +224,9 @@ if ($tor_reged && $tor_info) {
]);
// TorrServer integration
if ($bb_cfg['torr_server']['enabled'] && $m3u_file = (new \TorrentPier\TorrServerAPI())->getM3UPath($attach_id)) {
if ($bb_cfg['torr_server']['enabled'] && (!IS_GUEST || !$bb_cfg['torr_server']['disable_for_guest']) && (new \TorrentPier\TorrServerAPI())->getM3UPath($attach_id)) {
$template->assign_block_vars('postrow.attach.tor_reged.tor_server', [
'TORR_SERVER_M3U_LINK' => $m3u_file,
'TORR_SERVER_M3U_LINK' => PLAYBACK_M3U_URL . $attach_id,
'TORR_SERVER_M3U_ICON' => $images['icon_tor_m3u_icon'],
]);
}

View file

@ -114,7 +114,8 @@ $bb_cfg['torr_server'] = [
// Read more: https://github.com/YouROK/TorrServer
'enabled' => false,
'url' => "http://$domain_name:8090",
'timeout' => 5
'timeout' => 5,
'disable_for_guest' => true
];
// Ocelot

View file

@ -302,6 +302,7 @@ define('PROFILE_URL', 'profile.php?mode=viewprofile&amp;' . POST_USERS_URL . '='
define('BONUS_URL', 'profile.php?mode=bonus');
define('TOPIC_URL', 'viewtopic.php?' . POST_TOPIC_URL . '=');
define('FILELIST_URL', 'filelist.php?' . POST_TOPIC_URL . '=');
define('PLAYBACK_M3U_URL', 'playback_m3u.php?attach_id=');
define('USER_AGENT', strtolower($_SERVER['HTTP_USER_AGENT']));

View file

@ -63,6 +63,7 @@ $lang['SELECT_ACTION'] = 'Select action';
$lang['CLEAR'] = 'Clear';
$lang['MOVE_TO_TOP'] = 'Move to top';
$lang['UNKNOWN'] = 'Unknown';
$lang['COPY_TO_CLIPBOARD'] = 'Copy to clipboard';
$lang['NEXT_PAGE'] = 'Next';
$lang['PREVIOUS_PAGE'] = 'Previous';
@ -1268,6 +1269,10 @@ $lang['FILESIZE'] = 'Filesize';
$lang['VIEWED'] = 'Viewed';
$lang['EXTENSION_DISABLED_AFTER_POSTING'] = 'The Extension \'%s\' was deactivated by an board admin, therefore this Attachment is not displayed.'; // used in Posts and PM's, replace %s with mime type
$lang['DOWNLOAD_M3U_FILE'] = 'Download .m3u file';
$lang['PLAYBACK_M3U'] = 'Playback .m3u file';
$lang['STREAM'] = 'Stream';
$lang['COPY_STREAM_LINK'] = 'Copy stream link to clipboard';
$lang['M3U_NOTICE'] = 'Some browsers do not support playback of certain video formats. In such a case, you can download the .m3u file and play it using a third-party player';
$lang['ATTACHMENT'] = 'Attachments';
$lang['ATTACHMENT_THUMBNAIL'] = 'Attachment Thumbnail';

89
playback_m3u.php Normal file
View file

@ -0,0 +1,89 @@
<?php
/**
* TorrentPier Bull-powered BitTorrent tracker engine
*
* @copyright Copyright (c) 2005-2024 TorrentPier (https://torrentpier.com)
* @link https://github.com/torrentpier/torrentpier for the canonical source repository
* @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License
*/
define('BB_SCRIPT', 'playback_m3u');
require __DIR__ . '/common.php';
if (!$bb_cfg['torr_server']['enabled']) {
redirect('index.php');
}
// Valid file formats
$validFormats = [
'audio' => ['mp3', 'flac', 'wav'],
'video' => ['mp4', 'mkv', 'avi']
];
// Start session management
$user->session_start(['req_login' => $bb_cfg['torr_server']['disable_for_guest']]);
// Disable robots indexing
$page_cfg['allow_robots'] = false;
// Check attach_id
if (!$attach_id = request_var('attach_id', 0)) {
bb_die($lang['INVALID_ATTACH_ID']);
}
// Check m3u file exist
if (!$m3uFile = (new \TorrentPier\TorrServerAPI())->getM3UPath($attach_id)) {
bb_die($lang['ERROR_NO_ATTACHMENT']);
}
// Parse M3U file
$m3uParser = new M3uParser\M3uParser();
$m3uParser->addDefaultTags();
$m3uData = $m3uParser->parseFile($m3uFile);
$filesCount = 0;
foreach ($m3uData as $entry) {
$filesCount++;
$rowClass = ($filesCount % 2) ? 'row1' : 'row2';
// Validate URL
$streamLink = $entry->getPath();
if (!filter_var($streamLink, FILTER_VALIDATE_URL)) {
continue;
}
// Parse tags
foreach ($entry->getExtTags() as $extTag) {
// #EXTINF tag
if ($extTag == $extTag instanceof \M3uParser\Tag\ExtInf) {
$title = $extTag->getTitle();
}
}
// Validate title
if (!isset($title)) {
continue;
}
// Validate file extension
$getExtension = pathinfo($title, PATHINFO_EXTENSION);
$template->assign_block_vars('m3ulist', [
'ROW_NUMBER' => $filesCount,
'ROW_CLASS' => $rowClass,
'IS_VALID' => in_array($getExtension, array_merge($validFormats['audio'], $validFormats['video'])),
'IS_AUDIO' => in_array($getExtension, $validFormats['audio']),
'STREAM_LINK' => $streamLink,
'M3U_DL_LINK' => $m3uFile,
'TITLE' => $title,
]);
}
// Generate output
$template->assign_vars([
'PAGE_TITLE' => $lang['PLAYBACK_M3U'],
'FILES_COUNT' => sprintf($lang['BT_FLIST_FILE_PATH'], declension($filesCount, 'files')),
]);
print_page('playback_m3u.tpl');

View file

@ -0,0 +1,43 @@
<h1 class="pagetitle">{PAGE_TITLE}</h1>
<table class="forumline">
<thead>
<tr>
<th>#</th>
<th>{FILES_COUNT}</th>
<th>{L_STREAM}</th>
</tr>
</thead>
<!-- BEGIN m3ulist -->
<tbody>
<tr class="{m3ulist.ROW_CLASS} tCenter">
<td>{m3ulist.ROW_NUMBER}</td>
<td width="40%">{m3ulist.TITLE}</td>
<td>
<a href="#" onclick="return false;" class="copyElement" data-clipboard-text="{m3ulist.STREAM_LINK}">{L_COPY_STREAM_LINK}</a>&nbsp;&middot;
<a target="_blank" href="{m3ulist.M3U_DL_LINK}">{L_DOWNLOAD_M3U_FILE}</a>
<!-- IF m3ulist.IS_VALID --><hr><!-- IF m3ulist.IS_AUDIO -->
<audio preload="none" src="{m3ulist.STREAM_LINK}" controls></audio>
<!-- ELSE -->
<video preload="none" width="500" height="auto" src="{m3ulist.STREAM_LINK}" controls></video>
<!-- ENDIF --><!-- ENDIF -->
</td>
</tr>
</tbody>
<!-- END m3ulist -->
<tfoot>
<tr>
<td class="catBottom warnColor1" colspan="4">{L_M3U_NOTICE}</td>
</tr>
</tfoot>
</table>
<!--bottom_info-->
<div class="bottom_info">
<div class="spacer_8"></div>
<div id="timezone">
<p>{CURRENT_TIME}</p>
<p>{S_TIMEZONE}</p>
</div>
<div class="clear"></div>
</div><!--/bottom_info-->

View file

@ -160,8 +160,8 @@
{postrow.attach.tor_reged.TRACKER_LINK}
[ <span title="{postrow.attach.tor_reged.REGED_DELTA}">{postrow.attach.tor_reged.REGED_TIME}</span> ]
<!-- IF not postrow.attach.tor_reged.TOR_FROZEN -->
<br><!-- IF postrow.attach.tor_reged.HASH --><br>info_hash: <span class="copyElement" data-clipboard-text="{postrow.attach.tor_reged.HASH}" title="Copy to clipboard">{postrow.attach.tor_reged.HASH}</span><!-- ENDIF -->
<!-- IF postrow.attach.tor_reged.HASH_V2 --><br>info_hash v2: <span class="copyElement" data-clipboard-text="{postrow.attach.tor_reged.HASH_V2}" title="Copy to clipboard">{postrow.attach.tor_reged.HASH_V2}</span><!-- ENDIF -->
<br><!-- IF postrow.attach.tor_reged.HASH --><br>info_hash: <span class="copyElement" data-clipboard-text="{postrow.attach.tor_reged.HASH}" title="{L_COPY_TO_CLIPBOARD}">{postrow.attach.tor_reged.HASH}</span><!-- ENDIF -->
<!-- IF postrow.attach.tor_reged.HASH_V2 --><br>info_hash v2: <span class="copyElement" data-clipboard-text="{postrow.attach.tor_reged.HASH_V2}" title="{L_COPY_TO_CLIPBOARD}">{postrow.attach.tor_reged.HASH_V2}</span><!-- ENDIF -->
<!-- ENDIF -->
</td>
<td width="15%" rowspan="4" class="tCenter pad_6">
@ -176,7 +176,7 @@
<!-- BEGIN tor_server -->
<!-- IF postrow.attach.tor_reged.tor_server.TORR_SERVER_M3U_LINK -->
<hr>
<a href="{postrow.attach.tor_reged.tor_server.TORR_SERVER_M3U_LINK}" target="_blank"><p><img alt="{L_DOWNLOAD_M3U_FILE}" src="{postrow.attach.tor_reged.tor_server.TORR_SERVER_M3U_ICON}" width="21" height="21" border="0"></p>{L_DOWNLOAD_M3U_FILE}</a>
<a href="{postrow.attach.tor_reged.tor_server.TORR_SERVER_M3U_LINK}" target="_blank"><p><img alt="{L_PLAYBACK_M3U}" src="{postrow.attach.tor_reged.tor_server.TORR_SERVER_M3U_ICON}" width="21" height="21" border="0"></p>{L_PLAYBACK_M3U}</a>
<!-- ENDIF -->
<!-- END tor_server -->
</td>