From 272b716f35bfec7e415b77ad4dab55966d55d703 Mon Sep 17 00:00:00 2001
From: xiaomlove <353856593@qq.com>
Date: Thu, 3 Jun 2021 11:47:56 +0800
Subject: [PATCH] improve technical info display
---
nexus/Torrent/TechnicalInformation.php | 50 ++++++++++----------------
1 file changed, 19 insertions(+), 31 deletions(-)
diff --git a/nexus/Torrent/TechnicalInformation.php b/nexus/Torrent/TechnicalInformation.php
index 688a30b9..0f6a11b7 100644
--- a/nexus/Torrent/TechnicalInformation.php
+++ b/nexus/Torrent/TechnicalInformation.php
@@ -149,47 +149,35 @@ class TechnicalInformation
$videos = array_filter($videos);
$audios = $this->getAudios();
$subtitles = $this->getSubtitles();
- //video part
- $videoTable = '
';
- foreach (array_chunk($videos, 2, true) as $row) {
- $videoTable .= '';
- foreach ($row as $key => $value) {
- $videoTable .= sprintf('| %s: %s | ', $key, $value);
- }
- $videoTable .= '
';
- }
- $videoTable .= '
';
-
- $audioTable = '';
- $audioTable .= '';
- foreach ($audios as $key => $value) {
- $audioTable .= sprintf('| %s: %s | ', $key, $value);
- }
- $audioTable .= '
';
- $audioTable .= '
';
-
- $subtitleTable = '';
- $subtitleTable .= '';
- foreach ($subtitles as $key => $value) {
- $subtitleTable .= sprintf('| %s: %s | ', $key, $value);
- }
- $subtitleTable .= '
';
- $subtitleTable .= '
';
-
+// dd($videos, $audios, $subtitles);
if (empty($videos) && empty($audios) && empty($subtitles)) {
return '';
}
- $result = '';
+
+ $result = '';
if (!empty($videos)) {
- $result .= sprintf('| %s | ', $videoTable);
+ $result .= $this->buildTdTable($videos);
}
if (!empty($audios)) {
- $result .= sprintf('%s | ', $audioTable);
+ $result .= $this->buildTdTable($audios);
}
if (!empty($subtitles)) {
- $result .= sprintf('%s | ', $subtitleTable);
+ $result .= $this->buildTdTable($subtitles);
}
$result .= '
';
return $result;
}
+
+ private function buildTdTable(array $parts)
+ {
+ $table = '';
+ foreach ($parts as $key => $value) {
+ $table .= '';
+ $table .= sprintf('| %s: %s | ', $key, $value);
+ $table .= '
';
+ }
+ $table .= '
';
+ return sprintf('%s | ', $table);
+ }
+
}