Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving Import and File Write Issues in Docker Container #2

Open
Tracked by #1
mattiasghodsian opened this issue Aug 4, 2024 · 1 comment
Open
Tracked by #1
Labels
bug Something isn't working

Comments

@mattiasghodsian
Copy link
Owner

Address the problem of fixing the import functionality and ensuring that the meta data is written to a file within a Docker container environment.

export const writeMetaToFile = (req, res) => {
const beetsDB = process.env.BEETS_DB || null;
const storage = process.env.MUSIC_STORAGE || null;
const directory = req.query.directoryname || null;
const fileName = req.query.filename || null;
const releaseID = req.query.releaseid || null;
const renameTo = req.query.rename || null;
if (directory === null) {
return res.status(400).send({
status: 400,
message: 'directory must be provided.'
});
}
if (fileName === null && releaseID === null) {
return res.status(400).send({
status: 400,
message: 'filename and releaseid must be provided.'
});
}
const directoryPath = path.join(storage, directory);
const filePath = path.join(directoryPath, fileName);
const fileExtension = path.extname(filePath);
checkDirectoryExists(directoryPath, res);
checkFileExists(filePath, fileName, res);
// Remove beets db file to avoid issues
if (fs.existsSync(beetsDB)) {
fs.unlink(beetsDB);
}
const beetsArgs = [
'import',
'--write',
'-S',
releaseID,
filePath
];
execa("beet", beetsArgs, { input: 'A\n' })
.then(({ stdout }) => {
if (renameTo){
let newFileName = renameTo + fileExtension;
let newFilePath = path.join(directoryPath, newFileName);
fs.rename(filePath, newFilePath, (err) => {
if (err) justLogg(err);
});
}
res.send({
status: 200,
message: `Meta import completed: ${filePath}`,
stdout: stdout
});
}).catch((error) => {
handleWriteMetaError(error, res);
});
};

@mattiasghodsian mattiasghodsian added the bug Something isn't working label Aug 4, 2024
@mattiasghodsian
Copy link
Owner Author

Suggestion:
Create a separate script that leverages parts of the Beets library to fetch metadata from MusicBrainz using the release ID. This script should then write the fetched metadata to a file.

@mattiasghodsian mattiasghodsian pinned this issue Aug 4, 2024
@mattiasghodsian mattiasghodsian mentioned this issue Aug 4, 2024
Closed
13 tasks
@mattiasghodsian mattiasghodsian unpinned this issue Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant