~matttbe/ubuntu/raring/rhythmbox/lp1010619_RB_2.98

« back to all changes in this revision

Viewing changes to plugins/artsearch/musicbrainz.py

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2012-11-06 20:52:57 UTC
  • mfrom: (1.1.67) (214.1.1 quantal-proposed)
  • Revision ID: package-import@ubuntu.com-20121106205257-0btjh8jqley153el
Tags: 2.98-0ubuntu1
* New upstream release (LP: #1060601)
* debian/control.in:
  - Bump minimum glib, gtk, totem-plparser, clutter, and clutter-gst
  - Drop no longer needed musicbrainz dependency
* Refreshed 09_keywords.patch
* Updated 11_fix_cd_pausing.patch with fix from git
* Dropped patches applied in new version:
  - 00git_musicbrainz5.patch
  - 08_CVE-2012-3355.patch
  - dont_free_consumed_floating_gvariant.patch
  - git_scale_click.patch
  - git_crash_during_monitor.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
import xml.dom.minidom as dom
28
28
 
29
 
import rb
 
29
import rb, urllib
30
30
from gi.repository import RB
31
31
 
32
32
# musicbrainz URLs
34
34
MUSICBRAINZ_RELEASE_PREFIX = "http://musicbrainz.org/release/"
35
35
MUSICBRAINZ_RELEASE_SUFFIX = ".html"
36
36
 
 
37
MUSICBRAINZ_SEARCH_QUERY = "artist:\"%s\" AND release:\"%s\""
 
38
MUSICBRAINZ_SEARCH_URL = "http://musicbrainz.org/ws/2/release/?query=%s&limit=1"
 
39
 
37
40
# musicbrainz IDs
38
41
MUSICBRAINZ_VARIOUS_ARTISTS = "89ad4ac3-39f7-470e-963a-56509c546377"
39
42
 
84
87
                        print "exception parsing musicbrainz response: %s" % e
85
88
                        callback(*cbargs)
86
89
 
 
90
        def try_search_artist_album (self, key, store, callback, *args):
 
91
                album = key.get_field("album")
 
92
                artist = key.get_field("artist")
 
93
 
 
94
                if not album or not artist:
 
95
                        print "artist or album information missing"
 
96
                        callback(*args)
 
97
                        return
 
98
 
 
99
                query = MUSICBRAINZ_SEARCH_QUERY % (artist.lower(), album.lower())
 
100
                url = MUSICBRAINZ_SEARCH_URL % (urllib.quote(query, safe=':'),)
 
101
 
 
102
                loader = rb.Loader()
 
103
                loader.get_url(url, self.get_release_cb, (key, store, callback, args))
 
104
 
87
105
        def search(self, key, last_time, store, callback, *args):
88
106
                key = key.copy()        # ugh
89
107
                album_id = key.get_info("musicbrainz-albumid")
90
108
                if album_id is None:
91
109
                        print "no musicbrainz release ID for this track"
92
 
                        callback(*args)
 
110
                        self.try_search_artist_album(key, store, callback, args)
93
111
                        return
94
112
 
95
113
                if album_id.startswith(MUSICBRAINZ_RELEASE_PREFIX):