Giter Site home page Giter Site logo

mtagger's Introduction

MTagger

MTagger is a library designed to load MP3 files downloaded from YouTube and retrieve and update their metadata, including title, artist, album, and genre. This ensures your music files have complete metadata, making them compatible with applications like Serato.

THIS LIBRARY IS OFFERED AS-IS, NO GUARANTEES

Features

  • Load MP3 Files or Folders: Load individual MP3 files or entire folders of MP3s downloaded from YouTube.
  • Retrieve Metadata: Use the LLM, YouTube API, and Google Search to find and retrieve metadata for the MP3 files.
    • Title
    • Artist
    • Album
    • Genre
  • Update Metadata: Automatically update the MP3 files with the retrieved metadata for compatibility with applications like Serato.

Installation

TODO

Usage

Load and Update a Single MP3 File

from mtagger import MetadataExtractor

# Initialize the metadata extractor
extractor = MetadataExtractor(
    yt_api_key='YOUR_YOUTUBE_API_KEY',
    spotify_client_id='YOUR_SPOTIFY_CLIENT_ID',
    spotify_client_secret='YOUR_SPOTIFY_CLIENT_SECRET'
)

# Load an MP3 file
mp3_file = 'path/to/your/downloaded/mp3file.mp3'

# Retrieve and update metadata
metadata = extractor.get_metadata(str)
extractor.update_metadata(metadata)

# Print the updated metadata
print("Title:", metadata.title)
print("Artist:", metadata.artist)
print("Album:", metadata.album)
print("Genre:", metadata.genre)

Load and Update All MP3 Files in a Folder

from mtagger import MetadataExtractor

# Initialize the metadata extractor
extractor = MetadataExtractor(
    yt_api_key='YOUR_YOUTUBE_API_KEY',
    spotify_client_id='YOUR_SPOTIFY_CLIENT_ID',
    spotify_client_secret='YOUR_SPOTIFY_CLIENT_SECRET'
)

# Load a folder containing MP3 files
folder_path = 'path/to/your/downloaded/mp3files/'

# Some extra metadata for LLM to infer metadata
extra_metadata = 'possible genres: bachata, salsa, zouk'

# Retrieve and update metadata for all files in the folder
extractor.update_metadata_for_folder(folder_path=folder_path, extra_metadata=extra_metadata)

Configuration

Provide your YouTube API key to use the YouTube API features when initializing the MetadataExtractor class.

API Reference

MetadataExtractor

__init__(self, api_key: str)

  • Initializes the metadata extractor with the necessary API key for YouTube.

get_metadata(self, mp3_file: str) -> dict

  • Retrieves metadata for the given MP3 file.
  • Parameters:
    • mp3_file: The path to the MP3 file.
  • Returns: A SeratoMetadata object containing the metadata (title, artist, album, genre).

update_metadata(self, mp3_file: str, metadata: dict)

  • Updates the given MP3 file with the provided metadata.
  • Parameters:
    • mp3_file: The path to the MP3 file.
    • SeratoMetadata: An object containing the metadata (title, artist, album, genre).

update_metadata_for_folder(self, folder_path: str)

  • Retrieves and updates metadata for all MP3 files in the specified folder.
  • Parameters:
    • folder_path: The path to the folder containing MP3 files.
    • extra_metadata: Extra metadata that you think might help the LLM infer metadata

License

This project is licensed under the MIT License.

mtagger's People

Contributors

aldarisbm avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.