Merge lp:~submarine/ubuntu-scopes/soundcloud-previews into lp:~submarine/ubuntu-scopes/soundcloud

Proposed by David Callé
Status: Merged
Approved by: Michal Hruby
Approved revision: 27
Merged at revision: 24
Proposed branch: lp:~submarine/ubuntu-scopes/soundcloud-previews
Merge into: lp:~submarine/ubuntu-scopes/soundcloud
Diff against target: 68 lines (+28/-14)
1 file modified
src/unity_soundcloud_daemon.py (+28/-14)
To merge this branch: bzr merge lp:~submarine/ubuntu-scopes/soundcloud-previews
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Michal Hruby (community) Approve
Review via email: mp+155727@code.launchpad.net

Commit message

Initial previews (with music streaming).

Description of the change

- Initial previews (with music streaming).
- Sort results by "hotness"

To post a comment you must log in.
25. By David Callé

Order results by "hotness"

26. By David Callé

Limit to 30 results

27. By David Callé

"Artist" in previews, instead of "By Artist"

Revision history for this message
Michal Hruby (mhr3) wrote :

Looks good.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/unity_soundcloud_daemon.py'
--- src/unity_soundcloud_daemon.py 2013-03-14 12:29:11 +0000
+++ src/unity_soundcloud_daemon.py 2013-03-28 16:12:20 +0000
@@ -89,7 +89,7 @@
89 if not search:89 if not search:
90 return results90 return results
91 search = urllib.parse.quote(search)91 search = urllib.parse.quote(search)
92 uri = "%stracks.json?consumer_key=%s&q=%s" % (SEARCH_URI, API_KEY, search)92 uri = "%stracks.json?consumer_key=%s&q=%s&order=hotness&limit=30" % (SEARCH_URI, API_KEY, search)
93 print(uri)93 print(uri)
94 data = []94 data = []
95 try:95 try:
@@ -160,22 +160,30 @@
160 i['comment'] = ''160 i['comment'] = ''
161 if not 'dnd_uri' in i or not i['dnd_uri'] or i['dnd_uri'] == '':161 if not 'dnd_uri' in i or not i['dnd_uri'] or i['dnd_uri'] == '':
162 i['dnd_uri'] = i['uri']162 i['dnd_uri'] = i['uri']
163 i['metadata'] = {}163 result_set.add_result(**i)
164 if EXTRA_METADATA:
165 for e in i:
166 for m in EXTRA_METADATA:
167 if m['id'] == e:
168 i['metadata'][e] = i[e]
169 i['metadata']['provider_credits'] = GLib.Variant('s', PROVIDER_CREDITS)
170 result = Unity.ScopeResult.create(str(i['uri']), str(i['icon']),
171 i['category'], i['result_type'],
172 str(i['mimetype']), str(i['title']),
173 str(i['comment']), str(i['dnd_uri']),
174 i['metadata'])
175 result_set.add_result(result)
176 except Exception as error:164 except Exception as error:
177 print (error)165 print (error)
178166
167class Preview (Unity.ResultPreviewer):
168
169 def do_run(self):
170 title = self.result.title.strip()
171 stream = self.result.metadata['stream'].get_string()
172 duration = int(self.result.metadata['duration'].get_string())
173 author = self.result.metadata['artist'].get_string()
174 description = self.result.comment.strip()
175 image = self.result.icon_hint.replace('large.jpg', 'original.jpg')
176 preview = Unity.MusicPreview.new(title, description, None)
177 if stream != '':
178 t = Unity.TrackMetadata.full(stream, 1, title, author, '', duration / 1000)
179 preview.add_track(t)
180 preview.props.subtitle = author
181 preview.props.image_source_uri = image
182 icon = Gio.FileIcon.new (Gio.file_new_for_path(PROVIDER_ICON))
183 view_action = Unity.PreviewAction.new("view", _("SoundCloud"), icon)
184 preview.add_action(view_action)
185 return preview
186
179class Scope (Unity.AbstractScope):187class Scope (Unity.AbstractScope):
180 def __init__(self):188 def __init__(self):
181 Unity.AbstractScope.__init__(self)189 Unity.AbstractScope.__init__(self)
@@ -227,5 +235,11 @@
227 se = MySearch (search_context)235 se = MySearch (search_context)
228 return se236 return se
229237
238 def do_create_previewer(self, result, metadata):
239 rp = Preview()
240 rp.set_scope_result(result)
241 rp.set_search_metadata(metadata)
242 return rp
243
230def load_scope():244def load_scope():
231 return Scope()245 return Scope()

Subscribers

People subscribed via source and target branches

to all changes: