Merge pull request #40 from medismail/master
Add select youtube-dl format extension
This commit is contained in:
@@ -80,6 +80,11 @@ class YoutubeController extends Controller
|
||||
$url = trim($this->request->getParam('text-input-value'));
|
||||
$yt = $this->youtube;
|
||||
$yt->audioOnly = (bool) $this->request->getParam('audio-only');
|
||||
if ($yt->audioOnly) {
|
||||
$yt->audioFormat = $this->request->getParam('extension');
|
||||
} else {
|
||||
$yt->videoFormat = $this->request->getParam('extension');
|
||||
}
|
||||
if (!$yt->isInstalled()) {
|
||||
return new JSONResponse(["error" => "Please install the latest youtube-dl or make the bundled binary file executable in ncdownloader/bin"]);
|
||||
}
|
||||
|
||||
@@ -71,9 +71,11 @@ class Youtube
|
||||
$this->addOption('--add-metadata');
|
||||
$this->setOption('--metadata-from-title', "%(artist)s-%(title).64s");
|
||||
$this->addOption('--extract-audio');
|
||||
} else {
|
||||
$this->audioFormat = "m4a";
|
||||
}
|
||||
$pos = strrpos($this->outTpl, '.');
|
||||
$this->outTpl = substr($this->outTpl, 0, $pos) . ".m4a";
|
||||
$this->outTpl = substr($this->outTpl, 0, $pos) . "." . $this->audioFormat;
|
||||
//$this->outTpl = "/%(id)s-%(title)s.m4a";
|
||||
$this->setAudioFormat($this->audioFormat);
|
||||
return $this;
|
||||
@@ -91,7 +93,8 @@ class Youtube
|
||||
|
||||
public function setVideoFormat($format)
|
||||
{
|
||||
$this->videoFormat = $format;
|
||||
//$this->videoFormat = $format;
|
||||
$this->setOption('--recode-video', $format);
|
||||
}
|
||||
|
||||
public function GetUrlOnly()
|
||||
@@ -125,9 +128,14 @@ class Youtube
|
||||
{
|
||||
if ($this->audioOnly) {
|
||||
$this->audioMode();
|
||||
} else {
|
||||
if ((Helper::ffmpegInstalled()) && ($this->videoFormat != "")) {
|
||||
$this->setOption('--format', 'bestvideo+bestaudio/best');
|
||||
$this->setVideoFormat($this->videoFormat);
|
||||
} else {
|
||||
$this->setOption('--format', $this->format);
|
||||
}
|
||||
}
|
||||
$this->helper = YoutubeHelper::create();
|
||||
$this->downloadDir = $this->downloadDir ?? $this->defaultDir;
|
||||
$this->setOption("--output", $this->downloadDir . "/" . $this->outTpl);
|
||||
|
||||
10
src/App.vue
10
src/App.vue
@@ -58,9 +58,15 @@ export default {
|
||||
let formData = helper.getData(formWrapper);
|
||||
let inputValue = formData["text-input-value"];
|
||||
let message;
|
||||
//formData.audioOnly = document.getElementById('audio-only').checked;
|
||||
if (formData.type === "youtube-dl") {
|
||||
formData["audio-only"] = formData["audio-only"] === "true";
|
||||
formData["audio-only"] = "";
|
||||
formData["extension"] = "";
|
||||
if (formData["select-value-extension"] !== "Default") {
|
||||
formData["extension"] = formData["select-value-extension"];
|
||||
if ((formData["select-value-extension"] === "mp3" ) || (formData["select-value-extension"] === "m4a" ) || (formData["select-value-extension"] === "vorbis" ) ) {
|
||||
formData["audio-only"] = "true";
|
||||
}
|
||||
}
|
||||
message = helper.t("Download task started!");
|
||||
}
|
||||
if (!helper.isURL(inputValue) && !helper.isMagnetURI(inputValue)) {
|
||||
|
||||
@@ -24,16 +24,49 @@
|
||||
<div class="download-input-container" v-if="inputType === 'download'">
|
||||
<textInput :placeholder="placeholder" :dataType="downloadType"></textInput>
|
||||
<div class="download-controls-container">
|
||||
<div v-if="checkboxes" class="checkboxes">
|
||||
<label for="audio-only" class="checkbox-label"
|
||||
><input
|
||||
type="checkbox"
|
||||
id="audio-only"
|
||||
v-model="checkedValue"
|
||||
:value="checkedValue"
|
||||
name="audio-only"
|
||||
/><span>Audio Only</span></label
|
||||
<div v-if="checkboxes" id="select-value-extension-container">
|
||||
<select :value="selectedExt" id="select-value-extension">
|
||||
<option
|
||||
id="defaultext"
|
||||
:value="defaultext"
|
||||
>
|
||||
Default
|
||||
</option>
|
||||
<optgroup label="Video">
|
||||
<option
|
||||
id="mp4"
|
||||
value="mp4"
|
||||
>
|
||||
mp4
|
||||
</option>
|
||||
<option
|
||||
id="webm"
|
||||
value="webm"
|
||||
>
|
||||
webm
|
||||
</option>
|
||||
</optgroup>
|
||||
<optgroup label="Audio">
|
||||
<option
|
||||
id="m4a"
|
||||
value="m4a"
|
||||
>
|
||||
m4a
|
||||
</option>
|
||||
<option
|
||||
id="mp3"
|
||||
value="mp3"
|
||||
>
|
||||
mp3
|
||||
</option>
|
||||
<option
|
||||
id="vorbis"
|
||||
value="vorbis"
|
||||
>
|
||||
vorbis
|
||||
</option>
|
||||
</optgroup>
|
||||
</select>
|
||||
</div>
|
||||
<actionButton className="download-button" @clicked="download"></actionButton>
|
||||
<uploadFile
|
||||
@@ -71,6 +104,7 @@ export default {
|
||||
placeholder: t("ncdownloader", "Paste your http/magnet link here"),
|
||||
searchLabel: t("ncdownloader", "Search Torrents"),
|
||||
searchOptions: this.search_sites ? this.search_sites : this.noOptions(),
|
||||
selectedExt: "Default",
|
||||
};
|
||||
},
|
||||
components: {
|
||||
|
||||
Reference in New Issue
Block a user