Merge pull request #41 from medismail/master
Update filename in the database according to the download extension file
This commit is contained in:
@@ -74,9 +74,9 @@ class Youtube
|
||||
} else {
|
||||
$this->audioFormat = "m4a";
|
||||
}
|
||||
$pos = strrpos($this->outTpl, '.');
|
||||
/*$pos = strrpos($this->outTpl, '.');
|
||||
$this->outTpl = substr($this->outTpl, 0, $pos) . "." . $this->audioFormat;
|
||||
//$this->outTpl = "/%(id)s-%(title)s.m4a";
|
||||
$this->outTpl = "/%(id)s-%(title)s.m4a";*/
|
||||
$this->setAudioFormat($this->audioFormat);
|
||||
return $this;
|
||||
}
|
||||
@@ -145,6 +145,11 @@ class Youtube
|
||||
$process = new Process($this->options, null, $this->env);
|
||||
$process->setTimeout($this->timeout);
|
||||
$data = ['link' => $url];
|
||||
if ($this->audioOnly) {
|
||||
$data['ext'] = $this->audioFormat;
|
||||
} else {
|
||||
$data['ext'] = $this->videoFormat;
|
||||
}
|
||||
$process->run(function ($type, $buffer) use ($data, $process) {
|
||||
if (Process::ERR === $type) {
|
||||
$this->onError($buffer);
|
||||
|
||||
@@ -36,7 +36,8 @@ class YoutubeHelper
|
||||
}
|
||||
public function getFilePath($output)
|
||||
{
|
||||
$rules = '#\[download\]\s+Destination:\s+(?<filename>.*\.(?<ext>(mp4|mp3|aac|webm|m4a|ogg|3gp|mkv|wav|flv)))#i';
|
||||
$rules = '#\[(download|ExtractAudio|VideoConvertor|Merger)\]((\s+|\s+Converting.*;\s+)Destination:\s+|\s+Merging formats into\s+\")' .
|
||||
'(?<filename>.*\.(?<ext>(mp4|mp3|aac|webm|m4a|ogg|3gp|mkv|wav|flv)))#i';
|
||||
|
||||
preg_match($rules, $output, $matches);
|
||||
|
||||
@@ -78,9 +79,14 @@ class YoutubeHelper
|
||||
'timestamp' => time(),
|
||||
'data' => $extra,
|
||||
];
|
||||
if (isset($this->file)) {
|
||||
$sql = sprintf("UPDATE %s set filename = ? WHERE gid = ?", $this->tablename);
|
||||
$this->dbconn->executeUpdate($sql, [basename($file), $this->gid]);
|
||||
} else {
|
||||
$this->dbconn->insert($data);
|
||||
}
|
||||
//save the filename as this runs only once
|
||||
$this->file = $file;
|
||||
$this->dbconn->insert($data);
|
||||
$this->file = basename($file);
|
||||
//$this->dbconn->save($data,[],['gid' => $this->gid]);
|
||||
}
|
||||
if (preg_match_all(self::PROGRESS_PATTERN, $buffer, $matches, PREG_SET_ORDER) !== false) {
|
||||
|
||||
Reference in New Issue
Block a user