| Crates.io | copyright_free_songs |
| lib.rs | copyright_free_songs |
| version | 67.0.44 |
| created_at | 2026-01-07 10:42:36.344502+00 |
| updated_at | 2026-01-07 10:42:36.344502+00 |
| description | High-quality integration for https://supermaker.ai/music/copyright-free-songs/ |
| homepage | https://supermaker.ai/music/copyright-free-songs/ |
| repository | https://github.com/qy-upup/copyright-free-songs |
| max_upload_size | |
| id | 2028020 |
| size | 13,947 |
A Rust crate for generating playlists and retrieving metadata for copyright-free music. Simplifies access to royalty-free audio resources for your projects.
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
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
// 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
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/