mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-03-21 20:20:57 +03:00
Merge pull request #35 from Tzahi12345/id3-tagging
Added automatic ID3 tagging for mp3 files
This commit is contained in:
@@ -10,6 +10,7 @@ var bodyParser = require("body-parser");
|
||||
var archiver = require('archiver');
|
||||
var mergeFiles = require('merge-files');
|
||||
const low = require('lowdb')
|
||||
const NodeID3 = require('node-id3')
|
||||
const downloader = require('youtube-dl/lib/downloader')
|
||||
const fetch = require('node-fetch');
|
||||
var URL = require('url').URL;
|
||||
@@ -831,12 +832,24 @@ app.post('/api/tomp3', async function(req, res) {
|
||||
// if invalid, continue onto the next
|
||||
continue;
|
||||
}
|
||||
var file_name = output_json['_filename'].replace(/^.*[\\\/]/, '');
|
||||
var file_path = output_json['_filename'].substring(audioFolderPath.length, output_json['_filename'].length);
|
||||
// remove extension from file path
|
||||
var alternate_file_path = file_path.replace(/\.[^/.]+$/, "")
|
||||
var alternate_file_name = file_name.substring(0, file_name.length-4);
|
||||
if (alternate_file_path) file_names.push(alternate_file_path);
|
||||
|
||||
var full_file_path = output_json['_filename'].substring(0, output_json['_filename'].length-5) + '.mp3';
|
||||
console.log(full_file_path);
|
||||
if (fs.existsSync(full_file_path)) {
|
||||
let tags = {
|
||||
title: output_json['title'],
|
||||
artist: output_json['artist'] ? output_json['artist'] : output_json['uploader']
|
||||
}
|
||||
// NodeID3.create(tags, function(frame) { })
|
||||
let success = NodeID3.write(tags, full_file_path);
|
||||
if (success) console.log('successfully tagged file');
|
||||
else console.log('failed to tag file');
|
||||
} else {
|
||||
console.log('Output mp3 does not exist');
|
||||
}
|
||||
|
||||
var file_path = output_json['_filename'].substring(audioFolderPath.length, output_json['_filename'].length-5);
|
||||
if (file_path) file_names.push(file_path);
|
||||
}
|
||||
|
||||
let is_playlist = file_names.length > 1;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
"exe": "^1.0.2",
|
||||
"express": "^4.17.1",
|
||||
"lowdb": "^1.0.0",
|
||||
"node-id3": "^0.1.14",
|
||||
"merge-files": "^0.1.2",
|
||||
"node-fetch": "^2.6.0",
|
||||
"shortid": "^2.2.15",
|
||||
|
||||
Reference in New Issue
Block a user