I actually have a small plugin which provides me two functions $is_lossless() and $is_lossy(). The functions also try to detect whether a mp4 is lossy or lossless. Maybe I should publish it if you want to try this place the following code in a file called e.g. islossless.py inside the Picard plugin folder (click on “Open plugin folder” in Options > Plugins):
# -*- coding: utf-8 -*-
PLUGIN_NAME = 'Tagger script functions is_lossless() and is_lossy()'
PLUGIN_AUTHOR = 'Philipp Wolfer'
PLUGIN_DESCRIPTION = 'Tagger script functions to detect if a file is lossless or lossy'
PLUGIN_VERSION = "0.1"
PLUGIN_API_VERSIONS = ["1.3.0", "2.0", "2.1", "2.2"]
PLUGIN_LICENSE = "GPL-2.0"
PLUGIN_LICENSE_URL = "https://www.gnu.org/licenses/gpl-2.0.html"
from picard.script import register_script_function
LOSSLESS_EXTENSIONS = ['flac', 'oggflac', 'ape', 'ofr', 'tak', 'wv', 'tta', 'wav']
def is_lossless(parser):
"""
Returns true, if the file processed is a lossless audio format.
Note: This depends mainly on the file extension and does not look inside the
file to detect the codec.
"""
if parser.context['~extension'] in LOSSLESS_EXTENSIONS:
return "1"
elif parser.context['~extension'] == 'm4a':
# Mutagen < 1.26 fails to detect the bitrate for Apple Lossless Audio Codec.
if not parser.context['~bitrate'] or parser.context['~bitrate'] > 1000:
return "1"
else:
return ""
else:
return ""
def is_lossy(parser):
"""Returns true, if the file processed is a lossy audio format."""
if is_lossless(parser) == "1":
return ""
else:
return "1"
register_script_function(is_lossless)
register_script_function(is_lossy)
Enable the plugin in Pcicard’s options, then you can use it like this:
Just realized that “wav” should also be in the lossless extension list. I updated the plugin code above. I initially did not add this as I don’t use WAV and Picard does not save tags to WAV anyway, so I think it should nearly always be better to use FLAC instead except you absolutely need it to be in WAV format for some reason
Hi @outsidecontext! Do you think this pluginn would still work with the latest version? I’ve followed your advice on how to install but it seems Picard doesn’t list the plugin and I’m thinkning that things might have changed since 2017?
Hey there, I used this script for a few years now. Somehow my old version (1.4.2 it was I think) could not load data anymore from the server. So I updated to the newest one (2.3.2). Now the script doesnt work anymore. I tried to add to the PLUGIN_API “2.3.2” like this:
PLUGIN_API_VERSIONS = [“1.3.0”, “2.0”, “2.1”, “2.2”, “2.3”, “2.3.2”]
Since it didnt work I also added 2.3 as seen, but this didnt work eighter. I double click install on my .py but nothing happens and it is not seen in Picard. Was something fundamentally changed in the plugin handling?
Really loved this separation and worked amazing. This would really destroy my library handling if this was no more feasible. Can anyone help me?
Thank you very much
Edit: Nevermind it suddenly works exactly like this! Thank you very much, seems like I was somehow not able to see that it worked hahaha
Edit2: Ok turns out the script is there but still doesnt work it is not moving my files and it says under renaming "1:4:$is_lossless: Unkown funktion ‘$is_lossless’ , which tells me it doesnt understand the string anymore?
The plugin I posted above should work, it’s exactly what I use. Can you make sure the plugin is enabled in Options > Plugins ? It should look like this:
I want to point out, that I only downloaded the new installer, that asked me to uninstall the old version and reinstalled the new one. Person settings were not deleted, but my old plugin was gone anyway…
It worked prior the way that it put lossy files unter “mp3/Artist/Album” and Lossless under “FLAC/Artist/Album”.
Should I see the strings from the plugin under scripting? since there is anything inside:
It is a few years since I set that up and I cant remember what I did back then to make it work the way I descripe it above, but it worked perfectly fine.
EDIT: Ok I found the problem! I couldn’t activate the plugin (red X stayed always), since I had the new $is_lossy in my tagging. Therefor it never saved the activation… I had to BACKUP!!! my string, set it to default, activate the script, SAVE, copy my old string back in and it looks like it works again!
It seems like it didnt save the activation of the plugin since it didnt know the string without the plugin and couldnt save.
Edit 2: Works perfectly again! Thank you very much! I hope you understand the “loop” that caused my problem described above lol. Basicly it didnt let me save the activation of the plugin due to the string the plugin adds was unknown lol
Thanks rdswift, you are right. The Problem was that I enabled it (green mark) but it never saved since the old string was already in and it would not save since it didnt know the string (seems like the string is only known after saving the settings, which I couldnt do, since it didnt know the string). I hope you see the viciouse circle
I got a new computer and needed to reinstall this plugin and am now getting an error message.
File “C:\Users\Willi\AppData\Local\MusicBrainz\Picard\plugins\islossless.py”, line 24, in is_lossless
if not parser.context[’~bitrate’] or parser.context[’~bitrate’] > 1000:
TypeError: ‘>’ not supported between instances of ‘str’ and ‘int’
Is anyone else running into this or know how to fix it?