Субтитри от Vbox7

Готови за използване кодове
User avatar
bankera1990
Потребител
Потребител
Posts: 683
Joined: Sat Aug 01, 2009 2:28 am
Answers: 15

Субтитри от Vbox7

Post by bankera1990 » Fri Oct 05, 2012 10:02 am

Здравейте интересува ме как мога да взема субтитри от клип в вбокса като .srt с помощта на php скрипт

User avatar
Weezy
Нов
Нов
Posts: 85
Joined: Sat Aug 25, 2012 5:21 pm

Post by Weezy » Fri Oct 05, 2012 10:16 am

За да ги изтеглиш, трябва да знаеш пътя до тях. :) Няма как е така бам и да теглиш субтитри, а и то дали изобщо може да се направи подобно нещо. ;)

User avatar
critrate
Потребител
Потребител
Posts: 640
Joined: Mon Jun 18, 2012 6:21 pm
Answers: 23

Post by critrate » Fri Oct 05, 2012 10:36 am

Ако се знае пъти може да се успее да се направи такова животно

User avatar
bankera1990
Потребител
Потребител
Posts: 683
Joined: Sat Aug 01, 2009 2:28 am
Answers: 15

Post by bankera1990 » Fri Oct 05, 2012 12:09 pm

значи това е линка към субтитрите http://i47.vbox7.com/subtitles/530/781530_2.js но някак трябва да се конвертира към srt

User avatar
critrate
Потребител
Потребител
Posts: 640
Joined: Mon Jun 18, 2012 6:21 pm
Answers: 23

Post by critrate » Fri Oct 05, 2012 2:01 pm

vbox са умни :D

записали са ги като js и във файла има и js код така че , и да се конвертира ще си останат js кодовете във файла ..

User avatar
bankera1990
Потребител
Потребител
Posts: 683
Joined: Sat Aug 01, 2009 2:28 am
Answers: 15

Post by bankera1990 » Fri Oct 05, 2012 2:31 pm

Това е за самия плеър но трябва да се съхраняват някъде под формата на .srt от този сайт се теглят http://www.infosphere.org/tools/subtitles/

User avatar
proba
Много Редовен
Много Редовен
Posts: 1850
Joined: Tue Nov 06, 2007 4:11 pm
Answers: 174
Location: София
Contact:

Post by proba » Fri Oct 05, 2012 7:49 pm

Кратък код за теглене чрез функцията на infosphere.org:

Code: Select all

<?php
$url = "http&#58;//vbox7.com/play&#58;b74ece70fa";
$vid = end&#40;explode&#40;"&#58;",$url&#41;&#41;;
$ext = base64_encode&#40;"http&#58;//www.vbox7.com/etc/ext.do?key=".$vid&#41;;
echo '<a href="http&#58;//www.infosphere.org/tools/subtitles/?subs='.$ext.'&domain=vbox7.com&v='.$vid.'">Download</a>';
?>
А ето ти и по-дълъг код + форма за въвеждане на url + проверка за валиден URL с възможност за сваляне на FLV и SRT , като за SRT пак се използва infosphere.org

Code: Select all

