devsnd / cherrymusic

Stream your own music collection to all your devices! The easy to use free and open-source music streaming server.
http://www.fomori.org/cherrymusic
GNU General Public License v3.0
1.03k stars 187 forks source link

Display Embed Track Cover-Art #531

Closed systems-rebooter closed 9 years ago

systems-rebooter commented 9 years ago

Hey there!

Is it possible to display track embed cover-art instead of fetching one from Internet?

Thanks

systems-rebooter commented 9 years ago

Ref #528

devsnd commented 9 years ago

Currently that is not possible, but it might be in the future, if reading the images from the meta-data was implemented in the tinytag module.

I have opened an issue over at the tinytag repo. If anybody steps up to implement it, I'd be more than happy to accept pull requests or I'll do it myself someday, when I find the time to do so.

devsnd commented 9 years ago

Hey systems-rebooter,

Today I took the time to hack in cover loading support for tinytag, so it will be possible to use that feature for cherrymusic as well. The following tasks have to be done for it to work:

Is anybody interested to implement this feature for CM?

systems-rebooter commented 9 years ago

Hey-hey @devsnd! You made my day by this update :+1:

tilboerner commented 9 years ago

get the albumart from a mp3, inside the httphandler fetchalbumart API call

Putting the actual logic somewhere into the albumartfetcher module would also be okay in my book, maybe even preferrable.

tilboerner commented 9 years ago

Beginning of implementation in id3-images branch.

Caution: very much untested. Might not even compile. :]

systems-rebooter commented 9 years ago

@tilboerner lol [-:

systems-rebooter commented 9 years ago

Oh, no...

Tried with

Python3
tinytag==0.8.0
[150407-20:35] 192.168.1.200 - - [07/Apr/2015:20:35:19] "GET /api/fetchalbumart/?data=%7B%22directory%22%3A%22P%22%7D HTTP/1.1" 500 823 "http://192.168.1.234:8080/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36"
[150407-20:35] ERROR   : [07/Apr/2015:20:35:19] HTTP Traceback (most recent call last):
  File "/usr/lib/python3.3/site-packages/cherrypy/_cprequest.py", line 670, in respond
    response.body = self.handler()
  File "/usr/lib/python3.3/site-packages/cherrypy/lib/encoding.py", line 217, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "/usr/lib/python3.3/site-packages/cherrypy/_cpdispatch.py", line 61, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/root/cherrymusic-id3images/cherrymusicserver/httphandler.py", line 288, in api
    return handler(**handler_args)
  File "/root/cherrymusic-id3images/cherrymusicserver/httphandler.py", line 407, in api_fetchalbumart
    header, data, resized = fetcher.fetchLocal(localpath)
  File "/root/cherrymusic-id3images/cherrymusicserver/albumartfetcher.py", line 199, in fetchLocal
    fetchers = (self._fetch_folder_image, _fetch_embedded_image)
NameError: global name '_fetch_embedded_image' is not defined
tilboerner commented 9 years ago

Yeah, I saw that as well. I literally just wrote the code without even trying it. Will fix soon.

systems-rebooter commented 9 years ago

@tilboerner cool stuff. will be awaiting for the fix impatiently :]

tilboerner commented 9 years ago

Branch id3-images should be fixed now. Could use some refactoring before merge.

systems-rebooter commented 9 years ago

Hey @tilboerner. Thats awesome! Just had a look on it. Embed images showing up just fine. I noticed few issues through:

I know its too many questions, but this feature is super great and really deserve to be the greatest! Maybe it be possible to have embed image option to be configurable somehow?

By track based collection, I mean the following structure:

ArtistX/Song1.mp3  
ArtistX/Song2.mp3 
.... 
ArtistX/SongN.mp3
ArtistY/Song1.mp3  
ArtistY/Song2.mp3 
.... 
ArtistY/SongM.mp3

