ENH: titres récupérés depuis le json

pull/33/head
Boris 1 year ago
parent b5f543220f
commit 74e478feda

@ -0,0 +1,90 @@
#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
# Version: 0.1
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
# SCRIPT INTERACTIF POUR AJOUTER UN FICHIER à ASTROPORT/KODI
#
# 1. CAT: film, serie, anime
# 2. TMDB: ID de la fiche sur https://www.themoviedb.org/
# 3. TITLE: Titre de la vidéo
# 4. YEAR: Année de la vidéo
# 5. RES: Résolution 1080p, 4K, SD, 720, HD
# 6. SAISON: Pour les séries et animes, c'est le numéro de saison.
# Pour un film, le champ SAISON est utilisé pour renseigner la Saga
# 7. GENRES: Action, Aventure, Fantastique, Animation, etc (choix multiple).
# 8. GROUPES: Permet de regrouper des films. (choix multiple)
#
# https://github.com/Kodi-vStream/venom-xbmc-addons/wiki/Voir-et-partager-sa-biblioth%C3%A8que-priv%C3%A9e#d%C3%A9clarer-des-films
########################################################################
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) && [[ ! $YOU ]] && echo "ipfs NOT RUNNING. EXIT" && exit 1
HOME=/home/$YOU
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
########################################################################
########################################################################
IPFSNODEID=$(ipfs id -f='<id>\n')
[[ -f ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_title ]] && XZUID=$(cat ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.gchange_title) || XZUID=$(cat /etc/hostname)
########################################################################
# CASE ## YOUTUBE
########################################################################
#YTURL=$(zenity --entry --width 300 --title "Lien ou identifiant à copier" --text "Indiquez le lien (URL) ou l'ID de la vidéo" --entry-text="")
YTURL=$1
[[ $YTURL == "" ]] && exit 1
# Create TEMP directory to copy $YID_$TITLE.$FILE_EXT
YTEMP="/tmp/$(date -u +%s%N | cut -b1-13)"
mkdir -p ${YTEMP}
# youtube-dl $YTURL
echo "VIDEO $YTURL"
/usr/local/bin/youtube-dl -f '[height=720]/best' \
--write-info-json --write-annotations \
--no-mtime -o "${YTEMP}/%(id)s_%(title)s.%(ext)s" $YTURL
# Get filename, extract ID, make destination dir and move copy.
YFILE=$(ls -t ${YTEMP} | head -n 1)
FILE_NAME="$(basename "${YFILE}")"
FILE_EXT="${FILE_NAME##*.}"
YID=$(echo "${FILE_NAME}" | cut -d "_" -f 1)
YNAME=$(echo "${FILE_NAME}" | cut -d "_" -f 2-)
TMDB="${YID}"
FILE_PATH="$HOME/astroport/youtube/$YID"
echo "Creating directory $FILE_PATH"
mkdir -p -v --mode=775 $FILE_PATH || echo "Directory creation failed :-("
echo "Moving files there..."
mv -f ${YTEMP}/* ${FILE_PATH}/
## CORRECT PARAMETERS to Make Kodi compatible YASTRXBIAN FILE
TITLE="${YNAME%.*}"
GENRES="[Youtube]"
GROUPES="_IPNSKEY_"
FILE_RES=$(ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 "${FILE_PATH}/${FILE_NAME}" | cut -d "x" -f 2)
RES=${FILE_RES%?}0p
## CREATE "~/astroport/${CAT}/${TMDB}/ajouter_video.txt" (with film CAT !!!)
URLENCODE_FILE_NAME=$(echo ${FILE_NAME} | jq -Rr @uri)
echo "film;${TMDB};${YEAR};${TITLE};${SAISON};${GENRES};${GROUPES};${RES};/ipfs/_IPFSREPFILEID_/$URLENCODE_FILE_NAME" > ~/astroport/youtube/${TMDB}/ajouter_video.txt
# _IPFSREPFILEID_ is replaced later
rm -Rf ${YTEMP}
########################################################################
# ADD $FILE to IPFS / ASTROPORT / KODI
########################################################################
./new_youtube_video_in_astroport.sh "$HOME/astroport/youtube/${TMDB}/" "${FILE_NAME}" > /tmp/youtube_${TMDB}.log 2>&1
########################################################################
########################################################################
exit 0

@ -3,6 +3,12 @@
define('STATION_NAME', exec('cat ../../../ipfs/.12D*/_xbian.zuid'));
define('HOST', 'astroport');
define('THEME', 'astroport');
define('SITENAME', 'Astroport "' . STATION_NAME . '"');
define('IPFS_API_PORT', 5001);
define('IPFS_HOST', '127.0.0.1');
define('TAGLINE', 'Bienvenue <strong>chez vous</strong>');
/*

@ -64,3 +64,72 @@ function guessTypeFromFilename ($filename) {
return $type;
}
function astroport_urlencode ($str) {
$str = str_replace('%', '%25', $str);
$str = str_replace('#', '%23', $str);
$str = str_replace('\'', '%27', $str);
$str = str_replace('"', '%22', $str);
return $str;
}
function quickfix_getYoutubeIdFromIpfsFileName ($name) {
return substr($name, 0, 11);
}
function quickfix_getVideoNameFromIpfsFileName ($name) {
//$name = substr($name, 12);
$name = substr($name, 0, strrpos($name, '.'));
return $name;
}
function formatDuration ($seconds) {
$h = floor($seconds / 3600);
$h_r = $seconds % 3600;
$m = floor($h_r / 60);
$s = $h_r % 60;
if ($h != 0) {
return sprintf("%s:%s:%s", $h, str_pad($m, 2, '0', STR_PAD_LEFT), str_pad($s, 2, '0', STR_PAD_LEFT));
} else {
return sprintf("%s:%s", $m, str_pad($s, 2, '0', STR_PAD_LEFT));
}
}
function getVideoJson ($ipnsHash) {
exec("/bin/bash -c './get_ipfs_node_id.sh'", $output);
// echo '<pre>'; var_dump($output); echo '</pre>';
$ipfsNodeId = $output[0];
$indexHTML = file_get_contents('http://' . HOST . '/ipns/' . $ipnsHash . '/index.html');
// $indexHTML = file_get_contents('http://' . HOST . '/ipns/' . $ipfsNodeId . '/.' . $ipfsNodeId . '/KEY/');
$re = '!/ipns/[^/]+/([^/]+)/!isU';
preg_match($re, $indexHTML, $matches);
$ipnsHiddenHash = $matches[1];
$indexHTML = file_get_contents('http://' . HOST . '/ipns/' . $ipnsHash . '/' . $ipnsHiddenHash . '/video.json');
if (isset($indexHTML)) {
return json_decode($indexHTML);
}
}

@ -0,0 +1,5 @@
#!/bin/bash
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) && [[ ! $YOU ]] && echo "ipfs NOT RUNNING. EXIT" && exit 1
IPFSNODEID=$(ipfs --timeout=20s id -f='<id>\n')
echo -n $IPFSNODEID

@ -0,0 +1,6 @@
#!/bin/bash
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) && [[ ! $YOU ]] && echo "ipfs NOT RUNNING. EXIT" && exit 1
cat /home/$YOU/.zen/ipfs*/.*/astroport/kodi/vstream/YASTRXBIAN | sort | uniq | tail -n +2

