megaplaylist

This commit is contained in:
root 2018-10-20 21:58:40 +00:00
parent 7a0f7ca332
commit de61d3abe9
23 changed files with 99 additions and 20 deletions

View File

@ -63,6 +63,8 @@ services:
- MAIN_PORT_5000_TCP=tcp://main:5000 - MAIN_PORT_5000_TCP=tcp://main:5000
links: links:
- main - main
volumes:
- ./state/liquidsoap/playlists:/playlists
labels: labels:
- traefik.enable=true - traefik.enable=true
- traefik.frontend.rule=Host:radio.dodsorf.as - traefik.frontend.rule=Host:radio.dodsorf.as

View File

@ -16,23 +16,3 @@ ffmpeg2wav:youtube-dl-x:https$(colon)//www.youtube.com/watch?v=R7IJC6nMons
ffmpeg2wav:youtube-dl-x:https$(colon)//www.youtube.com/watch?v=0nlJuwO0GDs ffmpeg2wav:youtube-dl-x:https$(colon)//www.youtube.com/watch?v=0nlJuwO0GDs
ffmpeg2wav:youtube-dl-x:https$(colon)//www.youtube.com/watch?v=KOrXKiSy8ZY ffmpeg2wav:youtube-dl-x:https$(colon)//www.youtube.com/watch?v=KOrXKiSy8ZY
ffmpeg2wav:youtube-dl-x:https$(colon)//www.youtube.com/watch?v=jDyZj4msaoE ffmpeg2wav:youtube-dl-x:https$(colon)//www.youtube.com/watch?v=jDyZj4msaoE

View File

@ -1,3 +1,4 @@
#EXTINF
#EXTINF:420,Savant feat. Qwentalis - Starscream Forever (Original Mix) #EXTINF:420,Savant feat. Qwentalis - Starscream Forever (Original Mix)
ffmpeg2wav:youtube-dl-x:BkJtsNBL8Lc ffmpeg2wav:youtube-dl-x:BkJtsNBL8Lc
#EXTINF:248,Zelda Medley- Lindsey Stirling #EXTINF:248,Zelda Medley- Lindsey Stirling

75
web/common.php Normal file
View File

@ -0,0 +1,75 @@
<?php
class scanDir {
static private $directories, $files, $ext_filter, $recursive;
// ----------------------------------------------------------------------------------------------
// scan(dirpath::string|array, extensions::string|array, recursive::true|false)
static public function scan(){
// Initialize defaults
self::$recursive = false;
self::$directories = array();
self::$files = array();
self::$ext_filter = false;
// Check we have minimum parameters
if(!$args = func_get_args()){
die("Must provide a path string or array of path strings");
}
if(gettype($args[0]) != "string" && gettype($args[0]) != "array"){
die("Must provide a path string or array of path strings");
}
// Check if recursive scan | default action: no sub-directories
if(isset($args[2]) && $args[2] == true){self::$recursive = true;}
// Was a filter on file extensions included? | default action: return all file types
if(isset($args[1])){
if(gettype($args[1]) == "array"){self::$ext_filter = array_map('strtolower', $args[1]);}
else
if(gettype($args[1]) == "string"){self::$ext_filter[] = strtolower($args[1]);}
}
// Grab path(s)
self::verifyPaths($args[0]);
return self::$files;
}
static private function verifyPaths($paths){
$path_errors = array();
if(gettype($paths) == "string"){$paths = array($paths);}
foreach($paths as $path){
if(is_dir($path)){
self::$directories[] = $path;
$dirContents = self::find_contents($path);
} else {
$path_errors[] = $path;
}
}
if($path_errors){echo "The following directories do not exists<br />";die(var_dump($path_errors));}
}
// This is how we scan directories
static private function find_contents($dir){
$result = array();
$root = scandir($dir);
foreach($root as $value){
if($value === '.' || $value === '..') {continue;}
if(is_file($dir.DIRECTORY_SEPARATOR.$value)){
if(!self::$ext_filter || in_array(strtolower(pathinfo($dir.DIRECTORY_SEPARATOR.$value, PATHINFO_EXTENSION)), self::$ext_filter)){
self::$files[] = $result[] = $dir.DIRECTORY_SEPARATOR.$value;
}
continue;
}
if(self::$recursive){
foreach(self::find_contents($dir.DIRECTORY_SEPARATOR.$value) as $value) {
self::$files[] = $result[] = $value;
}
}
}
// Return required for recursive search
return $result;
}
}
?>

21
web/playlist.php Normal file
View File

@ -0,0 +1,21 @@
<?
include 'common.php';
$files = scanDir::scan('/playlists/normal', false, true);
echo "#EXTM3U\n";
foreach($files as $file) {
$filename = $file;
$file = file($file);
$file = array_slice($file, 1);
echo "#$filename\n";
foreach($file as $line) {
echo $line;
}
}
?>