Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_lazy_load_filters(album.tagger.config.setting)
url = str(QtCore.QUrl.fromPercentEncoding(path))
if url in _cache:
tags = apply_translations_and_sally(_cache[url], sally, factor)
_tags_finalize(album, metadata, current + tags, next)
else:
# If we have already sent a request for this URL, delay this call until later
if url in _pending_xmlws_requests:
_pending_xmlws_requests[url].append(partial(get_tags, album, metadata, path, sally, factor, next, current))
else:
_pending_xmlws_requests[url] = []
album._requests += 1
album.tagger.xmlws.get(LASTFM_HOST, LASTFM_PORT, path,
partial(_tags_downloaded, album, metadata, sally, factor, next, current),
priority=True, important=True)
def process_track(album, metadata, release, track):
tagger = album.tagger
use_track_tags = tagger.config.setting["lastfm_use_track_tags"]
use_artist_tags = tagger.config.setting["lastfm_artist_tag_us_ex"] or tagger.config.setting["lastfm_artist_tag_us_yes"]
if use_track_tags or use_artist_tags:
artist = metadata["artist"]
title = metadata["title"]
if artist:
if use_artist_tags:
get_artist_tags_func = partial(get_artist_tags, album, metadata, artist, None)
else:
get_artist_tags_func = None
if title and use_track_tags:
get_track_tags(album, metadata, artist, title, get_artist_tags_func, [])
elif get_artist_tags_func:
get_artist_tags_func([])
def get_tags(album, metadata, path, sally, factor, next, current):
"""Get tags from an URL."""
# Ensure config is loaded (or reloaded if has been changed)
_lazy_load_filters(album.tagger.config.setting)
url = str(QtCore.QUrl.fromPercentEncoding(path))
if url in _cache:
tags = apply_translations_and_sally(_cache[url], sally, factor)
_tags_finalize(album, metadata, current + tags, next)
else:
# If we have already sent a request for this URL, delay this call until later
if url in _pending_xmlws_requests:
_pending_xmlws_requests[url].append(partial(get_tags, album, metadata, path, sally, factor, next, current))
else:
_pending_xmlws_requests[url] = []
album._requests += 1
album.tagger.xmlws.get(LASTFM_HOST, LASTFM_PORT, path,
partial(_tags_downloaded, album, metadata, sally, factor, next, current),
priority=True, important=True)
_lazy_load_filters(album.tagger.config.setting)
url = str(QtCore.QUrl.fromPercentEncoding(path))
if url in _cache:
tags = apply_translations_and_sally(_cache[url], sally, factor)
_tags_finalize(album, metadata, current + tags, next)
else:
# If we have already sent a request for this URL, delay this call until later
if url in _pending_xmlws_requests:
_pending_xmlws_requests[url].append(partial(get_tags, album, metadata, path, sally, factor, next, current))
else:
_pending_xmlws_requests[url] = []
album._requests += 1
album.tagger.xmlws.get(LASTFM_HOST, LASTFM_PORT, path,
partial(_tags_downloaded, album, metadata, sally, factor, next, current),
priority=True, important=True)
def _add_file_to_queue(self, file):
thread.run_task(
partial(self._calculate_replaygain, file),
partial(self._replaygain_callback, file))
def post(album, host, port, path, data, handler, position=None):
func = partial(_post, album, host, port, path, data, handler)
album.tagger.xmlws.add_task(func, position)
def finalize_genres(styles, metadata, target, albumtitle, albumartist, album, html):
if styles == [] and target == "album_data" and albumartist != "Various Artists":
album._requests += 1
album.tagger.xmlws.add_task(partial(artist_search, album, metadata, albumtitle, albumartist), position=1)
elif styles == [] and (target == "artist_data" or target == "artist_search"):
album._requests += 1
album.tagger.xmlws.add_task(partial(scrape_genres, html, album, "scrape_genre", albumtitle, albumartist, metadata), position=1)
elif styles == []:
print " * Dang, couldn't find anything!\n"
else:
metadata["genre"] = styles
for track in album._new_tracks:
track.metadata["genre"] = styles
print "\n"
# return cached PUID
puids = file.metadata.getall('musicip_puid')
if puids:
next(result=puids[0])
return
# use cached fingerpring
fingerprints = file.metadata.getall('musicip_fingerprint')
if fingerprints:
self._lookup_fingerprint(self.tagger.analyze_queue.next,
file.filename, result=(fingerprints[0], 0))
return
# calculate fingerprint
if ofa is not None:
if file not in self._analyze_tasks:
task = (partial(self.calculate_fingerprint, file.filename),
partial(self._lookup_fingerprint, self.tagger._lookup_puid, file.filename),
QtCore.Qt.LowEventPriority + 1)
self._analyze_tasks[file] = task
self.tagger.analyze_queue.put(task)
return
# no PUID
next(result=None)