
Security News
Node.js Homepage Adds Paid Support Link, Prompting Contributor Pushback
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
EasyMP3 is a Python library designed for individuals with limited Python experience to easily manipulate and tag their MP3 files programmatically. This library is a simplified wrapper around the mutagen library, providing simpler functions and expanded functionality.
pip install easymp3
from easymp3 import EasyMP3
songs_directory = r"path\to\songs"
tagger = EasyMP3(songs_directory, search_subfolders=True)
This will create a tagger object that contains the paths to all MP3 files in the given directory including MP3 files in subfolders of the directory.
String templates can be created using f strings and passing constants from the Tag
class.
For example:
from easymp3 import Tag
file_name_template = f"{Tag.TITLE} - {Tag.ARTIST}"
String templates can be used to set tags from the filename.
This will set the filename for all MP3 files in the tagger object.
Ex. Fast - Juice WRLD.mp3
.
from easymp3 import EasyMP3, Tag
songs_directory = r"path\to\songs"
tagger = EasyMP3(songs_directory, search_subfolders=True)
file_name_template = f"{Tag.TITLE} - {Tag.ARTIST}"
tagger.set_tags_from_filename(file_name_template)
String templates can also be used to set the filenames from the tags.
For all MP3 files in the tagger object that are correctly formatted, their title
and artist will be set accordingly. Ex. If the file is named Fast - Juice WRLD.mp3
then the title will be set to Fast, and the artist will be set to Juice WRLD.
from easymp3 import EasyMP3, Tag
songs_directory = r"path\to\songs"
tagger = EasyMP3(songs_directory, search_subfolders=True)
file_name_template = f"{Tag.TITLE} - {Tag.ARTIST}"
tagger.set_filename_from_tags(file_name_template)
For all MP3 files in the tagger object, their tags will be extracted to existing MP3
files (of the same filename) in a specified directory. Ex. for all MP3 files in songs_directory
,
their tags will be copied to a file of the same name in copy_directory
.
from easymp3 import EasyMP3
songs_directory = r"path\to\songs"
copy_directory = r"path\to\other\directory"
tagger = EasyMP3(songs_directory, search_subfolders=True)
tagger.copy_tags(copy_directory)
By specifying a directory for cover art images, cover art can be set for each MP3 file in the tagger object.
This will set the cover art for every MP3 file in the tagger object if
it is found. For example, if an MP3 is titled Fast.mp3
and there is a file
in covers_path
titled Fast.png,
that image will be set as the front
cover art for Fast.mp3
.
from easymp3 import EasyMP3
songs_directory = r"path\to\songs"
covers_path = r"path\to\covers"
tagger = EasyMP3(songs_directory, search_subfolders=True)
tagger.set_cover_art(covers_path)
Cover art can also be set by using a string template that represents how the cover images are named.
This will set the cover for all images that match the template.
For example, if an MP3 file is tagged such that the title is Fast
and the artist is Juice WRLD, then if an image file exists with
the name Fast - Juice WRLD,
that image will be set as the
front cover image.
from easymp3 import EasyMP3, Tag
songs_directory = r"path\to\songs"
covers_path = r"path\to\covers"
template_str = f"{Tag.TITLE} - {Tag.ARTIST}"
tagger = EasyMP3(songs_directory, search_subfolders=True)
tagger.set_cover_art(covers_path, template_str)
This will extract the cover art for all MP3 files in the tagger object
and name them using the filename of the original MP3 file. For example, if an
MP3 file is named Fast - Juice WRLD.mp3
, then the cover image will be named
Fast - Juice WRLD.png
(the extension can vary)
from easymp3 import EasyMP3
songs_directory = r"path\to\songs"
extracted_covers_path = r"path\to\covers"
tagger = EasyMP3(songs_directory, search_subfolders=True)
tagger.extract_cover_arts(extracted_covers_path)
The filenames for extracted cover art can also be set using a string template.
This will set all the extracted cover images as the template. For example, if MP3
file is tagged such that the title is Fast and the artist is Juice WRLD, then the
the extracted cover image will be named Fast - Juice WRLD.png
(the extension can vary)
from easymp3 import EasyMP3, Tag
songs_directory = r"path\to\songs"
extracted_covers_path = r"path\to\covers"
template_str = f"{Tag.TITLE} - {Tag.ARTIST}"
tagger = EasyMP3(songs_directory, search_subfolders=True)
tagger.extract_cover_arts(extracted_covers_path, template_str)
This will remove all tags from all MP3 files in the tagger object.
from easymp3 import EasyMP3
songs_directory = r"path\to\songs"
tagger = EasyMP3(songs_directory, search_subfolders=True)
tagger.remove_all_tags()
f'(?P<{attribute}>.+)
.EasyMP3 allows users to quickly create powerful scripts utilizing its features without needing to delve into the complexities of the mutagen library. This significantly lowers the barrier for users looking to manage their MP3 collections programmatically.
Contributions are welcome! Please fork the repository and submit a pull request with your changes.
This project is licensed under the MIT License.
FAQs
Easily tag and manipulate MP3 files in a programmatic way.
We found that easymp3 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.
Research
Security News
The Socket Research Team investigates a malicious Python typosquat of a popular password library that forces Windows shutdowns when input is incorrect.