njh / ruby-playlist

A ruby gem to convert playlists between different formats
https://rubygems.org/gems/playlist
MIT License
7 stars 1 forks source link

output to JSON ? #15

Closed gordielachance closed 4 years ago

gordielachance commented 4 years ago

Hi, is there a way to output the tracklist as a JSON object, based, ideally, on the XSPF playlist (since it's a standard) ?

Thanks !

njh commented 4 years ago

I did add support for JSPF (http://www.xspf.org/jspf/) in 5ae308fabe93cf235e71db3360db2b3fdad3954f but it isn't in a released version. Is that any use to you?

Or would do you mean a JSON export of the internal data model? I was considering adding support for YAML and JSON. And maybe write a schema 🤔

gordielachance commented 4 years ago

wow ! JSPF would be exactly what i'm looking for. Didn't knew about that. For your information, i'm working on a music API, that's why i'm interested in your project. Would you considerer release that ? Thanks.

gordielachance commented 4 years ago

I'm quite new to Ruby, how could I test this ? (where are stored the gems ?) Thanks !!!

njh commented 4 years ago

I personally use bundler for my gems.

You can add the current git version to your project's Gemfile using:

gem 'rack', git: 'https://github.com/njh/ruby-playlist'

Otherwise you will have to clone the repo and then build and install the gem locally:

git clone https://github.com/njh/ruby-playlist
cd ruby-playlist/
gem install rspec rubocop yard
rake build
gem install ./pkg/playlist-1.3.0.gem
gordielachance commented 4 years ago

I guess you meant

 gem 'playlist', git: 'https://github.com/njh/ruby-playlist'

but anyway, OK, I got it, thanks !

gordielachance commented 4 years ago

I can confirm JSPF works with 1.3.0.

This is the output for the tracklist image - is this correct ? The specs here just show an URL. Track images seems ok (just an URL).

"image": {
  "height": null,
  "url": "https://i.scdn.co/image/ab67706c0000da84c3f4168e56a7662a53c0142a",
  "width": null
}

Thanks for your great work.

njh commented 4 years ago

Thanks for testing!

Ok, I will check the image thing and then make a release.

njh commented 4 years ago

Hi,

There isn't any code that would add width and height to an image object when serialising to JSPF. Are you assigning it from some kind of object, rather than a string?

I wonder if I should be calling #to_s on values somewhere - although it doesn't seem very rubyish.

gordielachance commented 4 years ago

mhh i'm check, yes, maybe that's my error. Thanks.

gordielachance commented 4 years ago

it was my error, thanks.