@ -0,0 +1,13 @@
</main>
<footer>
<p>
<span>le code est libre</span> × <span>voyez le évoluer</span>
</p>
<p>
<span><a href="https://git.p2p.legal/axiom-team/astrXbian/src/branch/master/www/boris">~/.zen/AstXbian/www/boris</a></span> × <span><a href="/ipfs/QmbmjSBWVNSSjJsMmCeFuFtQiuWyGg6iUGLRyvK7TUkFN8">Voir le code de la page</a></span>
</p>
</footer>
</body>
</html>

@ -0,0 +1,63 @@
<?php
require_once('conf.php');
?><!DOCTYPE html>
<html>
<head>
<title>Astroport "<?php echo STATION_NAME; ?></title>
<link rel="stylesheet" href="styles/<?php echo THEME; ?>/style.css" type="text/css" />
<link rel="icon" type="image/png" href="./styles/<?php echo THEME; ?>/logo.png" />
</head>
<body>
<header>
<?php $elt = isset($home) ? 'h1' : 'h6'; ?>
<<?php echo $elt; ?>>
<a href="youtube.php">Astroport "<span><?php echo STATION_NAME; ?></span>"</a>
</<?php echo $elt; ?>>
<p class="usp">
<?php echo TAGLINE; ?>
</p>
<form method="post" action="" class="add-video">
<label for="youtube_url">Sauvegarder une vidéo Youtube&nbsp;:</label>
<?php
if (!isset($_POST['youtube_url'])) {
$out = '';
$placeholder = 'https://www.youtube.com/watch?v=ASywAfBAVrQ';
} else {
$out = '
<p class="confirmation">Votre vidéo est en cours de téléchargement…</p>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$.ajax({
method: "POST",
url: "youtube_add_video_aux.php",
data: { youtube_url: "'. $_POST['youtube_url'] .'" }
})
.done(function( response ) {
console.log(response);
});
</script>';
$placeholder = htmlspecialchars($_POST['youtube_url']);
}
?>
<input type="text" name="youtube_url" placeholder="<?php echo $placeholder; ?>" size="45" />
<input type="submit" value="Mon précieux !" />
<?php
echo $out;
?>
</form>
</header>
<main>

