Check size before download
Add common.php with common functions
This commit is contained in:
parent
30cd0ba548
commit
f8d59cca32
270
common.php
Normal file
270
common.php
Normal file
@ -0,0 +1,270 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$user = "generic";
|
||||||
|
foreach ($_GET as $k => $t)
|
||||||
|
{
|
||||||
|
if (empty($t))
|
||||||
|
{
|
||||||
|
$user = $k;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!preg_match("#^[a-zA-Z0-9_]+$#", $user))
|
||||||
|
die ("Le nom d'utilisateur contient des caractères interdits.");
|
||||||
|
|
||||||
|
|
||||||
|
function get_info($url)
|
||||||
|
{
|
||||||
|
$ec = file(MAIN_DIR."/database",FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
||||||
|
$nbLign = count($ec);
|
||||||
|
|
||||||
|
for ($i = 0; $i < $nbLign; $i++)
|
||||||
|
{
|
||||||
|
if ($ec[$i] == $url)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while ($i < $nbLign && trim($ec[$i]) != "--")
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($i+2 < $nbLign)
|
||||||
|
{
|
||||||
|
if ($ec[$i+3] == "-- ")
|
||||||
|
{
|
||||||
|
@$vfilename = $ec[$i+2];
|
||||||
|
@$pic = "default.jpg";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
@$pic = $ec[$i+2];
|
||||||
|
@$vfilename = $ec[$i+3];
|
||||||
|
}
|
||||||
|
|
||||||
|
$mp3 = preg_replace("#^(.+)\.([a-zA-Z0-9]{1,4})$#",
|
||||||
|
'\1.mp3',
|
||||||
|
$vfilename);
|
||||||
|
$ogg = preg_replace("#^(.+)\.([a-zA-Z0-9]{1,4})$#",
|
||||||
|
'\1.ogg',
|
||||||
|
$vfilename);
|
||||||
|
|
||||||
|
return @array("url" => $ec[$i],
|
||||||
|
"title" => $ec[$i+1],
|
||||||
|
"pics" => $pic,
|
||||||
|
"filename" => $vfilename,
|
||||||
|
"mp3" => trim($mp3),
|
||||||
|
"ogg" => trim($ogg));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_url($user, $url)
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
preg_match("#^http://(www.)?youtube.com/watch\?v=([a-zA-Z0-9_-]+)#",
|
||||||
|
$url, $matched)
|
||||||
|
|| preg_match("#^http://youtu.be/([a-zA-Z0-9_-]+)#",
|
||||||
|
$url, $matched)
|
||||||
|
|| preg_match("#^http://(www.)?dailymotion.com/video/([a-zA-Z0-9_-]+)#",
|
||||||
|
$url, $matched)
|
||||||
|
|| preg_match("#^http://(www.)?vimeo.com/([0-9]+)#",
|
||||||
|
$url, $matched)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//Check if the URL isn't already in the file
|
||||||
|
if (is_file(MAIN_DIR."/users/".$user.".dlist"))
|
||||||
|
{
|
||||||
|
$content = file(MAIN_DIR."/users/".$user.".dlist",
|
||||||
|
FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||||
|
if (in_array($matched[0], $content))
|
||||||
|
{
|
||||||
|
print "<h3>Le fichier est déjà dans la liste d'attente.</h3>";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Is the file already downloaded by another user?
|
||||||
|
$video = get_info($matched[0]);
|
||||||
|
if (!empty($video))
|
||||||
|
{
|
||||||
|
$fp = fopen(MAIN_DIR."/users/".$user.".dlist.done", "a+");
|
||||||
|
fputs($fp, $matched[0]."\n");
|
||||||
|
fclose($fp);
|
||||||
|
print '<h3 style="color: #0000FF;">Vidéo déjà convertie...<meta http-equiv="refresh" content="2"></h3>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($fp = fopen(MAIN_DIR."/users/".$user.".dlist", "a+"))
|
||||||
|
{
|
||||||
|
fputs($fp, $matched[0]."\n");
|
||||||
|
fclose($fp);
|
||||||
|
print "<h3 style=\"color: #00FF00;\">L'adresse a bien été ajoutée avec succès.</h3>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
die("Une erreur s'est produite lors de l'ajout de la vidéo au fichier ; il s'agit sans doute d'un problème de droits. Contactez l'administrateur du site pour qu'il corrige le problème.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
print "<h3>L'adresse fournie n'est pas valide !</h3>";
|
||||||
|
}
|
||||||
|
|
||||||
|
function mark_as_dled($user, $key)
|
||||||
|
{
|
||||||
|
$dir = MAIN_DIR."/content/";
|
||||||
|
|
||||||
|
if (is_file(MAIN_DIR."/users/".$user.".dlist.done"))
|
||||||
|
{
|
||||||
|
$ec = file(MAIN_DIR."/users/".$user.".dlist.done",
|
||||||
|
FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||||
|
$outstr = "";
|
||||||
|
|
||||||
|
foreach ($ec as $k => $lign)
|
||||||
|
{
|
||||||
|
if ($key == $k)
|
||||||
|
{
|
||||||
|
preg_match("#^([^ ]+)( ([0-9]+))?#", $lign, $out);
|
||||||
|
|
||||||
|
if (empty($out[2]))
|
||||||
|
$outstr .= $lign." ".time()."\n";
|
||||||
|
else
|
||||||
|
$outstr .= $lign."\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$outstr .= $lign."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
file_put_contents(MAIN_DIR."/users/".$user.".dlist.done", $outstr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_dlmusiks($user)
|
||||||
|
{
|
||||||
|
$list = array();
|
||||||
|
|
||||||
|
$dir = MAIN_DIR."/content/";
|
||||||
|
|
||||||
|
if (is_file(MAIN_DIR."/users/".$user.".dlist.done"))
|
||||||
|
{
|
||||||
|
$ec = file(MAIN_DIR."/users/".$user.".dlist.done",
|
||||||
|
FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||||
|
|
||||||
|
foreach ($ec as $k => $lign)
|
||||||
|
{
|
||||||
|
preg_match("#^([^ ]+)( ([0-9]+))?#", $lign, $out);
|
||||||
|
|
||||||
|
if (empty($out[2]))
|
||||||
|
$out[2] = "0";
|
||||||
|
|
||||||
|
$musik = get_info($out[1]);
|
||||||
|
if(isset($musik)
|
||||||
|
&& (is_file($dir.'/'.$musik["mp3"])
|
||||||
|
|| is_file($dir.'/'.$musik["ogg"])))
|
||||||
|
{
|
||||||
|
$musik["dled"] = intval($out[2]);
|
||||||
|
$musik["k"] = $k;
|
||||||
|
$list[$k] = $musik;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_user_ready($user)
|
||||||
|
{
|
||||||
|
$list = array();
|
||||||
|
|
||||||
|
foreach (get_dlmusiks($user) as $k => $lign)
|
||||||
|
{
|
||||||
|
if (!$lign["dled"])
|
||||||
|
$list[$k] = $lign;
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_reverse($list);
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_user_archives($user)
|
||||||
|
{
|
||||||
|
$list = array();
|
||||||
|
$sort = array();
|
||||||
|
|
||||||
|
if ($user != "generic")
|
||||||
|
foreach (get_dlmusiks($user) as $k => $lign)
|
||||||
|
{
|
||||||
|
if ($lign["dled"])
|
||||||
|
{
|
||||||
|
$sort[] = $lign["dled"];
|
||||||
|
$list[$k] = $lign;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
array_multisort($sort, $list);
|
||||||
|
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_ecdl($user)
|
||||||
|
{
|
||||||
|
$list = array();
|
||||||
|
|
||||||
|
if (is_file(MAIN_DIR."/users/".$user.".dlist.ec"))
|
||||||
|
{
|
||||||
|
$ec = file(MAIN_DIR."/users/".$user.".dlist.ec",
|
||||||
|
FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||||
|
|
||||||
|
if (!empty($ec[0]))
|
||||||
|
{
|
||||||
|
$musik = get_info($ec[0]);
|
||||||
|
if(isset($musik))
|
||||||
|
{
|
||||||
|
if (!empty($musik["pics"]))
|
||||||
|
echo '<div style="text-align: center;"><img src="'.
|
||||||
|
$musik["pics"].'" alt="Miniature"></div>';
|
||||||
|
|
||||||
|
if (count ($ec) == 1)
|
||||||
|
echo "<label>En cours de téléchargement :</label>";
|
||||||
|
else if (count ($ec) == 2)
|
||||||
|
echo "<label>En cours de conversion :</label>";
|
||||||
|
|
||||||
|
echo $musik["title"];
|
||||||
|
$encours = $ec[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_file(MAIN_DIR."/users/".$user.".dlist"))
|
||||||
|
{
|
||||||
|
$ec = file(MAIN_DIR."/users/".$user.".dlist",
|
||||||
|
FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||||
|
|
||||||
|
foreach ($ec as $k => $lign)
|
||||||
|
{
|
||||||
|
if (isset($encours) && $lign == $encours)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$list[] = $lign;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
|
||||||
|
function format_clip($user, $m)
|
||||||
|
{
|
||||||
|
?>
|
||||||
|
<div class="clip">
|
||||||
|
<a href="dl.php?<?php echo $user; ?>&s&f=<?php echo $m["k"]; ?>"
|
||||||
|
class="tp"><br>Stream</a>
|
||||||
|
<a href="<?php echo $m["url"]; ?>" class="tp">Source</a>
|
||||||
|
<img src="<?php echo $m["pics"]; ?>"
|
||||||
|
alt="<?php echo $m["title"]; ?>"
|
||||||
|
title="<?php echo $m["title"]; ?>">
|
||||||
|
<a title="<?php echo $m["title"]; ?>" class="bot"
|
||||||
|
href="dl.php?<?php echo $user; ?>&f=<?php echo $m["k"]; ?>">
|
||||||
|
<?php echo $m["title"]; ?></a>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
44
dl.sh
44
dl.sh
@ -23,26 +23,34 @@ if [ ! -e /tmp/dlEnCours ]; then
|
|||||||
echo "-- " >> $f.done
|
echo "-- " >> $f.done
|
||||||
transmission-remote -AS
|
transmission-remote -AS
|
||||||
else
|
else
|
||||||
echo "$lign" >> $pwd/database
|
size=`$pwd/youtube-dl --skip-download http://www.youtube.com/watch?v=nh_hs-8_zF4 | grep "File size"`
|
||||||
$pwd/youtube-dl --get-title --get-thumbnail --get-filename "$lign" >> $pwd/database
|
if echo $size | grep -E " [1234]?[0-9]{2}\.[0-9]+M "
|
||||||
echo "-- " >> $pwd/database
|
then
|
||||||
|
echo "$lign" >> $pwd/database
|
||||||
|
|
||||||
echo "$lign" > $f.ec
|
$pwd/youtube-dl --get-title --get-thumbnail --get-filename "$lign" >> $pwd/database
|
||||||
$pwd/youtube-dl -c -o "$pwd/content/%(id)s.%(ext)s" "$lign"
|
echo "-- " >> $pwd/database
|
||||||
# $pwd/youtube-dl --no-progress -c -o "$pwd/content/%(id)s.%(ext)s" "$lign"
|
|
||||||
echo "$lign" >> $f.ec
|
echo "$lign" > $f.ec
|
||||||
echo "${f:$((${#pwd} + 7)):4}"
|
$pwd/youtube-dl -c -o "$pwd/content/%(id)s.%(ext)s" "$lign"
|
||||||
if [ "${f:$((${#pwd} + 7)):4}" == "nemu" ]; then
|
# $pwd/youtube-dl --no-progress -c -o "$pwd/content/%(id)s.%(ext)s" "$lign"
|
||||||
echo "nemu convertion"
|
echo "$lign" >> $f.ec
|
||||||
$pwd/youtube-dl --no-progress -c -k -o "$pwd/content/%(id)s.%(ext)s" --extract-audio --audio-format=vorbis "$lign"
|
echo "${f:$((${#pwd} + 7)):4}"
|
||||||
|
if [ "${f:$((${#pwd} + 7)):4}" == "nemu" ]; then
|
||||||
|
echo "nemu convertion"
|
||||||
|
$pwd/youtube-dl --no-progress -c -k -o "$pwd/content/%(id)s.%(ext)s" --extract-audio --audio-format=vorbis "$lign"
|
||||||
|
else
|
||||||
|
$pwd/youtube-dl --no-progress -c -k -o "$pwd/content/%(id)s.%(ext)s" --extract-audio --audio-format=mp3 "$lign"
|
||||||
|
fi
|
||||||
|
echo "" > $f.ec
|
||||||
|
|
||||||
|
echo "$lign" >> $f.done
|
||||||
|
|
||||||
|
chown www-data:www-data $f.done $f.ec
|
||||||
else
|
else
|
||||||
$pwd/youtube-dl --no-progress -c -k -o "$pwd/content/%(id)s.%(ext)s" --extract-audio --audio-format=mp3 "$lign"
|
echo $size
|
||||||
fi
|
fi
|
||||||
echo "" > $f.ec
|
fi
|
||||||
|
|
||||||
echo "$lign" >> $f.done
|
|
||||||
fi
|
|
||||||
|
|
||||||
#Remove the action from the file
|
#Remove the action from the file
|
||||||
sed -i '1d' $f
|
sed -i '1d' $f
|
||||||
|
|
||||||
|
@ -2,48 +2,9 @@
|
|||||||
|
|
||||||
define("MAIN_DIR", __dir__."/..");
|
define("MAIN_DIR", __dir__."/..");
|
||||||
|
|
||||||
function get_info($url)
|
require(MAIN_DIR."/common.php");
|
||||||
{
|
|
||||||
$ec = file(MAIN_DIR."/database",FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
|
||||||
$nbLign = count($ec);
|
|
||||||
|
|
||||||
for ($i = 0; $i < $nbLign; $i++)
|
//header("Content-type: application/atom+xml;charset=utf-8");
|
||||||
{
|
|
||||||
if ($ec[$i] == $url)
|
|
||||||
break;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while ($i < $nbLign && trim($ec[$i]) != "--")
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($i+2 < $nbLign)
|
|
||||||
{
|
|
||||||
if ($ec[$i+3] == "-- ")
|
|
||||||
@$filename = preg_replace("#^(.+)\.([a-zA-Z0-9]{1,4})$#", '\1.mp3', $ec[$i+2]);
|
|
||||||
else
|
|
||||||
@$filename = preg_replace("#^(.+)\.([a-zA-Z0-9]{1,4})$#", '\1.mp3', $ec[$i+3]);
|
|
||||||
@$filenameogg = preg_replace("#^(.+)\.([a-zA-Z0-9]{1,4})$#", '\1.ogg', $filename);
|
|
||||||
return @array($ec[$i], $ec[$i+1], $ec[$i+2], $ec[$i+3], trim($filename), trim($filenameogg));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
$user = "generic";
|
|
||||||
foreach ($_GET as $k => $t)
|
|
||||||
{
|
|
||||||
if (empty($t))
|
|
||||||
{
|
|
||||||
$user = $k;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!preg_match("#^[a-zA-Z0-9_]+$#", $user))
|
|
||||||
die ("Le nom d'utilisateur contient des caractères interdits.");
|
|
||||||
|
|
||||||
header("Content-type: application/atom+xml;charset=utf-8");
|
|
||||||
|
|
||||||
$xml = new DOMDocument('1.0', 'UTF-8');
|
$xml = new DOMDocument('1.0', 'UTF-8');
|
||||||
$xml->formatOutput = true;
|
$xml->formatOutput = true;
|
||||||
@ -70,33 +31,32 @@ $xml_feed->appendChild($xml_feed_rights);
|
|||||||
$xml_feed->appendChild($xml_feed_author);
|
$xml_feed->appendChild($xml_feed_author);
|
||||||
|
|
||||||
$files = array();
|
$files = array();
|
||||||
if (is_file(MAIN_DIR."/users/".$user.".dlist.done"))
|
|
||||||
|
$ec = get_dlmusiks($user);
|
||||||
|
$cnt = 0;
|
||||||
|
for ($i = count ($ec) - 1; $i >= 0 && $cnt < 10; $i--, $cnt++)
|
||||||
{
|
{
|
||||||
$ec = file(MAIN_DIR."/users/".$user.".dlist.done",FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
$musik = $ec[$i];
|
||||||
$cnt = 0;
|
if (isset($musik) && (is_file (MAIN_DIR."/content/".$musik["mp3"]) || is_file (MAIN_DIR."/content/".$musik["ogg"])))
|
||||||
for ($i = count ($ec) - 1; $i >= 0 && $cnt < 10; $i--, $cnt++)
|
|
||||||
{
|
|
||||||
$musik = get_info($ec[$i]);
|
|
||||||
if (isset($musik) && (is_file (MAIN_DIR."/content/".$musik[4]) || is_file (MAIN_DIR."/content/".$musik[5])))
|
|
||||||
{
|
{
|
||||||
$xml_entry = $xml->createElement("entry");
|
$xml_entry = $xml->createElement("entry");
|
||||||
$xml_entry->appendChild($xml->createElement("id", "http://musik.p0m.fr/".$musik[0]));
|
$xml_entry->appendChild($xml->createElement("id", "http://musik.p0m.fr/".$musik["filename"]));
|
||||||
@$xml_entry->appendChild($xml->createElement("title", strip_tags($musik[1])));
|
@$xml_entry->appendChild($xml->createElement("title", strip_tags($musik["title"])));
|
||||||
if (is_file (MAIN_DIR."/content/".$musik[5]))
|
if (is_file (MAIN_DIR."/content/".$musik["ogg"]))
|
||||||
$xml_entry->appendChild($xml->createElement("updated", date('c', filectime(MAIN_DIR."/content/".$musik[5]))));
|
$xml_entry->appendChild($xml->createElement("updated", date('c', filectime(MAIN_DIR."/content/".$musik["ogg"]))));
|
||||||
else
|
else
|
||||||
$xml_entry->appendChild($xml->createElement("updated", date('c', filectime(MAIN_DIR."/content/".$musik[4]))));
|
$xml_entry->appendChild($xml->createElement("updated", date('c', filectime(MAIN_DIR."/content/".$musik["mp3"]))));
|
||||||
|
|
||||||
$xml_entry_summary = $xml->createElement("summary", htmlentities(utf8_decode($musik[2])));
|
$xml_entry_summary = $xml->createElement("summary", htmlentities(utf8_decode($musik["title"])));
|
||||||
$xml_entry_summary->setAttribute("type", "html");
|
$xml_entry_summary->setAttribute("type", "html");
|
||||||
|
|
||||||
$xml_entry_enclosure = $xml_entry->appendChild($xml->createElement("link"));
|
$xml_entry_enclosure = $xml_entry->appendChild($xml->createElement("link"));
|
||||||
$xml_entry_enclosure->setAttribute("href", "http://".$_SERVER["SERVER_NAME"].dirname($_SERVER["REQUEST_URI"]).urlencode("dl.php?".$user."&f=".$i));
|
$xml_entry_enclosure->setAttribute("href", "http://".$_SERVER["SERVER_NAME"].dirname($_SERVER["REQUEST_URI"]).urlencode("dl.php?".$user."&s&f=".$i));
|
||||||
$xml_entry_enclosure->setAttribute("rel", "enclosure");
|
$xml_entry_enclosure->setAttribute("rel", "enclosure");
|
||||||
$xml_entry->appendChild($xml_entry_enclosure);
|
$xml_entry->appendChild($xml_entry_enclosure);
|
||||||
|
|
||||||
$xml_entry_enclosure = $xml_entry->appendChild($xml->createElement("link"));
|
$xml_entry_enclosure = $xml_entry->appendChild($xml->createElement("link"));
|
||||||
$xml_entry_enclosure->setAttribute("href", $musik[0]);
|
$xml_entry_enclosure->setAttribute("href", $musik["url"]);
|
||||||
$xml_entry_enclosure->setAttribute("rel", "via");
|
$xml_entry_enclosure->setAttribute("rel", "via");
|
||||||
$xml_entry->appendChild($xml_entry_enclosure);
|
$xml_entry->appendChild($xml_entry_enclosure);
|
||||||
|
|
||||||
@ -109,7 +69,7 @@ if (is_file(MAIN_DIR."/users/".$user.".dlist.done"))
|
|||||||
$xml_feed->appendChild($xml_entry);
|
$xml_feed->appendChild($xml_entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$xml->appendChild($xml_feed);
|
$xml->appendChild($xml_feed);
|
||||||
|
|
||||||
|
BIN
htdocs/default.jpg
Normal file
BIN
htdocs/default.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
104
htdocs/dl.php
104
htdocs/dl.php
@ -1,80 +1,54 @@
|
|||||||
<?php
|
<?php
|
||||||
define("MAIN_DIR", __dir__."/..");
|
define("MAIN_DIR", __dir__."/..");
|
||||||
|
|
||||||
function get_info($url)
|
require(MAIN_DIR."/common.php");
|
||||||
{
|
|
||||||
$ec = file(MAIN_DIR."/database",FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
|
||||||
$nbLign = count($ec);
|
|
||||||
|
|
||||||
for ($i = 0; $i < $nbLign; $i++)
|
|
||||||
{
|
|
||||||
if ($ec[$i] == $url)
|
|
||||||
break;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while ($i < $nbLign && trim($ec[$i]) != "--")
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($i+2 < $nbLign)
|
|
||||||
{
|
|
||||||
if ($ec[$i+3] == "-- ")
|
|
||||||
@$filename = preg_replace("#^(.+)\.([a-zA-Z0-9]{1,4})$#", '\1.mp3', $ec[$i+2]);
|
|
||||||
else
|
|
||||||
@$filename = preg_replace("#^(.+)\.([a-zA-Z0-9]{1,4})$#", '\1.mp3', $ec[$i+3]);
|
|
||||||
@$filenameogg = preg_replace("#^(.+)\.([a-zA-Z0-9]{1,4})$#", '\1.ogg', $filename);
|
|
||||||
return @array($ec[$i], $ec[$i+1], $ec[$i+2], $ec[$i+3], trim($filename), trim($filenameogg));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
$user = "generic";
|
|
||||||
foreach ($_GET as $k => $t)
|
|
||||||
{
|
|
||||||
if (empty($t))
|
|
||||||
{
|
|
||||||
$user = $k;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!preg_match("#^[a-zA-Z0-9_]+$#", $user))
|
|
||||||
die ("Le nom d'utilisateur contient des caractères interdits.");
|
|
||||||
|
|
||||||
|
if (isset($_GET["s"]))
|
||||||
|
$stream = "inline";
|
||||||
|
else
|
||||||
|
$stream = "attachment";
|
||||||
|
|
||||||
if (isset($_GET["f"]))
|
if (isset($_GET["f"]))
|
||||||
{
|
{
|
||||||
if (is_file(MAIN_DIR."/users/".$user.".dlist.done"))
|
$musiks = get_dlmusiks($user);
|
||||||
|
|
||||||
|
foreach ($musiks as $k => $lign)
|
||||||
{
|
{
|
||||||
$ec = file(MAIN_DIR."/users/".$user.".dlist.done",FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
if ($k == $_GET["f"])
|
||||||
|
|
||||||
foreach ($ec as $k => $lign)
|
|
||||||
{
|
{
|
||||||
if ($k == $_GET["f"])
|
$musik = get_info($lign["url"]);
|
||||||
|
if (isset($musik) && (is_file(MAIN_DIR."/content/".$musik["mp3"])
|
||||||
|
|| is_file(MAIN_DIR."/content/".$musik["ogg"])))
|
||||||
{
|
{
|
||||||
$musik = get_info($lign);
|
if (is_file(MAIN_DIR."/content/".$musik["ogg"]))
|
||||||
if (isset($musik) && (is_file(MAIN_DIR."/content/".$musik[4]) || is_file(MAIN_DIR."/content/".$musik[5])))
|
|
||||||
{
|
{
|
||||||
if (is_file(MAIN_DIR."/content/".$musik[5]))
|
$filename = MAIN_DIR."/content/".$musik["ogg"];
|
||||||
$filename = MAIN_DIR."/content/".$musik[5];
|
$ext = ".ogg";
|
||||||
else
|
|
||||||
$filename = MAIN_DIR."/content/".$musik[4];
|
|
||||||
|
|
||||||
header('Content-Description: File Transfer');
|
|
||||||
header('Content-Type: application/octet-stream');
|
|
||||||
if (is_file(MAIN_DIR."/content/".$musik[5]))
|
|
||||||
header("Content-Disposition: attachment; filename=\"".$musik[1].".ogg\"");
|
|
||||||
else
|
|
||||||
header("Content-Disposition: attachment; filename=\"".$musik[1].".mp3\"");
|
|
||||||
header('Content-Transfer-Encoding: binary');
|
|
||||||
header('Expires: 0');
|
|
||||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
|
||||||
header('Pragma: public');
|
|
||||||
header('Content-Length: ' . filesize($filename));
|
|
||||||
readfile($filename);
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$filename = MAIN_DIR."/content/".$musik["mp3"];
|
||||||
|
$ext = ".mp3";
|
||||||
|
}
|
||||||
|
|
||||||
|
//Mark file as dled
|
||||||
|
mark_as_dled($user, $k);
|
||||||
|
|
||||||
|
if (is_file(MAIN_DIR."/content/".$musik["ogg"]))
|
||||||
|
$fname = MAIN_DIR."/content/".$musik["ogg"];
|
||||||
|
else
|
||||||
|
$fname = MAIN_DIR."/content/".$musik["mp3"];
|
||||||
|
|
||||||
|
header('Content-Description: File Transfer');
|
||||||
|
header('Content-Type: '.mime_content_type($filename));
|
||||||
|
header("Content-Disposition: ".$stream."; filename=\"".addslashes($musik["title"]).$ext."\"");
|
||||||
|
header('Content-Transfer-Encoding: binary');
|
||||||
|
//header('Expires: 0');
|
||||||
|
//header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||||
|
header('Pragma: public');
|
||||||
|
header('Content-Length: ' . filesize($filename));
|
||||||
|
readfile($filename);
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
173
htdocs/index.php
173
htdocs/index.php
@ -2,48 +2,9 @@
|
|||||||
|
|
||||||
define("MAIN_DIR", __dir__."/..");
|
define("MAIN_DIR", __dir__."/..");
|
||||||
|
|
||||||
function get_info($url)
|
|
||||||
{
|
|
||||||
$ec = file(MAIN_DIR."/database",FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
|
||||||
$nbLign = count($ec);
|
|
||||||
|
|
||||||
for ($i = 0; $i < $nbLign; $i++)
|
|
||||||
{
|
|
||||||
if ($ec[$i] == $url)
|
|
||||||
break;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while ($i < $nbLign && trim($ec[$i]) != "--")
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($i+2 < $nbLign)
|
|
||||||
{
|
|
||||||
if ($ec[$i+3] == "-- ")
|
|
||||||
@$filename = preg_replace("#^(.+)\.([a-zA-Z0-9]{1,4})$#", '\1.mp3', $ec[$i+2]);
|
|
||||||
else
|
|
||||||
@$filename = preg_replace("#^(.+)\.([a-zA-Z0-9]{1,4})$#", '\1.mp3', $ec[$i+3]);
|
|
||||||
@$filenameogg = preg_replace("#^(.+)\.([a-zA-Z0-9]{1,4})$#", '\1.ogg', $filename);
|
|
||||||
return @array($ec[$i], $ec[$i+1], $ec[$i+2], $ec[$i+3], trim($filename), trim($filenameogg));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
header("Content-type: text/html;charset=utf-8");
|
header("Content-type: text/html;charset=utf-8");
|
||||||
|
|
||||||
$user = "generic";
|
require(MAIN_DIR."/common.php");
|
||||||
foreach ($_GET as $k => $t)
|
|
||||||
{
|
|
||||||
if (empty($t))
|
|
||||||
{
|
|
||||||
$user = $k;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!preg_match("#^[a-zA-Z0-9_]+$#", $user))
|
|
||||||
die ("Le nom d'utilisateur contient des caractères interdits.");
|
|
||||||
?>
|
?>
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
@ -57,33 +18,23 @@ if (!preg_match("#^[a-zA-Z0-9_]+$#", $user))
|
|||||||
<body>
|
<body>
|
||||||
<div class="blk">
|
<div class="blk">
|
||||||
<h2>Chansons prêtes à être téléchargées</h2>
|
<h2>Chansons prêtes à être téléchargées</h2>
|
||||||
<ul><?php
|
<div class="dled"><?php
|
||||||
$dir = MAIN_DIR."/content/";
|
$list_ready = get_user_ready($user);
|
||||||
|
if (count($list_ready))
|
||||||
$someone = false;
|
|
||||||
if (is_file(MAIN_DIR."/users/".$user.".dlist.done"))
|
|
||||||
{
|
{
|
||||||
$ec = file(MAIN_DIR."/users/".$user.".dlist.done",FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
foreach ($list_ready as $m)
|
||||||
|
format_clip($user, $m);
|
||||||
foreach ($ec as $k => $lign)
|
|
||||||
{
|
|
||||||
$musik = get_info($lign);
|
|
||||||
if(isset($musik) && (is_file($dir.'/'.$musik[4]) || is_file($dir.'/'.$musik[5])))
|
|
||||||
{
|
|
||||||
$someone = true;
|
|
||||||
echo '<li><a href="dl.php?'.$user.'&f='.$k.'">'.$musik[1].'</a></li>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (empty($someone))
|
echo "<h3>Pas de nouvelle chanson à télécharger</h3>";
|
||||||
echo "<h3>Aucun élément dans cette liste</h3>";
|
?> </div>
|
||||||
?> </ul>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="blk">
|
<div class="blk">
|
||||||
<h2>Ajouter une chanson</h2>
|
<h2>Ajouter une chanson</h2>
|
||||||
<?php
|
<?php
|
||||||
if ((!empty($_GET["a"]) && $_GET["a"] == "add" && (!empty($_POST["url"]) || !empty($_SERVER["HTTP_REFERER"]))) || !empty($_GET["url"]))
|
if ((!empty($_GET["a"]) && $_GET["a"] == "add"
|
||||||
|
&& (!empty($_POST["url"]) || !empty($_SERVER["HTTP_REFERER"])))
|
||||||
|
|| !empty($_GET["url"]))
|
||||||
{
|
{
|
||||||
if (!empty($_GET["url"]))
|
if (!empty($_GET["url"]))
|
||||||
$url = $_GET["url"];
|
$url = $_GET["url"];
|
||||||
@ -91,35 +42,7 @@ if (empty($someone))
|
|||||||
$url = $_POST["url"];
|
$url = $_POST["url"];
|
||||||
else
|
else
|
||||||
$url = $_SERVER["HTTP_REFERER"];
|
$url = $_SERVER["HTTP_REFERER"];
|
||||||
|
add_url($user, $url);
|
||||||
if ($url == "clear")
|
|
||||||
{
|
|
||||||
if ($fp = fopen(MAIN_DIR."/users/".$user.".dlist", "a+"))
|
|
||||||
{
|
|
||||||
fputs($fp, "clear\n");
|
|
||||||
print "<h3 style=\"color: #00FF00;\">La demande de vidage de la liste a été ajouté à la file d'attente</h3>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elseif (
|
|
||||||
preg_match("#^http://(www.)?youtube.com/watch\?v=([a-zA-Z0-9_-]+)#", $url, $matched)
|
|
||||||
|| preg_match("#^http://youtu.be/([a-zA-Z0-9_-]+)#", $url, $matched)
|
|
||||||
|| preg_match("#^http://(www.)?dailymotion.com/video/([a-zA-Z0-9_-]+)#", $url, $matched)
|
|
||||||
|| preg_match("#^http://(www.)?vimeo.com/([0-9]+)#", $url, $matched)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//Check if the URL isn't already in the file
|
|
||||||
if (is_file(MAIN_DIR."/users/".$user.".dlist"))
|
|
||||||
$content = file(MAIN_DIR."/users/".$user.".dlist",FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
|
||||||
else
|
|
||||||
$content = array();
|
|
||||||
if (!in_array($matched[0], $content) && $fp = fopen(MAIN_DIR."/users/".$user.".dlist", "a+"))
|
|
||||||
{
|
|
||||||
fputs($fp, $matched[0]."\n");
|
|
||||||
print "<h3 style=\"color: #00FF00;\">L'adresse a bien été ajoutée avec succès.</h3>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
print "<h3>L'adresse fournie n'est pas valide !</h3>";
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<form method="post" action="?a=add&<?php echo $user; ?>">
|
<form method="post" action="?a=add&<?php echo $user; ?>">
|
||||||
@ -131,55 +54,33 @@ if (empty($someone))
|
|||||||
<h2>Chansons en file d'attente</h2>
|
<h2>Chansons en file d'attente</h2>
|
||||||
<form method="post" action="?a=del">
|
<form method="post" action="?a=del">
|
||||||
<ul><?php
|
<ul><?php
|
||||||
$someone = false;
|
$ecdl = get_ecdl($user);
|
||||||
if (is_file(MAIN_DIR."/users/".$user.".dlist.ec"))
|
foreach($ecdl as $lign)
|
||||||
{
|
{
|
||||||
$ec = file(MAIN_DIR."/users/".$user.".dlist.ec",FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
echo '<li>'.$lign.' <input type="submit" name="del'.
|
||||||
|
sha1($lign).'" value="Retirer de la liste"></li>';
|
||||||
if (!empty($ec[0]))
|
|
||||||
{
|
|
||||||
$musik = get_info($ec[0]);
|
|
||||||
if(isset($musik))
|
|
||||||
{
|
|
||||||
echo '<div style="text-align: center;"><img src="'.$musik[2].'" alt="Miniature"></div>';
|
|
||||||
|
|
||||||
if (count ($ec) == 1)
|
|
||||||
echo "<label>En cours de téléchargement :</label>";
|
|
||||||
else if (count ($ec) == 2)
|
|
||||||
echo "<label>En cours de conversion :</label>";
|
|
||||||
|
|
||||||
echo $musik[1];
|
|
||||||
$encours = $ec[0];
|
|
||||||
$someone = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (is_file(MAIN_DIR."/users/".$user.".dlist"))
|
if (empty($ecdl))
|
||||||
{
|
|
||||||
$ec = file(MAIN_DIR."/users/".$user.".dlist",FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
|
||||||
|
|
||||||
foreach ($ec as $k => $lign)
|
|
||||||
{
|
|
||||||
if (isset($encours) && $lign == $encours)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
$someone = true;
|
|
||||||
$musik = get_info($lign);
|
|
||||||
if(isset($musik) && is_file($dir.'/'.$musik[4]))
|
|
||||||
echo '<li>'.$musik[1].'</li>';
|
|
||||||
else
|
|
||||||
echo '<li>'.$lign.' <input type="submit" name="del'.sha1($lign).'" value="Retirer de la liste"></li>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($someone))
|
|
||||||
echo "<h3>Aucun élément dans cette liste</h3>";
|
echo "<h3>Aucun élément dans cette liste</h3>";
|
||||||
?></ul>
|
?></ul>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div><?php
|
||||||
<div class="blk">
|
$list_archives = get_user_archives($user);
|
||||||
<h2>Chansons déjà téléchargées</h2>
|
if (count($list_archives))
|
||||||
<h3>Prochainement ...</h3>
|
{
|
||||||
</div>
|
print '<div class="blk"><h2>Chansons déjà téléchargées</h2><div class="dled">';
|
||||||
</body>
|
$last = 0;
|
||||||
|
foreach ($list_archives as $m)
|
||||||
|
{
|
||||||
|
$ths = intval($m["dled"] / 21600);
|
||||||
|
if ($last < $ths)
|
||||||
|
{
|
||||||
|
$last = $ths;
|
||||||
|
echo "<h4>".strftime("%a. %d %b %G - %H:%M", $m["dled"])."</h4>";
|
||||||
|
}
|
||||||
|
format_clip($user, $m);
|
||||||
|
}
|
||||||
|
print '</div></div>';
|
||||||
|
}
|
||||||
|
?></body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -55,7 +55,7 @@ label:hover {
|
|||||||
input[type=text], input[type=password], select, textarea {
|
input[type=text], input[type=password], select, textarea {
|
||||||
transition: background 0.75s;
|
transition: background 0.75s;
|
||||||
-moz-transition: background 0.75s;
|
-moz-transition: background 0.75s;
|
||||||
-webkit-transition: background 0.75s;
|
-webkit-transition: background 0.75s;
|
||||||
-o-transition: background 0.75s;
|
-o-transition: background 0.75s;
|
||||||
}
|
}
|
||||||
input, select, textarea {
|
input, select, textarea {
|
||||||
@ -107,6 +107,10 @@ div.blk {
|
|||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
padding-bottom: 15px;
|
padding-bottom: 15px;
|
||||||
}
|
}
|
||||||
|
div.blk .dled {
|
||||||
|
margin-top: -15px;
|
||||||
|
padding: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
.blk h2 {
|
.blk h2 {
|
||||||
background: #88DE66;
|
background: #88DE66;
|
||||||
@ -117,7 +121,7 @@ div.blk {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
transition: color 1s;
|
transition: color 1s;
|
||||||
-moz-transition: color 1s;
|
-moz-transition: color 1s;
|
||||||
-webkit-transition: color 1s;
|
-webkit-transition: color 1s;
|
||||||
-o-transition: color 1s;
|
-o-transition: color 1s;
|
||||||
}
|
}
|
||||||
.blk:hover h2 {
|
.blk:hover h2 {
|
||||||
@ -163,4 +167,30 @@ ins
|
|||||||
del
|
del
|
||||||
{
|
{
|
||||||
color: #DF2200;
|
color: #DF2200;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.clip
|
||||||
|
{
|
||||||
|
display: inline-block;
|
||||||
|
margin: 9px 1.5px;
|
||||||
|
text-align: center;
|
||||||
|
width: 19%;
|
||||||
|
}
|
||||||
|
div.clip a.bot
|
||||||
|
{
|
||||||
|
display: block;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
div.clip a.tp
|
||||||
|
{
|
||||||
|
color: white;
|
||||||
|
display: none;
|
||||||
|
margin-left: 12px;
|
||||||
|
position: absolute;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
div.clip:hover a.tp
|
||||||
|
{
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
62
youtube-dl
62
youtube-dl
@ -15,6 +15,7 @@ __authors__ = (
|
|||||||
'Kevin Ngo',
|
'Kevin Ngo',
|
||||||
'Ori Avtalion',
|
'Ori Avtalion',
|
||||||
'shizeeg',
|
'shizeeg',
|
||||||
|
'Filippo Valsorda',
|
||||||
)
|
)
|
||||||
|
|
||||||
__license__ = 'Public Domain'
|
__license__ = 'Public Domain'
|
||||||
@ -849,27 +850,26 @@ class FileDownloader(object):
|
|||||||
self.trouble(u'ERROR: Cannot write metadata to JSON file ' + infofn)
|
self.trouble(u'ERROR: Cannot write metadata to JSON file ' + infofn)
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.params.get('skip_download', False):
|
if self.params.get('nooverwrites', False) and os.path.exists(_encodeFilename(filename)):
|
||||||
if self.params.get('nooverwrites', False) and os.path.exists(_encodeFilename(filename)):
|
success = True
|
||||||
success = True
|
else:
|
||||||
else:
|
try:
|
||||||
try:
|
success = self._do_download(filename, info_dict)
|
||||||
success = self._do_download(filename, info_dict)
|
except (OSError, IOError), err:
|
||||||
except (OSError, IOError), err:
|
raise UnavailableVideoError
|
||||||
raise UnavailableVideoError
|
except (urllib2.URLError, httplib.HTTPException, socket.error), err:
|
||||||
except (urllib2.URLError, httplib.HTTPException, socket.error), err:
|
self.trouble(u'ERROR: unable to download video data: %s' % str(err))
|
||||||
self.trouble(u'ERROR: unable to download video data: %s' % str(err))
|
return
|
||||||
return
|
except (ContentTooShortError, ), err:
|
||||||
except (ContentTooShortError, ), err:
|
self.trouble(u'ERROR: content too short (expected %s bytes and served %s)' % (err.expected, err.downloaded))
|
||||||
self.trouble(u'ERROR: content too short (expected %s bytes and served %s)' % (err.expected, err.downloaded))
|
return
|
||||||
return
|
|
||||||
|
if success:
|
||||||
if success:
|
try:
|
||||||
try:
|
self.post_process(filename, info_dict)
|
||||||
self.post_process(filename, info_dict)
|
except (PostProcessingError), err:
|
||||||
except (PostProcessingError), err:
|
self.trouble(u'ERROR: postprocessing: %s' % str(err))
|
||||||
self.trouble(u'ERROR: postprocessing: %s' % str(err))
|
return
|
||||||
return
|
|
||||||
|
|
||||||
def download(self, url_list):
|
def download(self, url_list):
|
||||||
"""Download a given list of URLs."""
|
"""Download a given list of URLs."""
|
||||||
@ -1038,6 +1038,9 @@ class FileDownloader(object):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
data_len = data.info().get('Content-length', None)
|
data_len = data.info().get('Content-length', None)
|
||||||
|
self.to_screen(u'[info] File size: ' + self.format_bytes(data_len) + ' bytes')
|
||||||
|
if self.params.get('skip_download', False):
|
||||||
|
return True;
|
||||||
if data_len is not None:
|
if data_len is not None:
|
||||||
data_len = long(data_len) + resume_len
|
data_len = long(data_len) + resume_len
|
||||||
data_len_str = self.format_bytes(data_len)
|
data_len_str = self.format_bytes(data_len)
|
||||||
@ -1177,8 +1180,8 @@ class YoutubeIE(InfoExtractor):
|
|||||||
_AGE_URL = 'http://www.youtube.com/verify_age?next_url=/&gl=US&hl=en'
|
_AGE_URL = 'http://www.youtube.com/verify_age?next_url=/&gl=US&hl=en'
|
||||||
_NETRC_MACHINE = 'youtube'
|
_NETRC_MACHINE = 'youtube'
|
||||||
# Listed in order of quality
|
# Listed in order of quality
|
||||||
_available_formats = ['38', '37', '22', '45', '35', '44', '34', '18', '43', '6', '5', '17', '13']
|
_available_formats = ['38', '37', '46', '22', '45', '35', '44', '34', '18', '43', '6', '5', '17', '13']
|
||||||
_available_formats_prefer_free = ['38', '37', '45', '22', '44', '35', '43', '34', '18', '6', '5', '17', '13']
|
_available_formats_prefer_free = ['38', '46', '37', '45', '22', '44', '35', '43', '34', '18', '6', '5', '17', '13']
|
||||||
_video_extensions = {
|
_video_extensions = {
|
||||||
'13': '3gp',
|
'13': '3gp',
|
||||||
'17': 'mp4',
|
'17': 'mp4',
|
||||||
@ -1189,6 +1192,7 @@ class YoutubeIE(InfoExtractor):
|
|||||||
'43': 'webm',
|
'43': 'webm',
|
||||||
'44': 'webm',
|
'44': 'webm',
|
||||||
'45': 'webm',
|
'45': 'webm',
|
||||||
|
'46': 'webm',
|
||||||
}
|
}
|
||||||
_video_dimensions = {
|
_video_dimensions = {
|
||||||
'5': '240x400',
|
'5': '240x400',
|
||||||
@ -1204,6 +1208,7 @@ class YoutubeIE(InfoExtractor):
|
|||||||
'43': '360x640',
|
'43': '360x640',
|
||||||
'44': '480x854',
|
'44': '480x854',
|
||||||
'45': '720x1280',
|
'45': '720x1280',
|
||||||
|
'46': '1080x1920',
|
||||||
}
|
}
|
||||||
IE_NAME = u'youtube'
|
IE_NAME = u'youtube'
|
||||||
|
|
||||||
@ -3093,14 +3098,14 @@ class BlipTVIE(InfoExtractor):
|
|||||||
data = json_data['Post']
|
data = json_data['Post']
|
||||||
else:
|
else:
|
||||||
data = json_data
|
data = json_data
|
||||||
|
|
||||||
upload_date = datetime.datetime.strptime(data['datestamp'], '%m-%d-%y %H:%M%p').strftime('%Y%m%d')
|
upload_date = datetime.datetime.strptime(data['datestamp'], '%m-%d-%y %H:%M%p').strftime('%Y%m%d')
|
||||||
video_url = data['media']['url']
|
video_url = data['media']['url']
|
||||||
umobj = re.match(self._URL_EXT, video_url)
|
umobj = re.match(self._URL_EXT, video_url)
|
||||||
if umobj is None:
|
if umobj is None:
|
||||||
raise ValueError('Can not determine filename extension')
|
raise ValueError('Can not determine filename extension')
|
||||||
ext = umobj.group(1)
|
ext = umobj.group(1)
|
||||||
|
|
||||||
info = {
|
info = {
|
||||||
'id': data['item_id'],
|
'id': data['item_id'],
|
||||||
'url': video_url,
|
'url': video_url,
|
||||||
@ -3201,7 +3206,7 @@ class ComedyCentralIE(InfoExtractor):
|
|||||||
|
|
||||||
def report_extraction(self, episode_id):
|
def report_extraction(self, episode_id):
|
||||||
self._downloader.to_screen(u'[comedycentral] %s: Extracting information' % episode_id)
|
self._downloader.to_screen(u'[comedycentral] %s: Extracting information' % episode_id)
|
||||||
|
|
||||||
def report_config_download(self, episode_id):
|
def report_config_download(self, episode_id):
|
||||||
self._downloader.to_screen(u'[comedycentral] %s: Downloading configuration' % episode_id)
|
self._downloader.to_screen(u'[comedycentral] %s: Downloading configuration' % episode_id)
|
||||||
|
|
||||||
@ -3763,7 +3768,6 @@ class MixcloudIE(InfoExtractor):
|
|||||||
url_list = jsonData[fmt][bitrate]
|
url_list = jsonData[fmt][bitrate]
|
||||||
except TypeError: # we have no bitrate info.
|
except TypeError: # we have no bitrate info.
|
||||||
url_list = jsonData[fmt]
|
url_list = jsonData[fmt]
|
||||||
|
|
||||||
return url_list
|
return url_list
|
||||||
|
|
||||||
def check_urls(self, url_list):
|
def check_urls(self, url_list):
|
||||||
@ -3883,7 +3887,7 @@ class StanfordOpenClassroomIE(InfoExtractor):
|
|||||||
info = {
|
info = {
|
||||||
'id': _simplify_title(course + '_' + video),
|
'id': _simplify_title(course + '_' + video),
|
||||||
}
|
}
|
||||||
|
|
||||||
self.report_extraction(info['id'])
|
self.report_extraction(info['id'])
|
||||||
baseUrl = 'http://openclassroom.stanford.edu/MainFolder/courses/' + course + '/videos/'
|
baseUrl = 'http://openclassroom.stanford.edu/MainFolder/courses/' + course + '/videos/'
|
||||||
xmlUrl = baseUrl + video + '.xml'
|
xmlUrl = baseUrl + video + '.xml'
|
||||||
@ -4688,7 +4692,7 @@ def _real_main():
|
|||||||
parser.error(u'you must provide at least one URL')
|
parser.error(u'you must provide at least one URL')
|
||||||
else:
|
else:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
retcode = fd.download(all_urls)
|
retcode = fd.download(all_urls)
|
||||||
except MaxDownloadsReached:
|
except MaxDownloadsReached:
|
||||||
|
Reference in New Issue
Block a user