astrXbian/www/boris/swarm_files.php

71 lines
1.4 KiB
PHP

<?php
require_once('conf.php');
require_once('functions.php');
$dir = scandir("swarm", SCANDIR_SORT_DESCENDING) or die('fail');
array_pop($dir); // .
array_pop($dir); // ..
$swarm = array();
foreach ($dir as $d) {
$fst = substr($d, 0, 1);
if ($fst == '.') {
$swarm[] = $d;
}
}
foreach ($swarm as $peer) {
$peerName = file_get_contents('swarm/' . $peer . '/G1SSB/_g1.astroport_title');
echo '<h2>'. $peerName . ' ['. substr($peer, 0, 5) . '…' . substr($peer, -4) . ']</h2>';
$files = scandir('swarm/' . $peer . '/astroport/kodi/vstream');
foreach ($files as $f) {
echo '<h3>' . getCollectionType($f) . '</h3>';
$collection = file_get_contents('swarm/' . $peer . '/astroport/kodi/vstream/' . $f);
$collection = trim($collection);
$videos = explode("\n", $collection);
$videos = array_reverse($videos);
array_pop($videos);
echo '<ul>';
foreach ($videos as $v) {
list($a, $b, $c, $videoName, $e, $g, $h, $m, $videoURI) = explode(";", $v);
$videoURL = 'https://'. HOST. $videoURI;
$mimeType = guessTypeFromFilename($videoURL);
if ($mimeType == 'video/mp4') {
echo '<li>';
echo '
<a href="'. $videoURL . '">' . $videoName . '</a><br />
('. $mimeType . ')<br />
<video controls width="320" height="240" preload="none">
<source src="'. $videoURL .'" type="'. $mimeType .'">
<a href="'. $videoURL . '">' . $videoName . '</a>
</video>';
echo '</li>';
}
}
}
}