Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _test_ascii_windows_compatibility(self):
metadata = Metadata()
metadata['artist'] = '\u2216/\\\u2215'
settings = config.setting.copy()
settings['ascii_filenames'] = True
filename = script_to_filename('%artist%/\u2216\\\\\u2215', metadata, settings=settings)
self.assertEqual('____/_\\_', filename)
def save(self):
config.setting["use_proxy"] = self.ui.web_proxy.isChecked()
config.setting["proxy_server_host"] = self.ui.server_host.text()
config.setting["proxy_server_port"] = self.ui.server_port.value()
config.setting["proxy_username"] = self.ui.username.text()
config.setting["proxy_password"] = self.ui.password.text()
self.tagger.webservice.setup_proxy()
config.setting["browser_integration"] = self.ui.browser_integration.isChecked()
config.setting["browser_integration_port"] = self.ui.browser_integration_port.value()
config.setting["browser_integration_localhost_only"] = \
self.ui.browser_integration_localhost_only.isChecked()
self.update_browser_integration()
def format_performer_tags(album, metadata, *args):
word_dict = get_word_dict(config.setting)
for key, values in list(filter(lambda filter_tuple: filter_tuple[0].startswith('performer:') or filter_tuple[0].startswith('~performersort:'), metadata.rawitems())):
rewrite_tag(key, values, metadata, word_dict, config.setting)
def update_layout_config(self):
config.setting['toolbar_layout'] = self._all_list_items()
self._update_toolbar()
def __iter__(self):
enabled_plugins = config.setting["enabled_plugins"]
for name in self.__dict:
if name is None or name in enabled_plugins:
for item in self.__dict[name]:
yield item
def load(self):
self.ui.api_key.setText(config.setting["musixmatch_api_key"])
def save(self):
self._set_settings(config.setting)
def next_in_queue(self):
"""Downloads next item in queue.
If there are none left, loading of album will be finalized.
"""
if self.album.id not in self.album.tagger.albums:
# album removed
return
if (self.front_image_found
and config.setting["save_images_to_tags"]
and not config.setting["save_images_to_files"]
and config.setting["embed_only_one_front_image"]):
# no need to continue
self.album._finalize_loading(None)
return
if self._queue_empty():
try:
# requeue from next provider
provider = next(self.providers)
ret = CoverArtProvider._STARTED
try:
instance = provider.cls(self)
if provider.enabled and instance.enabled():
log.debug("Trying cover art provider %s ..." %
provider.name)
ret = instance.queue_images()
else:
def images_to_be_saved_to_tags(self):
if not config.setting["save_images_to_tags"]:
return ()
images = [img for img in self.images if img.can_be_saved_to_tags]
if config.setting["embed_only_one_front_image"]:
front_image = self.get_single_front_image(images)
if front_image:
return front_image
return images
def _save(self, filename, metadata):
"""Save metadata to the file."""
log.debug("Saving file %r", filename)
file = self._File(encode_filename(filename))
if file.tags is None:
file.add_tags()
if config.setting["clear_existing_tags"]:
file.tags.clear()
if self._File == mutagen.flac.FLAC and (
config.setting["clear_existing_tags"] or
(config.setting['save_images_to_tags'] and metadata.images)):
file.clear_pictures()
tags = {}
for name, value in metadata.items():
if name == '~rating':
# Save rating according to http://code.google.com/p/quodlibet/wiki/Specs_VorbisComments
if config.setting['rating_user_email']:
name = 'rating:%s' % config.setting['rating_user_email']
else:
name = 'rating'
value = unicode(float(value) / (config.setting['rating_steps'] - 1))
# don't save private tags
elif name.startswith("~"):
continue
if name.startswith('lyrics:'):
name = 'lyrics'
elif name == "date" or name == "originaldate":