Bonsoir,
J'utilise un flux RSS custom pour pouvoir lister mes téléchargements et pouvoir laisser mon syno rapatrier les fichiers (nouveaux) automatiquement.
Le seul soucis que j'ai, se sont les caractères spéciaux.
Voici ce que ça donne avec un exemple :
Agents très spéciaux Code U.N.C.L.E (2015).mp4
Du coup, je ne sais pas trop dire si ce soucis vient de mon flux RSS ou s'il s'agit du syno, ou encore d'autre chose.
Si quelqu'un a une idée.
pour information voici le code du RSS :
<?php
//Utilisation : <-----------URL------------>/rss.php?dossier=<NOM_DU_DOSSIER>
//Si le paramêtre dossier n'est pas mis, le dossier par défaut est listé.
/********************************/
/* CONFIGURATION */
/********************************/
$user = "gormson";
$physical_path = '/home/'.$user.'/termines/'; // Dossier à lister par défaut (ex : /var/www/download)
$max = 70; //Nombre de fichiers à afficher dans le flux RSS
$site = 'http://domaine.tld/cakebox/'.$user; // IP ou NDD (http://<IP> ou htps://<IP> ou ftp://<IP> etc... utilisé pour télécharger les fichiers)
$nomDePage = 'XXXX - '.$user;// Nom affiché
$lienInterne = '/home/'.$user.'/termines/'; //position non affiché dans l'url (ex : /var/www/download/fichier.ext et url = http://<IP>/download/fichier.ext, mettre /var/www/ dans ce champs car non présent dans l'url)
$tempsAttente = 300; //Temps (en s) sans que le fichier soit modifié avant de le lister. (si trop rapide, il peut apparaître alors que le fichier n'est pas fini de téléchargé).
//VOIR LIGNE 100 POUR INDIQUER LES EXTENSIONS AUTORISES :
// Ajouter '|| get_file_icon($file)=="ext"' (sans les '') avant la fin de la parenthèse avec ext, l'extension que l'on veut qui soit listé
/********************************/
/* FONCTIONS */
/********************************/
$excludeFiles = array(".", "..", ".htaccess", ""); // Liste des fichiers ignorés dans le listing
/**
* Récupère récursivement le contenu d'un répertoire
* et le retourne sous forme d'array
* @param $directory Le répertoire à traiter
**/
function recursive_directory_tree($directory = null)
{
global $excludeFiles;
//If $directory is null, set $directory to the current working directory.
if ($directory == null) {
$directory = getcwd();
}
//declare the array to return
$return = array();
//Check if the argument specified is an array
if (is_dir($directory)) {
//Scan the directory and loop through the results
foreach(scandir($directory) as $file) {
//. = current directory, .. = up one level. We want to ignore both.
if ($file[0] == ".") {
continue;
}
//Exclude some specified files
if (in_array($file, $excludeFiles)) {
continue;
}
//Check if the current $file is a directory itself.
//The appending of $directory is necessary here.
if (is_dir($directory."/".$file))
{
//Create a new array with an index of the folder name.
$return[$directory."/".$file] = recursive_directory_tree($directory."/".$file);
}
else
{
//If $file is not a directory, just add it to th return array.
$return[] = $directory."/".$file;
}
}
}
else
{
$return[] = $directory;
}
return $return;
}
/**
* Stock dans un tableau tous les fichiers video présents dans le repertoire mis en pareamètre
**/
function liste($dossier)
{
global $tabTrie;
foreach ($dossier as $file)
{
if ( is_array($file) )
{
liste($file);
}
else
{
if(get_file_icon($file)=="mp4" || get_file_icon($file)=="mkv" || get_file_icon($file)=="avi" || get_file_icon($file)=="zip" || get_file_icon($file)=="cbz" || get_file_icon($file)=="pdf" || get_file_icon($file)=="cbr" )
{
array_push($tabTrie, $file);
}
}
}
}
/**
* Convertit la taille en Xo
* @param $fs La taille à convertir
*/
function convert_size($fs)
{
if ($fs >= 1073741824)
$fs = round($fs / 1073741824 * 100) / 100 . " Go";
elseif ($fs >= 1048576)
$fs = round($fs / 1048576 * 100) / 100 . " Mo";
elseif ($fs >= 1024)
$fs = round($fs / 1024 * 100) / 100 . " Ko";
else
$fs = $fs . " o";
return $fs;
}
/**
* Retourne l'extention d'un fichier en fonction de son type
* @filename Le nom du fichier à considérer
*/
function get_file_icon($filename)
{
return pathinfo($filename, PATHINFO_EXTENSION);
}
/**
* Retourne le mime d'un fichier
* @filename Le nom du fichier à considérer
*/
function mime_file($filename)
{
$finfo = finfo_open(FILEINFO_MIME_TYPE); // Retourne le type mime à la extension mimetype
$mime=finfo_file($finfo, $filename);
finfo_close($finfo);
return $mime;
}
/********************************/
/* FONCTIONS */
/********************************/
$entete = '<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:media="http://search.yahoo.com/mrss/"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<atom:link href="'.$site.'/rss.php" rel="self" type="application/rss+xml" />
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
<title>'.$nomDePage.'</title>
<link>'.$site.'</link>
<pubDate>'.date('r', time()).'</pubDate>
<language>fr</language>
<description>Liste des nouveaux fichiers</description>
';
$pied = '</channel>
</rss>';
if(isset ($_GET['dossier']))
$physical_path = $physical_path.'/'.$_GET['dossier'];
$current_dir = array();
$tab= array();
$tabSize = array();
$tabTrie= array();
$current_dir = recursive_directory_tree($physical_path);
liste($current_dir);
foreach ($tabTrie as $key => $fichier)
{
$time = filemtime($fichier);
$actualTime = time();
$date = date("F d Y H:i:s.", filemtime($fichier));
if($fichier != '.' && $fichier != '..' && $fichier != 'index.php')
{
$tab["$fichier"] = $time;
$taille=filesize($fichier);
$tabSize["$fichier"] = $taille;
}
}
array_multisort($tab, SORT_DESC, $tabSize);
echo $entete;
$nombre = 1;
foreach ($tab as $fichier => $heure)
{
$nom = basename($fichier);
$extension = get_file_icon($fichier,TRUE);
$nom = str_replace(".$extension", "" , $nom);
$nom = str_replace(".", " " , $nom);
/********************************/
/* RENOMMAGE */
/********************************/
if(substr_count(strtoupper($nom), strtoupper(" epz")) > 0)
{
$nom = str_replace("epz-", "" , $nom);
}
if(substr_count(strtoupper($nom), strtoupper(" HDTV")) > 0)
{
$nom = strrev($nom);
$nom = strrev(substr($nom,strpos(strtoupper($nom),strtoupper("VTDH"))+5));
}
if(substr_count(strtoupper($nom), strtoupper(" PDTV")) > 0)
{
$nom = strrev($nom);
$nom = strrev(substr($nom,strpos(strtoupper($nom),strtoupper("VTDP"))+5));
}
if(substr_count(strtoupper($nom), strtoupper(" WEB")) > 0)
{
$nom = strrev($nom);
$nom = strrev(substr($nom,strpos(strtoupper($nom),strtoupper("BEW"))+4));
}
if(substr_count(strtoupper($nom), strtoupper(" XVID")) > 0)
{
$nom = strrev($nom);
$nom = strrev(substr($nom,strpos(strtoupper($nom),strtoupper("DIVX"))+5));
}
if(substr_count(strtoupper($nom), strtoupper(" LD")) > 0)
{
$nom = strrev($nom);
$nom = strrev(substr($nom,strpos(strtoupper($nom),strtoupper("DL"))+3));
}
if(substr_count(strtoupper($nom), strtoupper(" DC")) > 0)
{
$nom = strrev($nom);
$nom = strrev(substr($nom,strpos(strtoupper($nom),strtoupper("CD"))+3));
}
if(substr_count(strtoupper($nom), strtoupper(" x264")) > 0)
{
$nom = strrev($nom);
$nom = strrev(substr($nom,strpos(strtoupper($nom),strtoupper("462x"))+3));
}
if(substr_count(strtoupper($nom), strtoupper(" bluray")) > 0)
{
$nom = strrev($nom);
$nom = strrev(substr($nom,strpos(strtoupper($nom),strtoupper("yarulb"))+7));
}
$nom = ucwords(mb_strtolower($nom));
$nom = str_replace ( "French" , "FRENCH", $nom);
$nom = str_replace ( "Vostfr" , "VOSTFR", $nom);
$nom = str_replace ( "e0" , "E0", $nom);
$nom = str_replace ( "e1" , "E1", $nom);
$nom = str_replace ( "e2" , "E2", $nom);
$nom = $nom." [$extension]";
/********************************/
/* RENOMMAGE */
/********************************/
if(($actualTime-$heure) > $tempsAttente)
{
if ($nombre <= $max)
{
echo('
<item>
<title>'.$nom.'</title>
<description>'.$nombre.' | Format : '.$extension.' | Date d\'ajout : '. date("d/m/Y H:i:s", $heure).' | Taille : '.convert_size($tabSize["$fichier"]).'</description>
<pubDate>'.date('r', $heure).'</pubDate>
<link>'.$site.str_replace($lienInterne, "" ,$fichier).'</link>
<enclosure length="'.$tabSize[$fichier].'" type="'.mime_file($fichier).'" url="'.$site.str_replace($lienInterne, "" ,$fichier).'" />
</item>
');
$nombre++;
}
}
}
echo $pied;
?>