Merge lp:~verterok/unity-scope-grooveshark/basic-preview into lp:unity-scope-grooveshark

Proposed by Guillermo Gonzalez
Status: Merged
Approved by: Guillermo Gonzalez
Approved revision: 43
Merged at revision: 42
Proposed branch: lp:~verterok/unity-scope-grooveshark/basic-preview
Merge into: lp:unity-scope-grooveshark
Diff against target: 158 lines (+47/-22)
3 files modified
debian/control (+1/-0)
po/unity-scope-grooveshark.pot (+14/-11)
src/unity_grooveshark_daemon.py (+32/-11)
To merge this branch: bzr merge lp:~verterok/unity-scope-grooveshark/basic-preview
Reviewer Review Type Date Requested Status
David Callé Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+184094@code.launchpad.net

Commit message

Add basic preview support.

Description of the change

Add basic preview support.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
David Callé (davidc3) wrote :

+1!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2013-05-23 13:39:20 +0000
3+++ debian/control 2013-09-06 14:55:54 +0000
4@@ -7,6 +7,7 @@
5 python3-distutils-extra,
6 pkg-config,
7 python3-nose,
8+ python3-gi,
9 gir1.2-unity-5.0 (>= 7),
10 gir1.2-dee-1.0,
11 gir1.2-glib-2.0,
12
13=== modified file 'po/unity-scope-grooveshark.pot'
14--- po/unity-scope-grooveshark.pot 2013-02-21 00:56:34 +0000
15+++ po/unity-scope-grooveshark.pot 2013-09-06 14:55:54 +0000
16@@ -8,7 +8,7 @@
17 msgstr ""
18 "Project-Id-Version: PACKAGE VERSION\n"
19 "Report-Msgid-Bugs-To: \n"
20-"POT-Creation-Date: 2013-02-21 01:56+0100\n"
21+"POT-Creation-Date: 2013-09-04 17:50-0300\n"
22 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
23 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
24 "Language-Team: LANGUAGE <LL@li.org>\n"
25@@ -17,34 +17,37 @@
26 "Content-Type: text/plain; charset=CHARSET\n"
27 "Content-Transfer-Encoding: 8bit\n"
28
29-#: ../src/unity_grooveshark_daemon.py:37 ../data/grooveshark.scope.in.h:4
30+#: ../src/unity_grooveshark_daemon.py:38 ../data/grooveshark.scope.in.h:4
31 msgid "Search Grooveshark"
32 msgstr ""
33
34-#: ../src/unity_grooveshark_daemon.py:38
35+#: ../src/unity_grooveshark_daemon.py:39
36 msgid "Sorry, there are no Grooveshark song or album that matches your search."
37 msgstr ""
38
39-#: ../src/unity_grooveshark_daemon.py:39
40+#: ../src/unity_grooveshark_daemon.py:40
41 msgid "Powered by Grooveshark"
42 msgstr ""
43
44-#: ../src/unity_grooveshark_daemon.py:47
45+#: ../src/unity_grooveshark_daemon.py:48
46 msgid "Songs"
47 msgstr ""
48
49-#: ../src/unity_grooveshark_daemon.py:51
50+#: ../src/unity_grooveshark_daemon.py:52
51 msgid "Albums"
52 msgstr ""
53
54+#: ../src/unity_grooveshark_daemon.py:188 ../data/grooveshark.scope.in.h:2
55+msgid "Grooveshark"
56+msgstr ""
57+
58 #: ../data/grooveshark.scope.in.h:1
59 msgid "music;grooveshark;"
60 msgstr ""
61
62-#: ../data/grooveshark.scope.in.h:2
63-msgid "Grooveshark"
64-msgstr ""
65-
66 #: ../data/grooveshark.scope.in.h:3
67-msgid "Find Grooveshark songs and albums"
68+msgid ""
69+"This is an Ubuntu search plugin that enables information from Grooveshark to "
70+"be searched and displayed in the Dash underneath the Music header. If you do "
71+"not wish to search this content source, you can disable this search plugin."
72 msgstr ""
73
74=== modified file 'src/unity_grooveshark_daemon.py'
75--- src/unity_grooveshark_daemon.py 2013-03-13 10:09:43 +0000
76+++ src/unity_grooveshark_daemon.py 2013-09-06 14:55:54 +0000
77@@ -17,7 +17,7 @@
78 # You should have received a copy of the GNU General Public License
79 # along with this program. If not, see <http://www.gnu.org/licenses/>.
80
81-from gi.repository import Unity, UnityExtras
82+from gi.repository import Unity
83 from gi.repository import Gio, GLib
84 import urllib.parse
85 import urllib.request
86@@ -88,12 +88,11 @@
87 return results
88 search = urllib.parse.quote(search)
89 uri = "%ss/%s?format=json&key=%s&limit=32" % (SEARCH_URI, search, API_KEY)
90- print(uri)
91 try:
92 response = urllib.request.urlopen(uri).read()
93 data = json.loads(response.decode('utf8'))
94 except Exception as error:
95- print(error)
96+ print("[grooveshark] Error: ", error)
97 return results
98 albums_seen = {}
99 for i in data:
100@@ -163,14 +162,30 @@
101 if m['id'] == e:
102 i['metadata'][e] = i[e]
103 i['metadata']['provider_credits'] = GLib.Variant('s', PROVIDER_CREDITS)
104- result = Unity.ScopeResult.create(str(i['uri']), str(i['icon']),
105- i['category'], i['result_type'],
106- str(i['mimetype']), str(i['title']),
107- str(i['comment']), str(i['dnd_uri']),
108- i['metadata'])
109- result_set.add_result(result)
110+ result_set.add_result(**i)
111 except Exception as error:
112- print (error)
113+ print("[grooveshark] Error: ", error)
114+
115+
116+class Preview (Unity.ResultPreviewer):
117+
118+ def do_run(self):
119+ title = self.result.title.strip()
120+ artist = self.result.metadata['artist'].get_string().strip()
121+ album = self.result.metadata['album'].get_string().strip()
122+ description = self.result.comment.strip()
123+ preview = Unity.MusicPreview.new(title, description, None)
124+ if title != album:
125+ preview.props.subtitle = artist + " - " + album
126+ else:
127+ preview.props.subtitle = artist
128+ image = self.result.icon_hint
129+ preview.props.image_source_uri = image
130+ icon = Gio.FileIcon.new (Gio.file_new_for_path(PROVIDER_ICON))
131+ view_action = Unity.PreviewAction.new("view", _("Grooveshark"), icon)
132+ preview.add_action(view_action)
133+ return preview
134+
135
136 class Scope (Unity.AbstractScope):
137 def __init__(self):
138@@ -210,7 +225,7 @@
139 '''
140 fs = Unity.FilterSet.new ()
141 # if FILTERS:
142-#
143+#
144 return fs
145
146 def do_get_group_name (self):
147@@ -223,5 +238,11 @@
148 se = MySearch (search_context)
149 return se
150
151+ def do_create_previewer(self, result, metadata):
152+ rp = Preview()
153+ rp.set_scope_result(result)
154+ rp.set_search_metadata(metadata)
155+ return rp
156+
157 def load_scope():
158 return Scope()

Subscribers

People subscribed via source and target branches