@ -0,0 +1,10 @@
The MIT License (MIT)
Copyright (c) 2015-2016 Vincent Cloutier
Copyright (c) 2016 S3r3nity Technologies
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ -0,0 +1,113 @@
IPFS API wrapper library in PHP
======================================
![](https://ipfs.io/ipfs/QmQJ68PFMDdAsgCZvA1UVzzn18asVcf7HVvCDgpjiSCAse)
> A client library for the IPFS API.
Good news everyone! [S3r3nity](http://www.s3r3nity.com/) is sponsoring the development of this library.
They will be using it inside one of their (unannounced) projects and its maintainer is hired
to implement all the missing api calls (including the new file api) before the end of September 2016.
**Warning:** Changes will be made from user's suggestions and this warning will be removed when everything is stable.
First stable release is scheduled for the end of September 2016.
# Usage
## Installing
This library requires the cURL module:
```bash
$ sudo apt-get install php5-curl
$ composer require cloutier/php-ipfs-api
$ composer install
```
```PHP
use Cloutier\PhpIpfsApi\IPFS;
// connect to ipfs daemon API server
$ipfs = new IPFS("localhost", "8080", "5001"); // leaving out the arguments will default to these values
```
## API
#### add
Adds content to IPFS.
**Usage**
```PHP
$hash = $ipfs->add("Hello world");
```
#### cat
Retrieves the contents of a single hash.
**Usage**
```PHP
$ipfs->cat($hash);
```
#### ls
Gets the node structure of a hash.
**Usage**
```PHP
$obj = $ipfs->ls($hash);
foreach ($obj as $e) {
echo $e['Hash'];
echo $e['Size'];
echo $e['Name'];
}
```
#### Object size
Returns object size.
**Usage**
```PHP
$size = $ipfs->size($hash);
```
#### Pin
Pin or unpin a hash.
**Usage**
```PHP
$ipfs->pinAdd($hash);
$ipfs->pinRm($hash);
```
#### Pin
Get information about your ipfs node.
**Usage**
```PHP
print_r($ipfs->id());
```
# License
The MIT License (MIT)
Copyright (c) 2015-2016 Vincent Cloutier
Copyright (c) 2016 S3r3nity Technologies
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ -0,0 +1,25 @@
{
"name": "cloutier/php-ipfs-api",
"type": "library",
"description": "A client library for the IPFS API",
"keywords": ["ipfs"],
"homepage": "https://github.com/cloutier/php-ipfs-api",
"license": "MIT",
"authors": [
{
"name": "Vincent Cloutier",
"email": "vincent@cloutier.co",
"homepage": "http://vincent.cloutier.co",
"role": "Developer"
}
],
"require": {
"php": ">=5.3.0",
"ext-curl": "*"
},
"autoload": {
"psr-4": {
"Cloutier\\PhpIpfsApi\\": "src/"
}
}
}

@ -0,0 +1,21 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "1128371a4702e5be4d07d705b7c25765",
"packages": [],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=5.3.0",
"ext-curl": "*"
},
"platform-dev": [],
"plugin-api-version": "1.1.0"
}

