mirror of
https://github.com/fergalmoran/picard.git
synced 2026-02-25 09:03:59 +00:00
Normalize variable names according to python naming scheme
This commit is contained in:
@@ -28,16 +28,16 @@ from picard.util import webbrowser2, build_qurl
|
||||
|
||||
class FileLookup(object):
|
||||
|
||||
def __init__(self, parent, server, port, localPort):
|
||||
def __init__(self, parent, server, port, local_port):
|
||||
self.server = server
|
||||
self.localPort = int(localPort)
|
||||
self.local_port = int(local_port)
|
||||
self.port = port
|
||||
|
||||
def _url(self, path, params=None):
|
||||
if params is None:
|
||||
params = {}
|
||||
if self.localPort:
|
||||
params['tport'] = self.localPort
|
||||
if self.local_port:
|
||||
params['tport'] = self.local_port
|
||||
url = build_qurl(self.server, self.port, path=path, queryargs=params)
|
||||
return url.toEncoded()
|
||||
|
||||
@@ -51,36 +51,36 @@ class FileLookup(object):
|
||||
webbrowser2.open(url)
|
||||
return True
|
||||
|
||||
def discLookup(self, url):
|
||||
if self.localPort:
|
||||
url = "%s&tport=%d" % (url, self.localPort)
|
||||
def disc_lookup(self, url):
|
||||
if self.local_port:
|
||||
url = "%s&tport=%d" % (url, self.local_port)
|
||||
return self.launch(url)
|
||||
|
||||
def _lookup(self, type_, id_):
|
||||
return self._build_launch("/%s/%s" % (type_, id_))
|
||||
|
||||
def recordingLookup(self, recording_id):
|
||||
def recording_lookup(self, recording_id):
|
||||
return self._lookup('recording', recording_id)
|
||||
|
||||
def albumLookup(self, album_id):
|
||||
def album_lookup(self, album_id):
|
||||
return self._lookup('release', album_id)
|
||||
|
||||
def artistLookup(self, artist_id):
|
||||
def artist_lookup(self, artist_id):
|
||||
return self._lookup('artist', artist_id)
|
||||
|
||||
def trackLookup(self, track_id):
|
||||
def track_lookup(self, track_id):
|
||||
return self._lookup('track', track_id)
|
||||
|
||||
def workLookup(self, work_id):
|
||||
def work_lookup(self, work_id):
|
||||
return self._lookup('work', work_id)
|
||||
|
||||
def releaseGroupLookup(self, releaseGroup_id):
|
||||
return self._lookup('release-group', releaseGroup_id)
|
||||
def release_group_lookup(self, release_group_id):
|
||||
return self._lookup('release-group', release_group_id)
|
||||
|
||||
def acoustLookup(self, acoust_id):
|
||||
def acoust_lookup(self, acoust_id):
|
||||
return self.launch(PICARD_URLS['acoustid_track'] + acoust_id)
|
||||
|
||||
def mbidLookup(self, string, type_):
|
||||
def mbid_lookup(self, string, type_):
|
||||
"""Parses string for known entity type and mbid, open browser for it
|
||||
If entity type is 'release', it will load corresponding release if
|
||||
possible.
|
||||
@@ -101,28 +101,7 @@ class FileLookup(object):
|
||||
return True
|
||||
return self._lookup(entity, mbid)
|
||||
|
||||
def _search(self, type_, query, adv=False):
|
||||
if self.mbidLookup(query, type_):
|
||||
return True
|
||||
params = {
|
||||
'limit': QUERY_LIMIT,
|
||||
'type': type_,
|
||||
'query': query,
|
||||
}
|
||||
if adv:
|
||||
params['adv'] = 'on'
|
||||
return self._build_launch('/search/textsearch', params)
|
||||
|
||||
def artistSearch(self, query, adv=False):
|
||||
return self._search('artist', query, adv)
|
||||
|
||||
def albumSearch(self, query, adv=False):
|
||||
return self._search('release', query, adv)
|
||||
|
||||
def trackSearch(self, query, adv=False):
|
||||
return self._search('recording', query, adv)
|
||||
|
||||
def tagLookup(self, artist, release, track, trackNum, duration, filename):
|
||||
def tag_lookup(self, artist, release, track, trackNum, duration, filename):
|
||||
params = {
|
||||
'artist': artist,
|
||||
'release': release,
|
||||
@@ -133,5 +112,26 @@ class FileLookup(object):
|
||||
}
|
||||
return self._build_launch('/taglookup', params)
|
||||
|
||||
def collectionLookup(self, userid):
|
||||
def collection_lookup(self, userid):
|
||||
return self._build_launch('/user/%s/collections' % userid)
|
||||
|
||||
def _search(self, type_, query, adv=False):
|
||||
if self.mbid_lookup(query, type_):
|
||||
return True
|
||||
params = {
|
||||
'limit': QUERY_LIMIT,
|
||||
'type': type_,
|
||||
'query': query,
|
||||
}
|
||||
if adv:
|
||||
params['adv'] = 'on'
|
||||
return self._build_launch('/search/textsearch', params)
|
||||
|
||||
def artist_search(self, query, adv=False):
|
||||
return self._search('artist', query, adv)
|
||||
|
||||
def album_search(self, query, adv=False):
|
||||
return self._search('release', query, adv)
|
||||
|
||||
def track_search(self, query, adv=False):
|
||||
return self._search('recording', query, adv)
|
||||
|
||||
@@ -475,15 +475,15 @@ class Tagger(QtWidgets.QApplication):
|
||||
"""Search on the MusicBrainz website."""
|
||||
lookup = self.get_file_lookup()
|
||||
if config.setting["builtin_search"]:
|
||||
if search_type == "track" and not lookup.mbidLookup(text, 'recording'):
|
||||
if search_type == "track" and not lookup.mbid_lookup(text, 'recording'):
|
||||
dialog = TrackSearchDialog(self.window)
|
||||
dialog.search(text)
|
||||
dialog.exec_()
|
||||
elif search_type == "album" and not lookup.mbidLookup(text, 'release'):
|
||||
elif search_type == "album" and not lookup.mbid_lookup(text, 'release'):
|
||||
dialog = AlbumSearchDialog(self.window)
|
||||
dialog.search(text)
|
||||
dialog.exec_()
|
||||
elif search_type == "artist" and not lookup.mbidLookup(text, 'artist'):
|
||||
elif search_type == "artist" and not lookup.mbid_lookup(text, 'artist'):
|
||||
dialog = ArtistSearchDialog(self.window)
|
||||
dialog.search(text)
|
||||
dialog.exec_()
|
||||
@@ -493,7 +493,7 @@ class Tagger(QtWidgets.QApplication):
|
||||
def collection_lookup(self):
|
||||
"""Lookup the users collections on the MusicBrainz website."""
|
||||
lookup = self.get_file_lookup()
|
||||
lookup.collectionLookup(config.persist["oauth_username"])
|
||||
lookup.collection_lookup(config.persist["oauth_username"])
|
||||
|
||||
def browser_lookup(self, item):
|
||||
"""Lookup the object's metadata on the MusicBrainz website."""
|
||||
@@ -503,11 +503,11 @@ class Tagger(QtWidgets.QApplication):
|
||||
if isinstance(item, DataObject):
|
||||
itemid = item.id
|
||||
if isinstance(item, Track):
|
||||
lookup.recordingLookup(itemid)
|
||||
lookup.recording_lookup(itemid)
|
||||
elif isinstance(item, Album):
|
||||
lookup.albumLookup(itemid)
|
||||
lookup.album_lookup(itemid)
|
||||
else:
|
||||
lookup.tagLookup(
|
||||
lookup.tag_lookup(
|
||||
metadata["albumartist"] if item.is_album_like() else metadata["artist"],
|
||||
metadata["album"],
|
||||
metadata["title"],
|
||||
|
||||
@@ -65,5 +65,5 @@ class CDLookupDialog(PicardDialog):
|
||||
|
||||
def lookup(self):
|
||||
lookup = self.tagger.get_file_lookup()
|
||||
lookup.discLookup(self.disc.submission_url)
|
||||
lookup.disc_lookup(self.disc.submission_url)
|
||||
QtWidgets.QDialog.accept(self)
|
||||
|
||||
@@ -240,7 +240,7 @@ class CoverArtThumbnail(ActiveLabel):
|
||||
|
||||
def open_release_page(self):
|
||||
lookup = self.tagger.get_file_lookup()
|
||||
lookup.albumLookup(self.release)
|
||||
lookup.album_lookup(self.release)
|
||||
|
||||
|
||||
def set_image_replace(obj, coverartimage):
|
||||
|
||||
@@ -203,14 +203,14 @@ class MetadataBox(QtWidgets.QTableWidget):
|
||||
def lookup_tags(self):
|
||||
lookup = self.get_file_lookup()
|
||||
LOOKUP_TAGS = {
|
||||
"musicbrainz_recordingid": lookup.recordingLookup,
|
||||
"musicbrainz_trackid": lookup.trackLookup,
|
||||
"musicbrainz_albumid": lookup.albumLookup,
|
||||
"musicbrainz_workid": lookup.workLookup,
|
||||
"musicbrainz_artistid": lookup.artistLookup,
|
||||
"musicbrainz_albumartistid": lookup.artistLookup,
|
||||
"musicbrainz_releasegroupid": lookup.releaseGroupLookup,
|
||||
"acoustid_id": lookup.acoustLookup
|
||||
"musicbrainz_recordingid": lookup.recording_lookup,
|
||||
"musicbrainz_trackid": lookup.track_lookup,
|
||||
"musicbrainz_albumid": lookup.album_lookup,
|
||||
"musicbrainz_workid": lookup.work_lookup,
|
||||
"musicbrainz_artistid": lookup.artist_lookup,
|
||||
"musicbrainz_albumartistid": lookup.artist_lookup,
|
||||
"musicbrainz_releasegroupid": lookup.release_group_lookup,
|
||||
"acoustid_id": lookup.acoust_lookup
|
||||
}
|
||||
return LOOKUP_TAGS
|
||||
|
||||
|
||||
Reference in New Issue
Block a user