After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 761694 - [lastfm] order thumbnails by size
[lastfm] order thumbnails by size
Status: RESOLVED FIXED
Product: grilo
Classification: Other
Component: plugins
git master
Other Linux
: Normal normal
: ---
Assigned To: grilo-maint
grilo-maint
Depends on:
Blocks:
 
 
Reported: 2016-02-08 00:00 UTC by Marinus Schraal
Modified: 2016-02-22 22:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
sort albumart urls large->small (994 bytes, patch)
2016-02-08 00:00 UTC, Marinus Schraal
none Details | Review
v2 (996 bytes, patch)
2016-02-08 14:14 UTC, Marinus Schraal
none Details | Review
order by size v3 (1.07 KB, patch)
2016-02-20 13:56 UTC, Marinus Schraal
none Details | Review
lastfm: order by size (1.45 KB, patch)
2016-02-22 17:51 UTC, Marinus Schraal
none Details | Review
lastfm: return empty (1.45 KB, patch)
2016-02-22 17:52 UTC, Marinus Schraal
none Details | Review

Description Marinus Schraal 2016-02-08 00:00:47 UTC
Created attachment 320595 [details] [review]
sort albumart urls large->small

I noticed with the new lua lastfm plugin, gnome-music retrieved very small albumart and upscaled it.

It looks like the old plugin ordered the retrieved albumart urls from large to small, this patch does the same.
Comment 1 Marinus Schraal 2016-02-08 14:14:17 UTC
Created attachment 320630 [details] [review]
v2

noticed the debug statement could have a null url in the new setup and this would generate a warning, so moved it inside the check.
Comment 2 Victor Toso 2016-02-20 10:08:33 UTC
Review of attachment 320595 [details] [review]:

This is obsolete to v2
Comment 3 Victor Toso 2016-02-20 10:27:29 UTC
Review of attachment 320630 [details] [review]:

Patch does not have comment, we need that ;)

::: src/lua-factory/sources/grl-lastfm-cover.lua
@@ +74,2 @@
 function fetch_page_cb(result, userdata)
+  local url

As this is used only inside the for scope, I would define it there

@@ +82,2 @@
   userdata.media.thumbnail = {}
+  image_sizes = { "mega", "extralarge", "large", "medium", "small" }

consider putting this outside of this scope as LASTFM_THUMBNAIL_SIZES
or include the local keyword: `local image_sizes = ...`

@@ +82,3 @@
   userdata.media.thumbnail = {}
+  image_sizes = { "mega", "extralarge", "large", "medium", "small" }
+  for c, u in pairs(image_sizes) do

you are not using c so you can switch it to _
also, consider changing u to 'image_size' or just 'size'

@@ +85,3 @@
+    url = string.match(result, '<image size="' .. u .. '">(.-)</image>')
+
+    if (url ~= nil and url ~= '') then

I don't mind () but the other conditionals in the code are not using it so bet remove it;

@@ +91,1 @@
   end

Could you please also add a patch to fix the case where userdata.media.thumbnail could be empty?
IIRC we discussed this at IRC and it was happening...

if #userdata.media.thumbnail == 0 then
 grl.callback()
 return
end
Comment 4 Marinus Schraal 2016-02-20 13:56:56 UTC
Created attachment 321726 [details] [review]
order by size v3

Changes as requested, as well as returning an empty result set (see bug #761852 -> where the supposed attachment was missing).
Comment 5 Victor Toso 2016-02-22 11:18:29 UTC
Review of attachment 321726 [details] [review]:

Could you split in two patches, add commit log and also the minor fix needed?

Thanks!

::: src/lua-factory/sources/grl-lastfm-cover.lua
@@ +88,3 @@
+    if url ~= nil and url ~= '' then
+      grl.debug ('Image size ' .. size .. ' = ' .. url)
+      if v ~= '' then

There is no 'v' now

@@ +98,3 @@
+  else
+    userdata.callback(userdata.media, 0)
+  end

Yes! But it should be in a different patch
Comment 6 Marinus Schraal 2016-02-22 17:51:38 UTC
Created attachment 321876 [details] [review]
lastfm: order by size

Order by size large->small patch.
Comment 7 Marinus Schraal 2016-02-22 17:52:35 UTC
Created attachment 321877 [details] [review]
lastfm: return empty

Lastfm: return an empty result if no covers are found.