@ -0,0 +1,129 @@
<?php
/*
This code is licensed under the MIT license.
See the LICENSE file for more information.
*/
namespace Cloutier\PhpIpfsApi;
class IPFS {
private $gatewayIP;
private $gatewayPort;
private $gatewayApiPort;
function __construct($ip = "localhost", $port = "8080", $apiPort = "5001") {
$this->gatewayIP = $ip;
$this->gatewayPort = $port;
$this->gatewayApiPort = $apiPort;
}
public function cat ($hash) {
$ip = $this->gatewayIP;
$port = $this->gatewayPort;
return $this->curl("http://$ip:$port/ipfs/$hash");
}
public function add ($content) {
$ip = $this->gatewayIP;
$port = $this->gatewayApiPort;
$req = $this->curl("http://$ip:$port/api/v0/add?stream-channels=true", $content);
$req = json_decode($req, TRUE);
return $req['Hash'];
}
public function ls ($hash) {
$ip = $this->gatewayIP;
$port = $this->gatewayApiPort;
$response = $this->curl("http://$ip:$port/api/v0/ls/$hash");
$data = json_decode($response, TRUE);
return $data['Objects'][0]['Links'];
}
public function size ($hash) {
$ip = $this->gatewayIP;
$port = $this->gatewayApiPort;
$response = $this->curl("http://$ip:$port/api/v0/object/stat/$hash");
$data = json_decode($response, TRUE);
return $data['CumulativeSize'];
}
public function pinAdd ($hash) {
$ip = $this->gatewayIP;
$port = $this->gatewayApiPort;
$response = $this->curl("http://$ip:$port/api/v0/pin/add/$hash");
$data = json_decode($response, TRUE);
return $data;
}
public function pinRm ($hash) {
$ip = $this->gatewayIP;
$port = $this->gatewayApiPort;
$response = $this->curl("http://$ip:$port/api/v0/pin/rm/$hash");
$data = json_decode($response, TRUE);
return $data;
}
public function version () {
$ip = $this->gatewayIP;
$port = $this->gatewayApiPort;
$response = $this->curl("http://$ip:$port/api/v0/version");
$data = json_decode($response, TRUE);
return $data['Version'];
}
public function id () {
$ip = $this->gatewayIP;
$port = $this->gatewayApiPort;
$response = $this->curl("http://$ip:$port/api/v0/id");
$data = json_decode($response, TRUE);
return $data;
}
private function curl ($url, $data = "") {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
if ($data != "") {
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: multipart/form-data; boundary=a831rwxi1a3gzaorw1w2z49dlsor'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "--a831rwxi1a3gzaorw1w2z49dlsor\r\nContent-Type: application/octet-stream\r\nContent-Disposition: file; \r\n\r\n" . $data . "\r\n--a831rwxi1a3gzaorw1w2z49dlsor");
}
$output = curl_exec($ch);
if ($output == FALSE) {
//todo: when ipfs doesn't answer
}
curl_close($ch);
return $output;
}
}

@ -0,0 +1,7 @@
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitfb20af428fb50fc34b2be451caca0aba::getLoader();

@ -0,0 +1,445 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Autoload;
/**
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @see http://www.php-fig.org/psr/psr-0/
* @see http://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
// PSR-4
private $prefixLengthsPsr4 = array();
private $prefixDirsPsr4 = array();
private $fallbackDirsPsr4 = array();
// PSR-0
private $prefixesPsr0 = array();
private $fallbackDirsPsr0 = array();
private $useIncludePath = false;
private $classMap = array();
private $classMapAuthoritative = false;
private $missingClasses = array();
private $apcuPrefix;
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
}
return array();
}
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
public function getClassMap()
{
return $this->classMap;
}
/**
* @param array $classMap Class to filename map
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap, $classMap);
} else {
$this->classMap = $classMap;
}
}
/**
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*/
public function add($prefix, $paths, $prepend = false)
{
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
(array) $paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
(array) $paths
);
}
return;
}
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
(array) $paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
(array) $paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
(array) $paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
(array) $paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 base directories
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}
/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*/
public function setPsr4($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}
/**
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}
/**
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
* @return bool
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}
/**
* Turns off searching the prefix and fallback directories for classes
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classMapAuthoritative = $classMapAuthoritative;
}
/**
* Should class lookup fail if not found in the current class map?
*
* @return bool
*/
public function isClassMapAuthoritative()
{
return $this->classMapAuthoritative;
}
/**
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
*
* @param string|null $apcuPrefix
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
}
/**
* The APCu prefix in use, or null if APCu caching is not enabled.
*
* @return string|null
*/
public function getApcuPrefix()
{
return $this->apcuPrefix;
}
/**
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
}
/**
* Unregisters this instance as an autoloader.
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return bool|null True if loaded, null otherwise
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
includeFile($file);
return true;
}
}
/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|false The path if found, false otherwise
*/
public function findFile($class)
{
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
return false;
}
if (null !== $this->apcuPrefix) {
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
if ($hit) {
return $file;
}
}
$file = $this->findFileWithExtension($class, '.php');
// Search for Hack files if we are running on HHVM
if (false === $file && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}
if (null !== $this->apcuPrefix) {
apcu_add($this->apcuPrefix.$class, $file);
}
if (false === $file) {
// Remember that this class does not exist.
$this->missingClasses[$class] = true;
}
return $file;
}
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath . '\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
}
}
}
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}
// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
}
if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
}
}
}
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
// PSR-0 include paths.
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}
return false;
}
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*/
function includeFile($file)
{
include $file;
}

