mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-03-07 20:10:03 +03:00
merged new checkbox for bookmarklet: enables ability to set bookmarklet to audio only
fixed two bugs for audio only files: sometimes downloads failed as extensions were improperly removed and readded, removing a single character from the filename. Fixed another extension-related bug where metadata from deleted audio files persisted
This commit is contained in:
@@ -710,11 +710,21 @@ async function deleteAudioFile(name, blacklistMode = false) {
|
||||
return new Promise(resolve => {
|
||||
// TODO: split descriptors into audio and video descriptors, as deleting an audio file will close all video file streams
|
||||
var jsonPath = path.join(audioFolderPath,name+'.mp3.info.json');
|
||||
var altJSONPath = path.join(audioFolderPath,name+'.info.json');
|
||||
var audioFilePath = path.join(audioFolderPath,name+'.mp3');
|
||||
jsonPath = path.join(__dirname, jsonPath);
|
||||
altJSONPath = path.join(__dirname, altJSONPath);
|
||||
audioFilePath = path.join(__dirname, audioFilePath);
|
||||
|
||||
let jsonExists = fs.existsSync(jsonPath);
|
||||
|
||||
if (!jsonExists) {
|
||||
if (fs.existsSync(altJSONPath)) {
|
||||
jsonExists = true;
|
||||
jsonPath = altJSONPath;
|
||||
}
|
||||
}
|
||||
|
||||
let audioFileExists = fs.existsSync(audioFilePath);
|
||||
|
||||
if (descriptors[name]) {
|
||||
@@ -1012,6 +1022,12 @@ async function checkExistsWithTimeout(filePath, timeout) {
|
||||
});
|
||||
}
|
||||
|
||||
function removeFileExtension(filename) {
|
||||
const filename_parts = filename.split('.');
|
||||
filename_parts.splice(filename_parts.length - 1)
|
||||
return filename_parts.join('.');
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/a/32197381/8088021
|
||||
const deleteFolderRecursive = function(folder_to_delete) {
|
||||
if (fs.existsSync(folder_to_delete)) {
|
||||
@@ -1165,8 +1181,10 @@ app.post('/api/tomp3', async function(req, res) {
|
||||
// if invalid, continue onto the next
|
||||
continue;
|
||||
}
|
||||
|
||||
const filename_no_extension = removeFileExtension(output_json['_filename']);
|
||||
|
||||
var full_file_path = output_json['_filename'].substring(0, output_json['_filename'].length-5) + '.mp3';
|
||||
var full_file_path = filename_no_extension + '.mp3';
|
||||
if (fs.existsSync(full_file_path)) {
|
||||
let tags = {
|
||||
title: output_json['title'],
|
||||
@@ -1179,7 +1197,7 @@ app.post('/api/tomp3', async function(req, res) {
|
||||
logger.info('Output mp3 does not exist');
|
||||
}
|
||||
|
||||
var file_path = output_json['_filename'].substring(audioFolderPath.length, output_json['_filename'].length-5);
|
||||
var file_path = filename_no_extension.substring(audioFolderPath.length, filename_no_extension.length);
|
||||
if (file_path) file_names.push(file_path);
|
||||
}
|
||||
|
||||
|
||||
@@ -210,6 +210,7 @@
|
||||
<div class="col-12">
|
||||
<h6>Bookmarklet</h6>
|
||||
<p><ng-container i18n="Bookmarklet instructions">Drag the link below to your bookmarks, and you're good to go! Just navigate to the YouTube video you'd like to download, and click the bookmark.</ng-container></p>
|
||||
<mat-checkbox (change)="bookmarkletAudioOnlyChanged($event)"><ng-container i18n="Generate audio only bookmarklet checkbox">Generate 'audio only' bookmarklet</ng-container></mat-checkbox>
|
||||
<!--<button style="margin-bottom: 5px;" mat-stroked-button color="accent" (click)="generateBookmarklet()">Generate bookmarklet</button>-->
|
||||
<p><a [href]="generated_bookmarklet_code" target="_blank">YTDL-Bookmarklet</a></p>
|
||||
</div>
|
||||
|
||||
@@ -7,6 +7,7 @@ import {DomSanitizer} from '@angular/platform-browser';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { ArgModifierDialogComponent } from 'app/dialogs/arg-modifier-dialog/arg-modifier-dialog.component';
|
||||
import { CURRENT_VERSION } from 'app/consts';
|
||||
import { MatCheckboxChange } from '@angular/material/checkbox';
|
||||
|
||||
@Component({
|
||||
selector: 'app-settings',
|
||||
@@ -22,6 +23,7 @@ export class SettingsComponent implements OnInit {
|
||||
new_config = null
|
||||
loading_config = false;
|
||||
generated_bookmarklet_code = null;
|
||||
bookmarkletAudioOnly = false;
|
||||
|
||||
_settingsSame = true;
|
||||
|
||||
@@ -96,11 +98,17 @@ export class SettingsComponent implements OnInit {
|
||||
generateBookmarkletCode() {
|
||||
const currentURL = window.location.href.split('#')[0];
|
||||
const homePageWithArgsURL = currentURL + '#/home;url=';
|
||||
const bookmarkletCodeInside = `'${homePageWithArgsURL}' + window.location`
|
||||
const bookmarkletCode = `javascript:(function()%7Bwindow.open('${homePageWithArgsURL}' + encodeURIComponent(window.location))%7D)()`;
|
||||
const audioOnly = this.bookmarkletAudioOnly;
|
||||
// tslint:disable-next-line: max-line-length
|
||||
const bookmarkletCode = `javascript:(function()%7Bwindow.open('${homePageWithArgsURL}' + encodeURIComponent(window.location) + ';audioOnly=${audioOnly}')%7D)()`;
|
||||
return bookmarkletCode;
|
||||
}
|
||||
|
||||
bookmarkletAudioOnlyChanged(event: MatCheckboxChange): void {
|
||||
this.bookmarkletAudioOnly = event.checked;
|
||||
this.generated_bookmarklet_code = this.sanitizer.bypassSecurityTrustUrl(this.generateBookmarkletCode());
|
||||
}
|
||||
|
||||
// not currently functioning on most platforms. hence not in use
|
||||
bookmarksite(title, url) {
|
||||
// Internet Explorer
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
</div>
|
||||
<div *ngIf="availableVersions" style="display: inline-block; margin-left: 15px;">
|
||||
<mat-form-field>
|
||||
<mat-select [(ngModel)]="selectedVersion">
|
||||
<mat-option *ngFor="let version of availableVersionsFiltered" [value]="version['tag_name']">
|
||||
{{version['tag_name'] + (version === latestStableRelease ? ' - Latest Stable' : '') + (version['tag_name'] === CURRENT_VERSION ? ' - Current Version' : '')}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
<mat-select [(ngModel)]="selectedVersion">
|
||||
<mat-option *ngFor="let version of availableVersionsFiltered" [value]="version['tag_name']">
|
||||
{{version['tag_name'] + (version === latestStableRelease ? ' - Latest Stable' : '') + (version['tag_name'] === CURRENT_VERSION ? ' - Current Version' : '')}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div *ngIf="selectedVersion && selectedVersion !== CURRENT_VERSION" style="display: inline-block; margin-left: 15px;">
|
||||
|
||||
Reference in New Issue
Block a user