Handle download lists part 1

This commit is contained in:
Uli Koeth 2017-03-07 17:24:34 +01:00
parent c9341acfb9
commit 03cf506132
3 changed files with 89 additions and 81 deletions

View file

@ -113,7 +113,14 @@ class VideoDownload
* */ * */
public function getJSON($url, $format = null, $password = null) public function getJSON($url, $format = null, $password = null)
{ {
return json_decode($this->getProp($url, $format, 'dump-json', $password)); $jsonArray = preg_split( "/\r|\n/", $this->getProp($url, $format, 'dump-json', $password), -1,
PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
$decodedJson = array();
foreach ($jsonArray as $oneJson)
{
array_push($decodedJson, json_decode($oneJson));
}
return $decodedJson;
} }
/** /**

View file

@ -1,5 +1,4 @@
<?php <?php
require_once __DIR__.'/vendor/autoload.php'; require_once __DIR__.'/vendor/autoload.php';
use Alltube\Config; use Alltube\Config;
use Alltube\Controller\FrontController; use Alltube\Controller\FrontController;

View file

@ -3,87 +3,89 @@
<div itemscope itemtype="http://schema.org/VideoObject"> <div itemscope itemtype="http://schema.org/VideoObject">
<div class="main"> <div class="main">
{include file="inc/logo.tpl"} {include file="inc/logo.tpl"}
<p id="download_intro">You are going to download<i itemprop="name"> {foreach $vidarr as $video}
<a itemprop="url" id="video_link" <p id="download_intro">You are going to download<i itemprop="name">
data-ext="{$video->ext}" <a itemprop="url" id="video_link"
data-video="{$video->url|escape}" data-ext="{$video->ext}"
href="{$video->webpage_url}"> data-video="{$video->url|escape}"
{$video->title}</a></i>. href="{$video->webpage_url}">
</p> {$video->title}</a></i>.
{if isset($video->thumbnail)} </p>
<img itemprop="thumbnailUrl" class="thumb" src="{$video->thumbnail}" alt="" /> {if isset($video->thumbnail)}
{/if} <img itemprop="thumbnailUrl" class="thumb" src="{$video->thumbnail}" alt="" />
{if isset($video->description)} {/if}
<meta itemprop="description" content="{$video->description|escape}" /> {if isset($video->description)}
{/if} <meta itemprop="description" content="{$video->description|escape}" />
{if isset($video->upload_date)} {/if}
<meta itemprop="uploadDate" content="{$video->upload_date}" /> {if isset($video->upload_date)}
{/if} <meta itemprop="uploadDate" content="{$video->upload_date}" />
<br/> {/if}
{if isset($video->formats)} <br/>
<h3><label for="format">Available formats:</label></h3> {if isset($video->formats)}
<form action="{path_for name="redirect"}"> <h3><label for="format{$video@index}">Available formats:</label></h3>
<input type="hidden" name="url" value="{$video->webpage_url}" /> <form action="{path_for name="redirect"}">
{if uglyUrls} <input type="hidden" name="url" value="{$video->webpage_url}" />
<input type="hidden" name="page" value="redirect" /> {if uglyUrls}
{/if} <input type="hidden" name="page" value="redirect" />
<select name="format" id="format" class="formats monospace"> {/if}
<optgroup label="Generic formats"> <select name="format" id="format{$video@index}" class="formats monospace">
<option value="best{$protocol}"> <optgroup label="Generic formats">
{strip} <option value="best{$protocol}">
Best ({$video->ext})
{/strip}
</option>
<option value="worst{$protocol}">
Worst
</option>
</optgroup>
<optgroup label="Detailed formats" class="monospace">
{foreach $video->formats as $format}
{if $config->stream || $format->protocol|in_array:array('http', 'https')}
{strip} {strip}
<option value="{$format->format_id}"> Best ({$video->ext})
{$format->ext}
{for $foo=1 to (5 - ($format->ext|strlen))}
&nbsp;
{/for}
{if isset($format->width)}
{$format->width}x{$format->height}
{for $foo=1 to (10 - (("{$format->width}x{$format->height}")|strlen))}
&nbsp;
{/for}
{else}
{for $foo=1 to 10}
&nbsp;
{/for}
{/if}
{if isset($format->filesize)}
{($format->filesize/1000000)|round:2} MB
{for $foo=1 to (7 - (($format->filesize/1000000)|round:2|strlen))}
&nbsp;
{/for}
{else}
{for $foo=1 to 10}
&nbsp;
{/for}
{/if}
{if isset($format->format_note)}
{$format->format_note}
{/if}
&nbsp;({$format->format_id})
</option>
{/strip} {/strip}
{/if} </option>
{/foreach} <option value="worst{$protocol}">
</optgroup> Worst
</select><br/><br/> </option>
<input class="downloadBtn" type="submit" value="Download" /><br/> </optgroup>
</form> <optgroup label="Detailed formats" class="monospace">
{else} {foreach $video->formats as $format}
<input type="hidden" name="format" value="best{$protocol}" /> {if $config->stream || $format->protocol|in_array:array('http', 'https')}
<a class="downloadBtn" {strip}
href="{$video->url|escape}">Download</a><br/> <option value="{$format->format_id}">
{/if} {$format->ext}
{for $foo=1 to (5 - ($format->ext|strlen))}
&nbsp;
{/for}
{if isset($format->width)}
{$format->width}x{$format->height}
{for $foo=1 to (10 - (("{$format->width}x{$format->height}")|strlen))}
&nbsp;
{/for}
{else}
{for $foo=1 to 10}
&nbsp;
{/for}
{/if}
{if isset($format->filesize)}
{($format->filesize/1000000)|round:2} MB
{for $foo=1 to (7 - (($format->filesize/1000000)|round:2|strlen))}
&nbsp;
{/for}
{else}
{for $foo=1 to 10}
&nbsp;
{/for}
{/if}
{if isset($format->format_note)}
{$format->format_note}
{/if}
&nbsp;({$format->format_id})
</option>
{/strip}
{/if}
{/foreach}
</optgroup>
</select><br/><br/>
<input class="downloadBtn" type="submit" value="Download" /><br/>
</form>
{else}
<input type="hidden" name="format" value="best{$protocol}" />
<a class="downloadBtn" href="{$video->url|escape}">Download</a><br/>
{/if}
<hr />
{/foreach}
</div> </div>
</div> </div>
{include file="inc/footer.tpl"} {include file="inc/footer.tpl"}