https://github.com/njh/ruby-playlist
A ruby gem to convert playlists between different formats
https://github.com/njh/ruby-playlist
cue-sheet jspf m3u playlist ruby xspf
Last synced: 7 months ago
JSON representation
A ruby gem to convert playlists between different formats
- Host: GitHub
- URL: https://github.com/njh/ruby-playlist
- Owner: njh
- License: mit
- Created: 2018-07-10T07:43:28.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2021-03-16T01:01:12.000Z (over 4 years ago)
- Last Synced: 2024-04-25T21:45:41.716Z (over 1 year ago)
- Topics: cue-sheet, jspf, m3u, playlist, ruby, xspf
- Language: Ruby
- Homepage: https://rubygems.org/gems/playlist
- Size: 72.3 KB
- Stars: 7
- Watchers: 3
- Forks: 1
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
[](https://travis-ci.org/njh/ruby-playlist)
# Playlist
This ruby gem allows you to create and manipulate playlists of musical tracks.
It supports parsing and generating playlists in the following formats:
* Cue Sheet
* JSPF
* M3U
* PLS
* XSPF
* A simple human readable format## Installation
Add this line to your application's Gemfile:
```ruby
gem 'playlist'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install playlist
## Usage
For full details, please see the [API Documentation](https://www.rubydoc.info/gems/playlist/).
### Creating a Playlist
The `playlist` gem provides data model classes for creating and manipulating
playlists and music metadata in ruby.Playlists can be constructed by passing a list of attributes to the constructor or by setting the attributes directly:
```ruby
playlist = Playlist.new(:title => "My awesome playlist")
playlist.description = "Each week I add best tracks I can think of."
playlist.add_track(
:performer => "Jon Hopkins",
:title => "Everything Connected"
)track = Playlist::Track.new(:title => "Get Your Shirt")
track.add_contributor(:name => "Underworld", :role => :performer)
track.add_contributor(:name => "Iggy Pop", :role => :performer)
playlist.add_track(track)
```### Parsing a playlist file
The `playlist` gem supports a number of different playlist file formats.
Here is an example of parsing a M3U file:```ruby
File.open("playlist.m3u") do |file|
playlist = Playlist::Format::M3U.parse(file)
puts "The playlist contains #{playlist.tracks.count} tracks"
end
```### Generating a playlist file
Having created a `Playlist` object, it can be converted to a playlist file using:
```ruby
File.open("playlist.m3u", "wb") do |file|
file.write Playlist::Format::M3U.generate(playlist)
end
```## Development
After checking out the repo, run `bundle install` to install dependencies. Then, run `rake spec` to run the tests.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/njh/ruby-playlist.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).