-
Notifications
You must be signed in to change notification settings - Fork 90
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
Grab cover art from MusicBrainz/Cover Art Archive and add it to the resulting whipper rips #436
Conversation
Here's a thought: should an error fetching the cover art be fatal or not? Also - let's make sure it's an optional feature. |
Alright, i'm just testing before bed :DD . Thank for your early suggestions. Also i think it shouldn't be fatal. |
Isn't it possible to import conditionally? It seems strange to bloat the mandatory dependencies for an optional feature. |
Hi @q3cpma , I don't really get what you mean right now but maybe i should move |
On Thu, Dec 26, 2019 at 11:05:48PM -0800, ABCbum wrote:
> Isn't it possible to import conditionally? It seems strange to bloat the mandatory dependencies for an optional feature.
I don't really get what you mean right now but maybe i should move `from PIL import Image` to where it is used ?.
Well, something like that. Sadly, I don't Python at all, so I don't know if that's a good idea. Just don't want to install pillow when I don't plan on using this feature.
|
Yeah i think thats a good point, just move the import statement down to the |
c071e9e
to
84ca2cf
Compare
Fixed conflicts and squashed. |
@JoeLametta , thanks for doing that for me ;) |
@ABCbum I think @q3cpma means that as this one (grabbing cover art) is not a primary feature of whipper, it should be possible to install and use whipper without the new dependency (pillow). try:
from PIL import Image
except ImportError as e:
logger.warning("bla, bla", e)
... |
@JoeLametta , i think that's a great idea but how about We can solve README.md my simply adding (optional) next to pillow. But what about the other two ? Should we remove |
|
I'm not sure if what i did in this commit correct tho, @JoeLametta . |
This is not enough but I'm also not sure which is the best way to handle this. @Freso do you have any advice about this? |
@ABCbum General comment: |
The "best"/canonical way of specifying optional dependencies is to specify them as "extras" in |
77750fe
to
80d628d
Compare
Small changes + history rewritten to be easier to understand. |
@ABCbum could you add a test case? |
80d628d
to
2bca3e6
Compare
2bca3e6
to
faf724c
Compare
d4080a6
to
9b2e5f7
Compare
I have added a "draft" test case i'm not sure if it's an okay one. |
410042c
to
b9be520
Compare
If you want to test whether the embedding works too I've attached this FLAC file (the extension is ZIP because GitHub doesn't allow attaching FLAC files directly, just rename it). The file content is just 1s of silence (stereo, 44100 Hz) with the test image embedded as front cover. 😉 |
@ABCbum Same file without attached cover: test_1s_silence_stereo_no_cover.flac.zip I have generated the source wave file with the following code: import wave
with wave.open('test.wav', 'wb') as f:
duration = 1 # duration in seconds
nchannels = 2 # Set to 1 for mono
sampwidth = 2 # 16 bit
framerate = 44100 # CD sample rate
f.setnchannels(nchannels)
f.setsampwidth(sampwidth)
f.setframerate(framerate)
f.setnframes(framerate * duration)
f.writeframes(b'\x00' * nchannels * sampwidth * framerate * duration) |
Yeah it works locally to me :D not sure if i should write a test case for that. |
d5ab69a
to
93b3f0f
Compare
Add option `--cover-art` to `whipper cd rip` command which accepts three values: - `file`: save the downloaded cover image as standalone file in the rip folder (named `cover.jpg`) - `embed`: embed the download cover image into all the ripped audio tracks (no standalone file will be kept) - `complete`: save standalone cover image as standalone file and embed it into all the ripped audio tracks (`file` + `embed`) Every cover art is fetched from the Cover Art Archive as JPEG thumbnail with a maximum dimension of 500px. Other supported values for the thumbnails are 250, 500 and 1200 (currently only some images have a corresponding 1200px sized thumbnail). This feature introduces an optional dependency on the `Pillow` module which is required for the decoding of the cover file (required by the `embed` and `complete` option values). Problem: - EmbedPicTureTask shouldn't be a task. Signed-off-by: ABCbum <kimlong221002@gmail.com> Co-authored-by: JoeLametta <JoeLametta@users.noreply.github.com> Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
Signed-off-by: ABCbum <kimlong221002@gmail.com> Co-authored-by: JoeLametta <JoeLametta@users.noreply.github.com> Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
Mock two functions `getCoverArt`, `get_image_front` and use a locally available cover art to check if the created cover art exists. Problems: - How to check image's quality. - Not sure if only this check is enough (do we need to check the embedding part?). Signed-off-by: ABCbum <kimlong221002@gmail.com>
93b3f0f
to
e2942b0
Compare
Merged, thanks! |
@@ -290,6 +291,14 @@ def add_arguments(self): | |||
help="whether to continue ripping if " | |||
"the disc is a CD-R", | |||
default=False) | |||
self.parser.add_argument('-C', '--cover-art', | |||
action="store", dest="fetch_cover_art", | |||
help="Fetch cover art and save it as " |
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.
help="Fetch cover art and save it as " | |
help="fetch cover art and save it as " |
I just noticed a small detail that this shouldn't be capital just to be consistent 😉.
Reported by user "ABCbum" in comment (#436 (comment)). Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
Lets say someone already issued: Now they want to go back and '--cover-art complete' without re-ripping. Can you just patch existing files with just artwork ? or is |
That's not possible with the current implementation and I would say that's out of scope for whipper and best left to a specialized tool (musical tagger). |
Submitted as a part of GCI competition
Description
Fixes: #50
Add option
--cover-art
towhipper cd rip
command which accepts three values:file
: save the downloaded cover image as standalone file in the rip folder (namedcover.jpg
)embed
: embed the download cover image into all the ripped audio tracks (no standalone file will be kept)complete
: save standalone cover image as standalone file and embed it into all the ripped audio tracks (file
+embed
)Every cover art is fetched from the Cover Art Archive as JPEG thumbnail with a maximum dimension of 500px using musicbrainzngs.
Other supported values for the thumbnails are 250, 500 and 1200 (currently only some images have a corresponding 1200px sized thumbnail).
This feature introduces an optional dependency on the
Pillow
module which is required for the decoding of the cover file (required by theembed
andcomplete
option values).Problems
getCoverArt
's functionality (embedding isn't tested)