Skip to content
This repository has been archived by the owner on Sep 7, 2021. It is now read-only.

Commit

Permalink
init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
p410n3 committed Mar 16, 2018
0 parents commit 588d7e8
Show file tree
Hide file tree
Showing 18 changed files with 461 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

*.iml
*.xml
24 changes: 24 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

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 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.

For more information, please refer to <https://unlicense.org>
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Youtube-dl-PHP-GUI

![image](https://i.imgur.com/PqBRRHg.png)

Simple GUI writen in HTML/CSS (Bootstrap) and PHP.
No python or annoying dependency management. Install youtube-dl via apt and unzip the UI to yout htdocs!

# Installation

That is pretty straight forward. Just install youtube-dl and make it so it can be globally run using the command "youtube-dl".
The easiest way to do this is by using `apt install youtube-dl`.
After that just put the contents of the .ZIP file somewhere on your Webserver Directory.

Thats all!

# Known bug: RRMDIR tries to delete the JS and the CSS folder. Will fix today!
22 changes: 22 additions & 0 deletions config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
//md5 hash of "password"
$authArray = array(
"user1"=>"5f4dcc3b5aa765d61d8327deb882cf99",
"user2"=>"5f4dcc3b5aa765d61d8327deb882cf99",
);

//These folders will not be deleted when space is freed. IMPORTANT!
$whiteListedFolders = array(
"js",
"css",
"php",
);

//Delete old folders after x hours
$hours = 0.5; // 0 to disable

//timezone
date_default_timezone_set('Europe/Berlin');

//adding these to the end of the youtube-dl command
$additionalParams = " --no-progress --no-warnings --embed-thumbnail --add-metadata";
107 changes: 107 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/* Keep in mind: Mobile first*/
html {
font-size: 16px;

box-sizing: border-box;
margin: 0;
padding: 0;
}

a {
text-decoration: none !important;
}

body {
color: #444 !important;
background-color: #eeeeee !important;
}

.content {
position: absolute;
margin-top: 80px;

width: 100%;

display: flex;
flex-direction: column;
align-items: center;
flex-wrap: wrap;
}

.content input{
margin-right: 5px;
}

.form {
width: 90%;
display: flex;
justify-content: center;
}

.form form {
width: 100%;
display: flex;
flex-direction: column;
}

.form select {
margin-top: 5px;
max-width: 20%;
min-width: 110px;
}

.login form {
display: flex;
flex-direction: column;
}

.login form input{
margin: 2px;
}

.login form .btn{
max-width: 50%;
}
/** The CSS for the PHP file **/
.dl-page {
font-size: 20px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}

.popen {
max-width: 700px;
width: 80%;

display: flex;
flex-direction: column-reverse;
}

.popen p {
margin: 0 !important;
}

@media (min-width: 480px) {
.form {
width: 60%;
max-width: 600px;
}

.form form {
flex-wrap: nowrap;
}

.url {
min-width: 0;
}
}

.card {
margin: 5px !important;
width: 95vw !important;
max-width: 600px !important;

border: 1px solid rgba(0, 0, 0, .25) !important;
}
34 changes: 34 additions & 0 deletions dl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
include "php/verification.php";
verifyLogin();
?>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>YDL-UI</title>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous">
<link rel="stylesheet" href="css/style.css">
</head>

<body>

<div class="dl-page">
<br />

<?php

include 'php/loopAndPrint.php';

if (isset($_GET['folder'])) {
chdir($_GET['folder']);
//That shows the cards
loopAndPrint();
}

?>
</div>
</body>
</html>
39 changes: 39 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
include "php/verification.php";
verifyLogin();
?>

<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>YDL-UI</title>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous">
<link rel="stylesheet" href="css/style.css">
</head>

<body>
<div class="content">
<h2>YDL-UI</h2>

<div class="form">
<form action="ydl.php" method="post">
<div style="display: inline-flex">
<input type="text" class="form-control url" name="url" placeholder="URL">
<input type="submit" class="btn btn-primary dl-btn" value="Download" id="dlBtn">
</div>
<select name="fileFormat" class="form-control">
<option value="mp3">MP3</option>
<option value="video">Video</option>
</select>
</form>
</div>

<a href="https://rg3.github.io/youtube-dl/supportedsites.html">Supported Sites to Download from</a>
<a href="https://github.com/p410n3/Youtube-dl-PHP-GUI">This project on Github</a>
</div>
</body>

</html>
5 changes: 5 additions & 0 deletions log.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
include "php/verification.php";
verifyLogin();
?>
<pre>
27 changes: 27 additions & 0 deletions login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>login</title>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous">
<link rel="stylesheet" href="css/style.css">
</head>

<body>

<div class="content">
<h2>Authentication needed</h2>
<div class="login">
<form action="login.php" method="post" class="inline">
<input type="text" class="form-control" name="user" placeholder="username">
<input type="password" class="form-control" name="pass" placeholder="password">
<input type="submit" class="btn btn-primary dl-btn">
</form>
</div>
</div>


</body>
</html>
21 changes: 21 additions & 0 deletions login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
session_start();

include "config.php";

if (isset($_POST['user']) && isset($_POST['pass'])) {

foreach($authArray as $x => $x_value) {
if ($x == $_POST['user']) {
if (($x_value) == md5($_POST['pass'])) {
$_SESSION['login'] = true;
$_SESSION['user'] = $x;
header("Location: index.php");
}
}
}
if ( $_SESSION['login'] == false) {
//if no right key was found, it just comes here and executes that code
header("Location: login.html");
}
}
10 changes: 10 additions & 0 deletions php/foldersize.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
//return the size of the folder
function folderSize ($dir)
{
$size = 0;
foreach (glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $each) {
$size += is_file($each) ? filesize($each) : folderSize($each);
}
return $size;
}
15 changes: 15 additions & 0 deletions php/liveExec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
//executes the commmand that it was given and live outouts it to the FE
function liveExec($cmd) {
while (@ ob_end_flush());

$proc = popen($cmd, 'r');
while (!feof($proc))
{
echo "<p>";
echo fread($proc, 4096);
echo "</p>";
@ flush();
}
pclose($proc);
}
18 changes: 18 additions & 0 deletions php/loopAndPrint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
function loopAndPrint() {
//Loop through the created dir and list all files in there for download
if ($handle = opendir("./")) {
while (false !== ($file = readdir($handle))) {
if ('.' === $file) continue;
if ('..' === $file) continue;

echo '<div class="card">';
echo '<div class="card-body">';
echo '<p class="card-text">' . $file . '</p>';
echo '<a href="' . $_GET["folder"] . '/' . $file . '" class="btn btn-primary" download target="blank">' . Download . '</a>';
echo '</div>';
echo '</div>';
}
closedir($handle);
}
}
19 changes: 19 additions & 0 deletions php/rmOld.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
//Deletes all old Directorys older than $hours in the config
function rmOldDir($hours) {
if ($handle = opendir('./')) {
while (false !== ($dir = readdir($handle))) {
if ('.' === $dir) continue;
if ('..' === $dir) continue;

if (in_array($dir, $whiteListedFolders)) continue;

if (is_dir($dir)) {
if ($hours != 0 && ((time() - filemtime($dir)) > ($hours * (60 * 60)))) {
rrmdir($dir);
}
}
}
closedir($handle);
}
}
Loading

0 comments on commit 588d7e8

Please sign in to comment.