@ -0,0 +1,19 @@
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

@ -0,0 +1,9 @@
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);

@ -0,0 +1,9 @@
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);

@ -0,0 +1,10 @@
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Cloutier\\PhpIpfsApi\\' => array($baseDir . '/src'),
);

@ -0,0 +1,55 @@
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitfb20af428fb50fc34b2be451caca0aba
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
/**
* @return \Composer\Autoload\ClassLoader
*/
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitfb20af428fb50fc34b2be451caca0aba', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitfb20af428fb50fc34b2be451caca0aba', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitfb20af428fb50fc34b2be451caca0aba::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
$loader->register(true);
return $loader;
}
}

@ -0,0 +1,31 @@
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInitfb20af428fb50fc34b2be451caca0aba
{
public static $prefixLengthsPsr4 = array (
'C' =>
array (
'Cloutier\\PhpIpfsApi\\' => 20,
),
);
public static $prefixDirsPsr4 = array (
'Cloutier\\PhpIpfsApi\\' =>
array (
0 => __DIR__ . '/../..' . '/src',
),
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitfb20af428fb50fc34b2be451caca0aba::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitfb20af428fb50fc34b2be451caca0aba::$prefixDirsPsr4;
}, null, ClassLoader::class);
}
}

@ -0,0 +1,73 @@
:root {
--rouge: hsl(0, 98.8%, 33.5%);
--noir-fonce: hsl(0, 30%, 2.1%);
--noir-moyen: hsl(0, 15%, 3.1%);
--noir-clair: hsl(0, 5%, 7.1%);
}
body {
background: var(--noir-fonce);
color: white;
font-family: Roboto,sans-serif;
}
header {
background: var(--noir-clair);
}
header * {
color: var(--rouge);
text-decoration: none;
}
header span {
color: white;
}
#videosList li {
background: var(--noir-clair);
border-color: var(--rouge);
border-style: solid;
}
.video-title,
.video-title a,
.video-title a:visited {
color: white;
font-weight: bold;
text-decoration: none;
}
article {
background: var(--noir-clair);
}
article video {
background: black;
}
article .video-title {
font-weight: bold;
}
#successMsg {
opacity: 0;
transition: opacity 1s;
}

@ -0,0 +1 @@
../default/layout.css

@ -1,117 +1,2 @@
:root {
--rouge: hsl(0, 98.8%, 33.5%);
--noir-fonce: hsl(0, 30%, 2.1%);
--noir-moyen: hsl(0, 15%, 3.1%);
--noir-clair: hsl(0, 5%, 7.1%);
}
body {
background: var(--noir-fonce);
color: white;
margin: 0;
padding: 0;
font-family: Roboto,sans-serif;
}
header {
background: var(--noir-clair);
overflow: hidden;
margin-bottom: 2rem;
}
header * {
font-size: 1.5rem;
padding: 0.5rem;
margin: 0;
color: var(--rouge);
text-decoration: none;
}
header span {
color: white;
}
main {
width: 80%;
margin: auto;
}
#videosList {
display: grid;
grid-gap: 1rem 1rem;
grid-auto-flow: row;
grid-template-columns: 322px 322px 322px;
list-style: none;
margin: 0;
padding: 0;
}
#videosList li {
background: var(--noir-clair);
border-color: var(--rouge);
border-radius: 0.25rem;
border-width: 1px;
border-style: solid;
overflow: hidden;
}
#videosList .video-title {
padding: 0.5rem 1rem;
}
.video-title,
.video-title a,
.video-title a:visited {
color: white;
font-weight: bold;
text-decoration: none;
}
article {
border-radius: 0.25rem;
background: var(--noir-clair);
width: 58.3%;
margin: auto;
overflow: hidden;
}
article video {
width: 100%;
max-height: 50vh;
background: black;
}
article .video-title {
font-weight: bold;
padding: 1rem 1rem;
font-size: 1.25rem;
margin: 0;
}
footer {
display: none;
}
#successMsg {
opacity: 0;
transition: opacity 1s;
}
@import "./layout.css";
@import "./decoration.css";

