<?php

$dsn = "mysql:host=127.0.0.1; port=6244; dbname=tytd";
$dbusername = "guest";
$dbpassword = "";
try {
    $pdo = new PDO($dsn,$dbusername,$dbpassword);
    $pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
} catch (PDOException $th) {
    echo "Connection failed: " . $th->getMessage();
}



function video_exists($id,$res)
{
    $path = $res."/".$id;
    $ext = "";

   


    if(file_exists($server_path.$path.".mp4"))
    {
        $ext = ".mp4";
        $path = $path.".mp4";
    }else
    if(file_exists($server_path.$path.".webm"))
    {
        $ext = ".webm";
        $path = $path.".webm";
    }else
    if(file_exists($server_path.$path.".3gpp"))
    {
        $ext = ".3gpp";
        $path = $path.".3gpp";
    }else
    if(file_exists($server_path.$path.".mkv"))
    {
        $ext = ".mkv";
        $path = $path.".mkv";
    }else if(file_exists($server_path.$path.".Tesses.YouTubeDownloader.BestStreamInfo"))
    {
	$ext=".Tesses.YouTubeDownloader.BestStreamInfo";
	$path=$path.".Tesses.YouTubeDownloader.BestStreamInfo";
    }
    else 
    {
        return "";
    }

    return $path;
}

?>