<?php
// Author&#58; proba
// web-tourist.net
ob_start&#40;&#41;;
echo "<form method='POST'>";
echo "URL&#58; <input type='text' name='url'> <input type='submit' name='submit' value='Download'>";
echo "</form>";
if &#40;isset&#40;$_POST&#91;'submit'&#93;&#41;&#41;
&#123;
$url = htmlspecialchars&#40;$_POST&#91;'url'&#93;&#41;;
$urlex = explode&#40;"&#58;",$url&#41;;
if &#40;preg_match&#40;"/vbox7.com/i",$urlex&#91;1&#93;&#41; and preg_match&#40;"/play/i",$urlex&#91;1&#93;&#41; and strlen&#40;$urlex&#91;2&#93;&#41; == 10&#41;
&#123;
$extdo = "http&#58;//www.vbox7.com/etc/ext.do?key=".$urlex&#91;2&#93;;
$extdo_open = file_get_contents&#40;$extdo&#41;;
if &#40;!preg_match&#40;"/errorInfo/i",$extdo_open&#41;&#41;
&#123;
$flv_get1 = explode&#40;"flv_addr=",$extdo_open&#41;;
$flv_get2 = explode&#40;"&",$flv_get1&#91;1&#93;&#41;;
$flv_file = $flv_get2&#91;0&#93;;
$img_get1 = explode&#40;"jpg_addr=",$extdo_open&#41;;
$img_get2 = explode&#40;"&",$img_get1&#91;1&#93;&#41;;
$img_file = "http&#58;//".$img_get2&#91;0&#93;;
echo "<form method='POST' name='step2'>";
echo "<img src='$img_file' /><br />";
echo "<input type='hidden' name='extdo' value='".base64_encode&#40;$extdo&#41;."' />";
echo "<input type='hidden' name='vid' value='$urlex&#91;2&#93;' />";
echo "<input type='hidden' name='url' value='$url' />";
echo "<input type='hidden' name='flvurl' value='$flv_file' />";
echo "<input type='hidden' name='submit' value='Download' />";
echo "<input type='submit' name='flvdown' value='Download Video' /> ";
echo "<input type='submit' name='subsdown' value='Download Subtitles' />";
echo "</form>";
if &#40;isset&#40;$_POST&#91;'flvdown'&#93;&#41;&#41;
&#123;
header&#40;"Location&#58; http&#58;//".$_POST&#91;'flvurl'&#93;&#41;;
&#125;
if &#40;isset&#40;$_POST&#91;'subsdown'&#93;&#41;&#41;
&#123;
header&#40;"Location&#58; http&#58;//www.infosphere.org/tools/subtitles/?subs=".$_POST&#91;'extdo'&#93;."&domain=vbox7.com&v=".$_POST&#91;'vid'&#93;&#41;;
&#125;
&#125;
else
&#123;
echo "Видео клипът не е намерен.";
&#125;
&#125;
else
&#123;
echo "Невалиден URL.";
&#125;
&#125;
?>

User avatar
Weezy
Нов
Нов
Posts: 85
Joined: Sat Aug 25, 2012 5:21 pm

Post by Weezy » Sat Oct 06, 2012 9:26 am

Първият код е добре, но вторият нещо ти дава еврори. :)

User avatar
qazxsw
Много Редовен
Много Редовен
Posts: 1860
Joined: Mon Dec 21, 2009 8:11 pm
Answers: 18

Post by qazxsw » Sat Oct 06, 2012 11:38 am

Weezy wrote:Първият код е добре, но вторият нещо ти дава еврори. :)
Ами сподели какви, пък току виж, спретнем всички ръкави и го оправим. :)

User avatar
Ticketa
Турист
Турист
Posts: 571
Joined: Mon Feb 27, 2012 1:54 pm
Answers: 24
Location: in /root
Contact:

Post by Ticketa » Sat Oct 06, 2012 11:56 am

В стария ми тефтер имам два класа за сваляне на субтитри от vbox7. Не ми се занимава да търся линкове и прочие и да го пренаписвам. Може на някой да му е дошла музата и идея как да направи кода.

v1.0
[php]<?php
/*
Version: 0.1
Author: Milen Ivanov / criobot<at>gmail<dot>com
*/

define("VBOX7_TITLE", 1);
define("VBOX7_SUBTITLES", 2);