@ -0,0 +1,102 @@
:root {
--pink: hsl(338.5, 72.8%, 36.1%);
--light-pink: hsl(338.5, 72.8%, 56.1%);
--canard: hsl(200.8, 100%, 9.6%);
}
body {
background: #121212;
color: white;
font-family: Roboto,sans-serif;
}
header {
background: var(--canard);
}
header a,
header a:visited {
color: white;
text-decoration: none;
}
header a:active {
outline: 0;
}
header > .sitetitle span {
border-bottom-style: solid;
border-bottom-color: var(--pink);
}
header .usp {
color: white;
}
header .usp strong {
color: var(--light-pink);
}
#videosList li {
background: var(--canard);
border-color: var(--pink);
border-style: solid;
}
.video-title,
.video-title a,
.video-title a:visited {
color: white;
font-weight: bold;
text-decoration: none;
}
article {
background: var(--canard);
}
article video {
background: black;
}
article .video-title {
font-weight: bold;
}
form.add-video input[type="text"] {
border-style: solid;
border-color: transparent;
}
form.add-video input[type="text"]:focus {
border-color: var(--pink);
outline: 0;
}
form.add-video input[type="submit"] {
background: var(--pink);
border-color: var(--pink);
border-style: solid;
color: white;
font-weight: bold;
}

@ -1,104 +1,2 @@
:root {
--pink: hsl(338.5, 72.8%, 36.1%);
--canard: hsl(200.8, 100%, 9.6%);
}
body {
background: #121212;
color: white;
margin: 0;
padding: 0;
font-family: Roboto,sans-serif;
}
header {
background: var(--canard);
overflow: hidden;
margin-bottom: 2rem;
}
header * {
font-size: 1.5rem;
padding: 0.5rem;
margin: 0;
color: var(--pink);
text-decoration: none;
}
header span {
color: white;
}
main {
width: 80%;
margin: auto;
}
#videosList {
display: grid;
grid-gap: 1rem 1rem;
grid-auto-flow: row;
grid-template-columns: 322px 322px 322px;
list-style: none;
margin: 0;
padding: 0;
}
#videosList li {
background: var(--canard);
border-color: var(--pink);
border-radius: 0.25rem;
border-width: 1px;
border-style: solid;
overflow: hidden;
}
#videosList .video-title {
padding: 0.5rem 1rem;
}
.video-title,
.video-title a,
.video-title a:visited {
color: white;
font-weight: bold;
text-decoration: none;
}
article {
border-radius: 0.25rem;
background: var(--canard);
width: 58.3%;
margin: auto;
overflow: hidden;
}
article video {
width: 100%;
max-height: 50vh;
background: black;
}
article .video-title {
font-weight: bold;
padding: 1rem 1rem;
font-size: 1.25rem;
margin: 0;
}
@import "./layout.css";
@import "./decoration.css";

@ -0,0 +1,131 @@
body {
margin: 0;
padding: 0;
}
header {
overflow: hidden;
padding: 1rem 0.666rem 1.333rem;
margin-bottom: 2rem;
}
header > * {
font-size: 1.5rem;
margin: 0;
padding: 0;
}
header > .sitetitle {
margin-bottom: 0.25rem;
}
header > .sitetitle span {
border-bottom-style: solid;
border-bottom-color: var(--pink);
}
header .usp {
font-size: 0.95rem;
}
main {
width: 95%;
margin: auto;
}
#videosList {
display: grid;
grid-gap: 1rem 1rem;
grid-auto-flow: row;
grid-template-columns: 322px 322px 322px;
list-style: none;
margin: 0;
padding: 0;
justify-content: center;
}
#videosList li {
border-radius: 0.25rem;
border-width: 1px;
overflow: hidden;
}
#videosList .video-title {
padding: 0.5rem 1rem;
}
article {
border-radius: 0.25rem;
width: 58.3%;
margin: auto;
overflow: hidden;
}
article video {