Merge lp:~stolowski/unity-scope-mediascanner/fix-1340952 into lp:unity-scope-mediascanner

Proposed by Paweł Stołowski
Status: Merged
Approved by: James Henstridge
Approved revision: 168
Merged at revision: 169
Proposed branch: lp:~stolowski/unity-scope-mediascanner/fix-1340952
Merge into: lp:unity-scope-mediascanner
Diff against target: 114 lines (+27/-11)
4 files modified
src/music-scope.cpp (+8/-2)
src/video-scope.cpp (+12/-2)
tests/test-music-scope.cpp (+4/-4)
tests/test-video-scope.cpp (+3/-3)
To merge this branch: bzr merge lp:~stolowski/unity-scope-mediascanner/fix-1340952
Reviewer Review Type Date Requested Status
James Henstridge Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+232084@code.launchpad.net

Commit message

Use music:// for individual song files and video:// uris for video files in medisanner music/video scopes.

Description of the change

Use music:// for individual song files and video:// uris for video files in medisanner music/video scopes. This change also required minor adjustement to the image uri for these types for results.

NOTE: requires handler for video:// schema (a MP for this is coming soon).

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
James Henstridge (jamesh) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/music-scope.cpp'
2--- src/music-scope.cpp 2014-08-13 10:14:32 +0000
3+++ src/music-scope.cpp 2014-08-25 13:55:45 +0000
4@@ -363,10 +363,16 @@
5
6 unity::scopes::CategorisedResult MusicQuery::create_song_result(unity::scopes::Category::SCPtr const& category, mediascanner::MediaFile const& media) const
7 {
8+ std::string uri = media.getUri();
9+ if (uri.find("file://") == 0)
10+ {
11+ uri = "music://" + uri.substr(7); // replace file:// with music://
12+ }
13 CategorisedResult res(category);
14- res.set_uri(media.getUri());
15- res.set_dnd_uri(media.getUri());
16+ res.set_uri(uri);
17+ res.set_dnd_uri(uri);
18 res.set_title(media.getTitle());
19+ res.set_art(scope.make_album_art_uri(media.getAlbumArtist(), media.getAlbum()));
20
21 res["duration"] = media.getDuration();
22 res["album"] = media.getAlbum();
23
24=== modified file 'src/video-scope.cpp'
25--- src/video-scope.cpp 2014-08-01 14:46:26 +0000
26+++ src/video-scope.cpp 2014-08-25 13:55:45 +0000
27@@ -183,9 +183,17 @@
28 break;
29 }
30
31+ std::string uri = media.getUri();
32+ std::string imguri;
33+ if (uri.find("file://") == 0) {
34+ imguri = "image://thumbnailer/" + uri.substr(7);
35+ uri = "video://" + uri.substr(7); // replace file:// with video://
36+ }
37+
38 CategorisedResult res(cat);
39- res.set_uri(media.getUri());
40- res.set_dnd_uri(media.getUri());
41+ res.set_uri(uri);
42+ res.set_dnd_uri(uri);
43+ res.set_art(imguri);
44 res.set_title(media.getTitle());
45
46 res["duration"] =media.getDuration();
47@@ -225,12 +233,14 @@
48
49 PreviewWidget video("video", "video");
50 video.add_attribute_mapping("source", "uri");
51+ video.add_attribute_mapping("screenshot", "art");
52
53 PreviewWidget actions("actions", "actions");
54 {
55 VariantBuilder builder;
56 builder.add_tuple({
57 {"id", Variant("play")},
58+ {"uri", Variant(result().uri())}, // this is a video:// uri
59 {"label", Variant(_("Play"))}
60 });
61 actions.add_attribute_value("actions", builder.end());
62
63=== modified file 'tests/test-music-scope.cpp'
64--- tests/test-music-scope.cpp 2014-08-04 15:52:05 +0000
65+++ tests/test-music-scope.cpp 2014-08-25 13:55:45 +0000
66@@ -176,13 +176,13 @@
67 .WillOnce(Return(albums_category));
68
69 EXPECT_CALL(reply, push(Matcher<CategorisedResult const&>(AllOf(
70- ResultProp("uri", "scope://mediascanner%2Dmusic?q=The%20John%20Butler%20Trio&dep=albums%5Fof%5Fartist"),
71+ ResultUriMatchesCannedQuery(CannedQuery("mediascanner-music", "The John Butler Trio", "albums_of_artist")),
72 ResultProp("title", "The John Butler Trio")))))
73 .WillOnce(Return(true));
74
75 EXPECT_CALL(reply, push(Matcher<CategorisedResult const&>(AllOf(
76- ResultProp("uri", "file:///path/foo7.ogg"),
77- ResultProp("dnd_uri", "file:///path/foo7.ogg"),
78+ ResultProp("uri", "music:///path/foo7.ogg"),
79+ ResultProp("dnd_uri", "music:///path/foo7.ogg"),
80 ResultProp("title", "One Way Road"),
81 ResultProp("duration", 185),
82 ResultProp("album", "April Uprising"),
83@@ -337,7 +337,7 @@
84
85 TEST_F(MusicScopeTest, PreviewSong) {
86 unity::scopes::testing::Result result;
87- result.set_uri("file:///xyz");
88+ result.set_uri("music:///xyz");
89 result.set_title("Song title");
90 result["artist"] = "Artist name";
91 result["album"] = "Album name";
92
93=== modified file 'tests/test-video-scope.cpp'
94--- tests/test-video-scope.cpp 2014-07-31 06:26:08 +0000
95+++ tests/test-video-scope.cpp 2014-08-25 13:55:45 +0000
96@@ -117,8 +117,8 @@
97 EXPECT_CALL(reply, register_category("local", _, _, _))
98 .WillOnce(Return(category));
99 EXPECT_CALL(reply, push(Matcher<CategorisedResult const&>(AllOf(
100- ResultProp("uri", "file:///path/bigbuckbunny.ogv"),
101- ResultProp("dnd_uri", "file:///path/bigbuckbunny.ogv"),
102+ ResultProp("uri", "video:///path/bigbuckbunny.ogv"),
103+ ResultProp("dnd_uri", "video:///path/bigbuckbunny.ogv"),
104 ResultProp("title", "Big Buck Bunny"),
105 ResultProp("duration", 596)))))
106 .WillOnce(Return(true));
107@@ -226,7 +226,7 @@
108
109 TEST_F(VideoScopeTest, PreviewVideo) {
110 unity::scopes::testing::Result result;
111- result.set_uri("file:///xyz");
112+ result.set_uri("video:///xyz");
113 result.set_title("Video title");
114 result["duration"] = 42;
115

Subscribers

People subscribed via source and target branches

to all changes: