diff --git a/include/functions.php b/include/functions.php index 5208bed4..551b6052 100644 --- a/include/functions.php +++ b/include/functions.php @@ -3021,7 +3021,7 @@ function get_torrent_bookmark_state($userid, $torrentid, $text = false) return $act; } -function torrenttable($res, $variant = "torrent") { +function torrenttable($rows, $variant = "torrent") { global $Cache; global $lang_functions; global $CURUSER, $waitsystem; @@ -3037,6 +3037,8 @@ function torrenttable($res, $variant = "torrent") { } elseif ($enableImdb) { $imdb = new Nexus\Imdb\Imdb(); } + $torrent = new Nexus\Torrent\Torrent(); + $torrentSeedingLeechingStatus = $torrent->listLeechingSeedingStatus($CURUSER['id'], array_column($rows, 'id')); if ($variant == "torrent"){ $last_browse = $CURUSER['last_browse']; @@ -3132,7 +3134,8 @@ $counter = 0; if ($smalldescription_main == 'no' || $CURUSER['showsmalldescr'] == 'no') $displaysmalldescr = false; else $displaysmalldescr = true; -while ($row = mysql_fetch_assoc($res)) +//while ($row = mysql_fetch_assoc($res)) +foreach ($rows as $row) { $id = $row["id"]; $sphighlight = get_torrent_bg_color($row['sp_state']); @@ -3234,6 +3237,9 @@ while ($row = mysql_fetch_assoc($res)) print($dissmall_descr == "" ? "" : "
".$tags.htmlspecialchars($dissmall_descr)); } else { print("
$tags"); + } + if (isset($torrentSeedingLeechingStatus[$row['id']])) { + print('
'); } print(""); if ($enablePtGen && !empty($row['pt_gen'])) { diff --git a/nexus/Database/DB.php b/nexus/Database/DB.php index cc128ce0..76514a67 100644 --- a/nexus/Database/DB.php +++ b/nexus/Database/DB.php @@ -187,4 +187,24 @@ class DB return mysql_fetch_assoc($res); } + public static function getAll($table, $whereStr, $fields = '*') + { + if ($fields != '*') { + if (is_array($fields)) { + $fields = implode(', ', $fields); + } + } + if (empty($fields)) { + do_log("args: " . json_encode(func_get_args())); + throw new DatabaseException("empty fields."); + } + $sql = "select $fields from $table where $whereStr"; + $res = sql_query($sql); + $result = []; + while ($row = mysql_fetch_assoc($res)) { + $result[] = $row; + } + return $result; + } + } \ No newline at end of file diff --git a/nexus/Torrent/TechnicalInformation.php b/nexus/Torrent/TechnicalInformation.php new file mode 100644 index 00000000..2d8353d1 --- /dev/null +++ b/nexus/Torrent/TechnicalInformation.php @@ -0,0 +1,152 @@ +mediaInfo = (string)$mediaInfo; + $this->mediaInfoArr = $this->getMediaInfoArr((string)$mediaInfo); + } + + public function getMediaInfoArr(string $mediaInfo) + { + $arr = preg_split('/[\r\n]+/', $mediaInfo); + $result = []; + $parentKey = ""; + foreach ($arr as $key => $value) { + $value = trim($value); + if (empty($value)) { + continue; + } + $rowKeyValue = explode(':', $value); + $rowKeyValue = array_filter(array_map('trim', $rowKeyValue)); + if (count($rowKeyValue) == 1) { + $parentKey = $rowKeyValue[0]; + } elseif (count($rowKeyValue) == 2) { + if (empty($parentKey)) { + continue; + } + $result[$parentKey][$rowKeyValue[0]] = $rowKeyValue[1]; + } + } + return $result; + + } + + public function getRuntime() + { + return $this->mediaInfoArr['General']['Duration'] ?? ''; + } + + public function getResolution() + { + $width = $this->mediaInfoArr['Video']['Width'] ?? ''; + $height = $this->mediaInfoArr['Video']['Height'] ?? ''; + $ratio = $this->mediaInfoArr['Video']['Display aspect ratio'] ?? ''; + $result = $width . 'x' . $height; + if ($ratio) { + $result .= "($ratio)"; + } + return $result; + } + + public function getBitrate() + { + $result = $this->mediaInfoArr['Video']['Bit rate'] ?? ''; + return $result; + } + + public function getFramerate() + { + $result = $this->mediaInfoArr['Video']['Frame rate'] ?? ''; + return $result; + } + + public function getProfile() + { + $result = $this->mediaInfoArr['Video']['Format profile'] ?? ''; + return $result; + } + + public function getRefFrame() + { + foreach ($this->mediaInfoArr['Video'] as $key => $value) { + if (strpos($key, 'Reference frames') !== false) { + return $value; + } + } + return ''; + } + + public function getAudios() + { + $result = []; + foreach ($this->mediaInfoArr as $parentKey => $values) { + if (strpos($parentKey, 'Audio') == false) { + continue; + } + $audioInfoArr = []; + if (!empty($values['Language'])) { + $audioInfoArr[] = $values['Language']; + } + if (!empty($values['Format'])) { + $audioInfoArr[] = $values['Format']; + } + if (!empty($values['Channel(s)'])) { + $audioInfoArr[] = $values['Channel(s)']; + } + if (!empty($values['Bit rate'])) { + $audioInfoArr[]= "@" . $values['Bit rate']; + } + if (!empty($audioInfoArr)) { + $result[$parentKey] = implode(" ", $audioInfoArr); + } + } + return $result; + } + + public function getSubtitles() + { + $result = []; + foreach ($this->mediaInfoArr as $parentKey => $values) { + if (strpos($parentKey, 'Text') == false) { + continue; + } + $audioInfoArr = []; + if (!empty($values['Language'])) { + $audioInfoArr[] = $values['Language']; + } + if (!empty($values['Format'])) { + $audioInfoArr[] = $values['Format']; + } + if (!empty($audioInfoArr)) { + $result[$parentKey] = implode(" ", $audioInfoArr); + } + } + return $result; + } + + public function renderOnDetailsPage() + { + global $lang_functions; + $runtime = $this->getRuntime(); + $resolution = $this->getResolution(); + $bitrate = $this->getBitrate(); + $profile = $this->getProfile(); + $framerate = $this->getFramerate(); + $refFrame = $this->getRefFrame(); + $audios = $this->getAudios(); + $subtitles = $this->getSubtitles(); + $html = ''; + if (!empty($runtime)) { + + } + + } +} \ No newline at end of file diff --git a/nexus/Torrent/Torrent.php b/nexus/Torrent/Torrent.php new file mode 100644 index 00000000..0652b7a1 --- /dev/null +++ b/nexus/Torrent/Torrent.php @@ -0,0 +1,51 @@ + $row['to_go'] == 0 ? 'yes' : 'no', + 'progress' => $progress, + 'active_status' => $activeStatus, + ]; + } + return $snatchedList; + } +} \ No newline at end of file diff --git a/public/torrents.php b/public/torrents.php index 25faf15b..6b8b3f70 100644 --- a/public/torrents.php +++ b/public/torrents.php @@ -1086,12 +1086,16 @@ elseif($inclbookmarked == 2) } if ($count) { + $rows = []; + while ($row = mysql_fetch_assoc($res)) { + $rows[] = $row; + } print($pagertop); if ($sectiontype == $browsecatmode) - torrenttable($res, "torrents"); + torrenttable($rows, "torrents"); elseif ($sectiontype == $specialcatmode) - torrenttable($res, "music"); - else torrenttable($res, "bookmarks"); + torrenttable($rows, "music"); + else torrenttable($rows, "bookmarks"); print($pagerbottom); } else {