Usually track-based collection structure is used for artists, which don't have albums/ep`s, but only songs instead. Also it is widely used for collecting the best Artist or Style songs in one directory.

The issue here is when Artist folder contains many songs - random embed image showing up for this Artist folder, which is fine for Artist/Album structure, but not looks smoothly for track-based collections.

Thanks again for such a great feature! I already own you few beers for sure! :)

Keep up a good work!

tilboerner commented 9 years ago

@systems-rebooter, thanks for the feedback, it's nice to see some dedication. :joy_cat:

In player embed images not displaying (yet? :)

I'll have a look.

If folder contains regular image - embed image is displaying with first priority :(

The way it's coded, folder images should take priority. What's the file name of the image in the folder?

For upper folders, which contains no images, but other directories - broken-image icon displayed (very likely its because of develop-branch, but not master?)

That's a bug. It should display the default folder image. I'll open a ticket.

Add support for track-based collections (see explanation below)

What do you have in mind? We simply can't know which of the ID3-embedded images is the "best" to pick for a folder. In that case, it's better for the user to pick. To do that, select an image from the web by clicking on the little wrench icon of the folder.

Displaying embed image on song level will be very-very nice looking (especially for track-based collections)

Not sure what you mean here. "On song level"?

Maybe it be possible to have embed image option to be configurable somehow?

What would you like to configure, enable/disable the use of embedded images? I think that's too minor a detail to warrant its own config option.

6arms1leg commented 9 years ago

Not sure what you mean here. "On song level"?

I interpreted it this way: Fetch the image embedded in the ID3 tag for each audio file individually. For a artist/album structure, fetching the image once per album(/folder) is sufficient. However, if your collection contains self-made compilations in the form of private_compilation/tracks_from_different_artists the displayed image (fetched for the directory) may not belong to each song in that collection. :crystal_ball:

systems-rebooter commented 9 years ago

I'll have a look.

Thanks for that :)

The way it's coded, folder images should take priority. What's the file name of the image in the folder?

Image name in the folder was as following: 1206562924.jpg Folder contained only this image and no others. I got your point and tried to rename it to artist.jpg cover.jpg folder.jpg in a raw, with restarting CM and reopening collection with fresh browser in incognito window, but embed cover-art was still displayed. I believe this happens because ~/.local/share/cherrymusic/albumart/ already fulfilled with embed thumb, which is not rewritten if image added to folder later. Two quick questions: what's the file name of the image in the folder should be used? Will CM fallback and use image with any name if there is only one image in the folder?

That's a bug. It should display the default folder image. I'll open a ticket.

Thanks for that as well :)

What do you have in mind? We simply can't know which of the ID3-embedded images is the "best" to pick for a folder. In that case, it's better for the user to pick. To do that, select an image from the web by clicking on the little wrench icon of the folder.

Nevermind - if artist image will be displaying fine with 1st prio - I will be more than happy. @6arms1leg was very closed explaining what track-based collection means. Thanks for that! Sometimes its better to show once than explain many times :)

Collection for AMETSUB artist in folded view.

screen shot 2015-04-15 at 11 41 00

5 Remixes (9) 6 Tracks (7) 7 Ringtones (2) folders are track-based collection (since contains only tracks)

Collection for AMETSUB artist in unfolded view:

screen shot 2015-04-15 at 11 40 38

Not sure what you mean here. "On song level"?

I mean displaying embed covers here if possible:

screen shot 2015-04-15 at 12 08 38

What would you like to configure, enable/disable the use of embedded images?

Yep, I meant exactly that :)

Thanks for all you are doing guys!

UPDATE:

I believe this happens because ~/.local/share/cherrymusic/albumart/ already fulfilled with embed thumb, which is not rewritten if image added to folder later. Two quick questions: what's the file name of the image in the folder should be used? Will CM fallback and use image with any name if there is only one image in the folder?

Verified above by purging albumart/*thumb Artist image with any name fallbacking just fine after that.