Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Recompute the key if it is missing or invalid
valid_keys = keyfinder.notations.camelot.values()
if not media.key or not media.key.strip("0") in valid_keys:
media.key = ""
self.execute_paralell(self.compute_key, identifier, media)
# Request more details from beatport
if importer.beatport.has_metadata(media):
self.execute_paralell(self.beatport_update, identifier, media)
self.mediafiles[identifier] = media
self.cache_art(media.artwork)
# Report track details
track = mediafile.serialize(media, trim_path=self.import_path)
self.send_details(identifier, track)
def report_state(self, ws):
# Report existing tracks and current processes. Events will be batched
# together and dispatched.
for identifier, media in self.mediafiles.items():
track = mediafile.serialize(media, trim_path=self.import_path)
self.send_details(identifier, track)
for identifier, process in self.processing:
self.send_processing(identifier, process)
# Track is a single
if len(tracks) == 1:
media.disc = ''
media.track = ''
media.album = ''
# Track is part of an album (multiple tracks)
else:
media.track.total = len(tracks)
media.disc = '1/1'
if media.genre in genre_remapping:
media.genre = genre_remapping[media.genre]
updated = mediafile.serialize(media)
# Return only changed values
return {k: v for k, v in updated.items() if updated[k] != orig[k]}
response = requests.get(release_url)
release = bs4.BeautifulSoup(response.content, 'html.parser')
# Get the list of tracks
tracks = release.select('div.bucket.tracks ul.bucket-items li')
# Get a mapping of track details (under the artwork)
details = release.select('ul.interior-release-chart-content-list')[0]
details = details.select('li')
details = [i.find_all('span') for i in details]
details = {s[0].text.lower(): s[1].text.strip() for s in details}
# Update the track, reporting only modified fields.
orig = mediafile.serialize(media)
media.release = details['catalog']
# Track is a single
if len(tracks) == 1:
media.disc = ''
media.track = ''
media.album = ''
# Track is part of an album (multiple tracks)
else:
media.track.total = len(tracks)
media.disc = '1/1'
if media.genre in genre_remapping:
media.genre = genre_remapping[media.genre]