-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Allow to transcode a file on-the-fly and download it from the web ui #2489
Conversation
@antlarr, thanks for your PR! By analyzing the history of the files in this pull request, we identified @sampsyo, @geigerzaehler and @obiesmans to be potential reviewers. |
Btw, as part of the tests I did for this I tried downloading (and converting) files with unicode characters in their filenames (like / or á). That fails due to a problem in flask, so I also submitted pallets/flask#2223 to fix it properly and get correct filenames generated in all flask applications. If that PR is not accepted for some reason in flask, I'll submit another (not so nice) fix here. Note that the problem with unicode characters is not introduced by this PR, but also happens with the regular download link. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've only got stylistic comments to add…
beetsplug/web/__init__.py
Outdated
@@ -25,6 +25,11 @@ | |||
from werkzeug.routing import BaseConverter, PathConverter | |||
import os | |||
import json | |||
import tempfile | |||
from string import Template |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should go with the other from anything_but_spam import spam
imports, instead of the middle of the import eggs
ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review. I fixed all the isues you mentioned
beetsplug/web/__init__.py
Outdated
) | ||
) | ||
attachment_filename = os.path.basename(util.py3_path(item.path)) | ||
attachment_filename = attachment_filename[:attachment_filename.rfind('.')] + extension |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line is too long, as per https://travis-ci.org/beetbox/beets/jobs/214352835
beetsplug/web/__init__.py
Outdated
@@ -348,6 +423,10 @@ def func(lib, opts, args): | |||
app.config['JSONIFY_PRETTYPRINT_REGULAR'] = False | |||
|
|||
app.config['INCLUDE_PATHS'] = self.config['include_paths'] | |||
if 'convert_extension' in self.config: | |||
app.config['convert_extension'] = self.config['convert_extension'].as_str() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line is too long, as per https://travis-ci.org/beetbox/beets/jobs/214352835
beetsplug/web/__init__.py
Outdated
if 'convert_extension' in self.config: | ||
app.config['convert_extension'] = self.config['convert_extension'].as_str() | ||
if 'convert_command' in self.config: | ||
app.config['convert_command'] = self.config['convert_command'].as_str() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line is too long, as per https://travis-ci.org/beetbox/beets/jobs/214352835
Wow; this is cool! Interestingly, we've talked about a flexible system for this kind of transcoding in the AURA spec, where the idea is that you could specify whatever file formats you're willing to accept: https://github.com/beetbox/aura/blob/master/docs/api.rst#audio-formats-and-quality Is there any code that currently needs to be duplicated from the |
2c6ae61
to
b0d53b0
Compare
This commit adds two config options to the web plugin: convert_extension and convert_command. When convert_extension is defined (for example, as 'mp3'), a new option "convert and download as mp3" is shown next to the download link for files that are not already in mp3 format. This also adds a config global variable to the javascript code, which is filled with data obtained from the new /config route, which returns configuration values useful in the UI (so far, only convert_extension). The code to convert music to another format was mainly copied from the convert plugin, and put in a new /item/<item_id>/converted_file route. The convert command used by default is the same as in the convert plugin too, but can be configured with the convert_command option. To enable this, just define in the configuration: ``` web: convert_extension: mp3 ``` And search for any non-mp3 file in the web plugin.
b0d53b0
to
666872f
Compare
Doing a simple git rebase -i on master and not changing anything in the git-rebase-todo should just replay the changes but it gave some conflicts on commits unrelated to my branch. This gave me a hard time rebasing my branch so that it applied cleanly on master. Because of that, I decided to just branch from master again, cherry-pick my changes rebasing them at the same time and then force-push the changes to the origin branch of this pull request. That's the reason they appear as new commits. |
Hi, @antlarr—thanks for your patience while I'm digging myself out of a PR review backlog! I'm aware I have more significant changes from you to review too, but while I'm on my way there, here are a couple of comments:
|
@antlarr any interest in continuing this? |
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This commit adds two config options to the web plugin:
convert_extension and convert_command.
When convert_extension is defined (for example, as 'mp3'), a new
option "convert and download as mp3" is shown next to the download link
for files that are not already in mp3 format.
This also adds a config global variable to the javascript code, which
is filled with data obtained from the new /config route, which returns
configuration values useful in the UI (so far, only convert_extension).
The code to convert music to another format was mainly copied
from the convert plugin, and put in a new /item/<item_id>/converted_file
route. The convert command used by default is the same as in the convert
plugin too, but can be configured with the convert_command option.
To enable this, just define in the configuration:
And search for any non-mp3 file in the web plugin.