copyright_free_songs

Crates.iocopyright_free_songs
lib.rscopyright_free_songs
version67.0.44
created_at2026-01-07 10:42:36.344502+00
updated_at2026-01-07 10:42:36.344502+00
descriptionHigh-quality integration for https://supermaker.ai/music/copyright-free-songs/
homepagehttps://supermaker.ai/music/copyright-free-songs/
repositoryhttps://github.com/qy-upup/copyright-free-songs
max_upload_size
id2028020
size13,947
(qy-upup)

documentation

README

copyright-free-songs

A Rust crate for generating playlists and retrieving metadata for copyright-free music. Simplifies access to royalty-free audio resources for your projects.

Installation

To include copyright-free-songs in your Rust project, add the following to your Cargo.toml file under the [dependencies] section: toml copyright-free-songs = "0.1.0" # Replace with the latest version

Usage Examples

Here are a few examples demonstrating how to use the copyright-free-songs crate:

1. Generating a Random Playlist:

This example shows how to generate a playlist of 10 random copyright-free songs. rust use copyright_free_songs::{PlaylistGenerator, Genre};

fn main() { let generator = PlaylistGenerator::new(); let playlist = generator.generate_playlist(10, None); // None for any genre

println!("Generated Playlist:");
for song in &playlist {
    println!("- {} by {}", song.title, song.artist);
}

}

2. Filtering by Genre:

This example demonstrates how to generate a playlist consisting only of songs from a specific genre (e.g., Electronic). rust use copyright_free_songs::{PlaylistGenerator, Genre};

fn main() { let generator = PlaylistGenerator::new(); let playlist = generator.generate_playlist(5, Some(Genre::Electronic));

println!("Electronic Playlist:");
for song in &playlist {
    println!("- {} by {}", song.title, song.artist);
}

}

3. Retrieving Song Metadata:

This example shows how to retrieve detailed metadata for a specific song. rust use copyright_free_songs::{Song, Genre};

fn main() { // Simulate retrieving a song (in a real application, this might come from a database or API) let song = Song { title: "Inspiring Hope".to_string(), artist: "John Smith".to_string(), genre: Genre::Ambient, duration_seconds: 180, url: "https://example.com/inspiring_hope.mp3".to_string(), };

println!("Song Metadata:");
println!("Title: {}", song.title);
println!("Artist: {}", song.artist);
println!("Genre: {:?}", song.genre);
println!("Duration: {} seconds", song.duration_seconds);
println!("URL: {}", song.url);

}

4. Creating a Playlist with Specific Duration Constraints (Hypothetical):

This showcases a planned, but not yet implemented feature. rust // Hypothetical example - feature not yet implemented // use copyright_free_songs::{PlaylistGenerator, Genre};

// fn main() { // let generator = PlaylistGenerator::new(); // let playlist = generator.generate_playlist_with_duration(300, None); // 300 seconds total duration

// println!("Playlist with target duration of 300 seconds:"); // for song in &playlist { // println!("- {} by {}", song.title, song.artist); // } // }

5. Working with a Larger Catalog (Hypothetical):

This demonstrates how the crate could be used with a larger, potentially externally sourced catalog of songs. rust // Hypothetical example - assumes a way to load a custom catalog // use copyright_free_songs::{PlaylistGenerator, Song, Genre};

// fn main() { // let custom_catalog: Vec = load_custom_catalog_from_somewhere(); // Replace with actual loading logic // let generator = PlaylistGenerator::with_catalog(custom_catalog); // let playlist = generator.generate_playlist(5, Some(Genre::Classical));

// println!("Custom Catalog Playlist:"); // for song in &playlist { // println!("- {} by {}", song.title, song.artist); // } // }

// Placeholder for loading a custom catalog (implementation not provided) // fn load_custom_catalog_from_somewhere() -> Vec { // // In a real application, this would load data from a file, database, or API. // Vec::new() // }

Feature Summary

  • Playlist Generation: Easily create playlists of copyright-free music with adjustable length and genre filters.
  • Song Metadata Retrieval: Access detailed information about each song, including title, artist, genre, duration, and URL.
  • Genre Filtering: Select songs from specific genres to match your project's aesthetic.
  • Extensible Catalog (Planned): Future versions will support loading custom song catalogs for greater flexibility.
  • Duration Constraints (Planned): Future versions will allow generating playlists with specific total durations.

License

This crate is licensed under the MIT License.

This crate is part of the copyright-free-songs ecosystem. For advanced features and enterprise-grade tools, visit: https://supermaker.ai/music/copyright-free-songs/

Commit count: 0

cargo fmt