<?php
require_once('smarty/Smarty.class.php');

define('ROOT_PATH', preg_replace('/index.php/', '', $_SERVER["DOCUMENT_ROOT"].$_SERVER["DOCUMENT_URI"]));
define('TOOLS_PATH', ROOT_PATH.'tools/');

$titulo="YTLibre";
$version="1.2.4";
$source_code="https://notabug.org/heckyel/ytlibre";
/* ---- ---- ---- Generated ---- ---- ---- ---- */
if ( empty($_GET['link']) )
{
    $template= new Smarty();
    /* ---- ---- Variables ---- ---- */
    $template->assign("titulo", $titulo);
    $template->assign("version", $version);
    /* ---- ---- CSS ---- ---- */
    $template->assign('styles', array('frond' => 'templates/css/frond.min.css',
                                      'normalize' => 'templates/css/normalize.css')
    );
    $template->display('templates/index.tpl');
}
else
{
    /* ---- ---- video-generated ---- ---- */
    require_once "tools/processor.php";
    $video_decode = new Smarty();

    /* ---- ---- Variables ---- ---- */
    $video_decode->assign("titulo", $titulo);
    $video_decode->assign("version", $version);
    $video_decode->assign("videoTitle", $videoTitle);
    $video_decode->assign("videoThumbURL", $videoThumbURL);
    $video_decode->assign("videoAuthor", $videoAuthor);
    $video_decode->assign("videoDuration", $videoDuration);
    $video_decode->assign("videoViews", $videoViews);

    // Videos Loop
    $video_decode->assign("streamFormats", $streamFormats);

    // Extra videos
    $video_decode->assign("streamExtra", $streamExtra);
    $video_decode->assign("streamFormatsExtra", $streamFormatsExtra);

    // Live
    $video_decode->assign("islive", $islive);

    // URL's
    $video_decode->assign("local_url", $local_url);
    $video_decode->assign("url_query", $url_query);

    /* ---- ---- CSS ---- ----  */
    $video_decode->assign('styles', array('frond' => 'templates/css/frond.min.css',
                                          'normalize' => 'templates/css/normalize.css',
                                          'plyr' => 'templates/libs/plyr/plyr.css',
                                          'salida' => 'templates/css/salida.min.css')
    );

    /* ---- ---- JS ---- ---- */
    $video_decode->assign('javascript', array('plyr' => 'templates/libs/plyr/plyr.min.js')
    );

    $video_decode->display('templates/video.tpl');
}
