<?php
include("db.php");
include("vars.php");
header("Content-Type: application/json");
$id=$_GET["v"];
$stmt = $pdo->prepare("select * from SavedVideo where Id like '$id'");
$stmt->execute();
$video = $stmt->fetchAll()[0];
$desc = utf8_encode($video["Description"]);
$res = "PreMuxed";
if(isset($_GET["res"]))
{
    $myRes = $_GET["res"];
    if($myRes == "PreMuxed" || $myRes == "Mux" || $myRes == "AudioOnly" || $myRes == "VideoOnly")
    {
        $res = $myRes;
    }
}
$path = video_exists($video["Id"],$res);


$array = ["exists"=>strlen($path)>0,"path"=>$url_root."content/".$path,"title"=>utf8_encode($video["Title"]),"id"=>$video["Id"],"author_title"=>utf8_encode($video["AuthorTitle"]),"author_id"=>$video["AuthorId"],"description"=>$desc,"views"=>$video["Views"],"likes"=>$video["Likes"],"dislikes"=>$video["Dislikes"],"upload_date"=>$video["UploadDate"],"tytd_tag"=>utf8_encode($video["TYTDTag"])];


echo json_encode($array);
?>