class vbox7{
public $url = null;
public $code = null;
public $title = null;
public $thumbnail = null;
public $flvUrl = null;
public $subtitles = null;
public $subtitlesExtension = 'srt';
public function __construct($url, $flags = VBOX7_FLVURL){
if(preg_match("/.*play:([a-fA-F0-9]{8})/",$url, $match)){
$this->url = $match[0];
$this->code = $match[1];

if( ($FLAGS & VBOX7_TITLE) == true ){
$src = file_get_contents($this->url);

if(preg_match("/<title>(.*) \/ VBOX7<\/title>/", $src, $found)){
$this->title = $found[1];
}
}

$src = file_get_contents("http://www.vbox7.com/etc/ext.do?key=".$ ... Stamp=1234");

if(preg_match("/&flv_addr=(.*?)&jpg_addr=(.*?)&subsEnabled=(?:true&subsData=)?(.*?)&related=[0-1]$/", $src, $parts)){
$this->flvUrl = "http://".$parts[1];
$this->thumbnail = "http://".$parts[2];
if(($flags & VBOX7_SUBTITLES) == true){
if($parts[3]){
if($subs == 'srt'){
$subs = new SRTFile(json_decode($parts[3]));
}else{
$subs = new SUBFile(json_decode($parts[3]));
$this->subtitlesExtension = 'sub';
}
$this->subtitles = $subs->parse();
}
}
}
}else{
throw new Exception("Невалиден линк");
}
}
}
/**
* SRT File Class
* 1\r\n
* 00:00:04,680 --> 00:00:08,500\r\n
* Кой даде идеята?\r\n
* - Ти.\r\n
* \r\n
*
*/
class SRTFile{
private $source = null;
public function __construct($src){
if($src)
$this->source = $src;
}

public function parse(){
$number = 1;
$return = "";
for($i=0; $i<sizeof($this->source);$i++){
$return .= ($i+1) . "\r\n";
$return .= $this->formatTime($this->source[$i]->f) . " --> " . $this->formatTime($this->source[$i]->t) . "\r\n";
$return .= str_replace("<br>", "\r\n", $this->source[$i]->s . "\r\n");
$return .= "\r\n";
}
return $return;
}
private function leadingNull($number){
if($number < 10) return "0".$number;
return $number;
}

private function formatTime($seconds){
$hours = $this->leadingNull((int)($seconds/360));
$minutes =$this->leadingNull((int)($seconds/60));
$seconds = $this->leadingNull($seconds - (((int)($seconds/360))*360 + ((int)($seconds/60))*60));
return $hours.":".$minutes.":".$seconds.",000";
}
}

/**
* SUB File Class
* {from*fps}{to*fps}Content(nl as |)\r\n
*
*/
class SUBFile{
private $source = NULL;
public function __construct($src){
if($src)
$this->source = $src;
}

public function parse($fps = 30){
//Свалих 2-3 клипа от vbox7 и всичките бяха с FPS 30.0 така, че го оставям така по подразбиране.
$return = "";
for($i=0; $i<sizeof($this->source);$i++){
$return .= "{". $fps * $this->source[$i]->f ."}{" . $fps * $this->source[$i]->t . "}" . $this->newLineFix($this->source[$i]->s) . "\r\n";
}
return $return;
}

public function newLineFix($string){
$nl = array("\r\n", "\r", "\n", "<br>");
return str_replace($nl, "|", $string);
}
}
$x = new vbox7("http://vbox7.com/play:87ae93cf", VBOX7_SUBTITLES);
echo $x->subtitles;

if(isset($_POST['link'])){
$link = $_POST['link'];
$format = $_POST['type'];
if(preg_match("/[?:http:\/\/](?:www\.)?(vbox7.com|zazz.bg)\/play:[0-9a-fA-F]{8}.*?/i", $link)){
if($_POST['download'] == 'subs'){
$clip = new vbox7($link, $format==0? "srt": "sub");
if($clip->subtitles){
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="'.$clip->code.'.'.$clip->subtitlesExtension.'"');
echo $clip->subtitles;
}else{
echo 'No subtitles found.';
}
}else{
$clip = new vbox7($link);
if($clip->flvUrl){
header('Location: '.$clip->flvUrl);
}else{
echo 'Error gettin\' FLV\'s URL';
}
}
}else{
echo 'Invalid link';
}
}else{
header("Location: index.html");
}
?>[/php]





v1.2
[php]
<?php
/*
Version: 0.1.2
Author: Milen Ivanov / criobot<at>gmail<dot>com

CHANGES:
v.0.1.2
- Updated subtitles support (vbox7 added url encoding to the json subs /how lame/).

v.0.1.1
- Updated subtitles support (SUB newline fix, also etc-link update).

v.0.1
- Init;
*/
class vbox7 {
public $url = null;
public $code = null;
public $title = null;
public $thumbnail = null;
public $flvUrl = null;
public $subtitles = null;
public $subtitlesExtension = 'srt';
public function __construct($url, $subs = 'srt'){
if(preg_match("/.*play:([a-fA-F0-9]{8})/",$url, $match)){
$this->url = $match[0];
$this->code = $match[1];

$src = file_get_contents($this->url);

if(preg_match("/<title>(.*) \/ VBOX7<\/title>/", $src, $found)){
$this->title = $found[1];
}
$src = file_get_contents("http://www.vbox7.com/etc/ext.do?key=".$ ... Stamp=1234");
if(preg_match("/&flv_addr=(.*?)&jpg_addr=(.*?)&subsEnabled=(?:true&subsData=)?(.*?)&related=[0-1]$/", $src, $parts)){
$this->flvUrl = "http://".$parts[1];
$this->thumbnail = "http://".$parts[2];
if($parts[3]){
if($subs == 'sub'){
$subs = new SUBFile(json_decode(urldecode($parts[3])));
$this->subtitlesExtension = 'sub';
}else{
$subs = new SRTFile(json_decode(urldecode($parts[3])));
}
$this->subtitles = $subs->parse();
}
}
} else {
throw new Exception("&#1053;&#1077;&#1074;&#1072;&#1083;&#1080;&#1076;&#1077;&#1085; &#1083;&#1080;&#1085;&#1082;");
}
}
}

/**
* SRT File Class
* 1\r\n
* 00:00:04,680 --> 00:00:08,500\r\n
* Кой даде идеята?\r\n
* - Ти.\r\n
* \r\n
*
*/
class SRTFile{
private $source = null;
public function __construct($src){
if($src)
$this->source = $src;
}
public function parse(){
$number = 1;
$return = "";
for($i=0; $i<sizeof($this->source);$i++){
$return .= ($i+1) . "\r\n";
$return .= $this->formatTime($this->source[$i]->f) . " --> " . $this->formatTime($this->source[$i]->t) . "\r\n";
$return .= str_replace("<br>", "\r\n", $this->source[$i]->s . "\r\n");
$return .= "\r\n";
}
return $return;
}
private function leadingNull($number){
if($number < 10) return "0".$number;
return $number;
}
private function formatTime($seconds){
$hours = $this->leadingNull((int)($seconds/360));
$minutes =$this->leadingNull((int)($seconds/60));
$seconds = $this->leadingNull($seconds - (((int)($seconds/360))*360 + ((int)($seconds/60))*60));
return $hours.":".$minutes.":".$seconds.",000";
}
}
/**
* SUB File Class
* {from*fps}{to*fps}Content(nl as |)\r\n
*
*/
class SUBFile{
private $source = NULL;
public function __construct($src){
if($src)
$this->source = $src;
}

public function parse($fps = 30){
//Свалих 2-3 клипа от vbox7 и всичките бяха с FPS 30.0 така, че го оставям така по подразбиране.
$return = "";
for($i=0; $i<sizeof($this->source);$i++){
$return .= "{". $fps * $this->source[$i]->f ."}{" . $fps * $this->source[$i]->t . "}" . $this->newLineFix($this->source[$i]->s) . "\r\n";
}
return $return;
}

public function newLineFix($string){
$nl = array("\r\n", "\r", "\n", "<br>");
return str_replace($nl, "|", $string);
}
}
if(isSet($_POST['link'])){
$link = $_POST['link'];
$format = $_POST['type'];
if(preg_match("/[?:http:\/\/](?:www\.)?(vbox7.com|zazz.bg)\/play:[0-9a-fA-F]{8}.*?/i", $link)){
if($_POST['download'] == 'subs'){
$clip = new vbox7($link, $format==0? "srt": "sub");
if($clip->subtitles){
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="'.$clip->code.'.'.$clip->subtitlesExtension.'"');
echo $clip->subtitles;
}else{
echo 'No subtitles found.';
}
}else{
$clip = new vbox7($link);
if($clip->flvUrl){
header('Location: '.$clip->flvUrl);
}else{
echo 'Error gettin\' FLV\'s URL';
}
}
}else{
echo 'Invalid link';
}
} else {
echo '<form action="?" method="post">
<p>
<label for="address" id="l_address">Пълен адрес на клипа:</label>
<input type="submit" value="Извлечи" id="b_extract" />
<input type="text" name="link" id="address" value=""/>
</p>
</form>
';
}
?>
[/php]

Post Reply