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,31 +3,32 @@
<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}
<p id="download_intro">You are going to download<i itemprop="name">
<a itemprop="url" id="video_link" <a itemprop="url" id="video_link"
data-ext="{$video->ext}" data-ext="{$video->ext}"
data-video="{$video->url|escape}" data-video="{$video->url|escape}"
href="{$video->webpage_url}"> href="{$video->webpage_url}">
{$video->title}</a></i>. {$video->title}</a></i>.
</p> </p>
{if isset($video->thumbnail)} {if isset($video->thumbnail)}
<img itemprop="thumbnailUrl" class="thumb" src="{$video->thumbnail}" alt="" /> <img itemprop="thumbnailUrl" class="thumb" src="{$video->thumbnail}" alt="" />
{/if} {/if}
{if isset($video->description)} {if isset($video->description)}
<meta itemprop="description" content="{$video->description|escape}" /> <meta itemprop="description" content="{$video->description|escape}" />
{/if} {/if}
{if isset($video->upload_date)} {if isset($video->upload_date)}
<meta itemprop="uploadDate" content="{$video->upload_date}" /> <meta itemprop="uploadDate" content="{$video->upload_date}" />
{/if} {/if}
<br/> <br/>
{if isset($video->formats)} {if isset($video->formats)}
<h3><label for="format">Available formats:</label></h3> <h3><label for="format{$video@index}">Available formats:</label></h3>
<form action="{path_for name="redirect"}"> <form action="{path_for name="redirect"}">
<input type="hidden" name="url" value="{$video->webpage_url}" /> <input type="hidden" name="url" value="{$video->webpage_url}" />
{if uglyUrls} {if uglyUrls}
<input type="hidden" name="page" value="redirect" /> <input type="hidden" name="page" value="redirect" />
{/if} {/if}
<select name="format" id="format" class="formats monospace"> <select name="format" id="format{$video@index}" class="formats monospace">
<optgroup label="Generic formats"> <optgroup label="Generic formats">
<option value="best{$protocol}"> <option value="best{$protocol}">
{strip} {strip}
@ -79,11 +80,12 @@
</select><br/><br/> </select><br/><br/>
<input class="downloadBtn" type="submit" value="Download" /><br/> <input class="downloadBtn" type="submit" value="Download" /><br/>
</form> </form>
{else} {else}
<input type="hidden" name="format" value="best{$protocol}" /> <input type="hidden" name="format" value="best{$protocol}" />
<a class="downloadBtn" <a class="downloadBtn" href="{$video->url|escape}">Download</a><br/>
href="{$video->url|escape}">Download</a><br/> {/if}
{/if} <hr />
{/foreach}
</div> </div>
</div> </div>
{include file="inc/footer.tpl"} {include file="inc/footer.tpl"}