Sha256: 77b7c30dfb0714e757766dcf86ceb85fc3842e9fcb17c820013dde4baf7470b1

Contents?: true

Size: 914 Bytes

Versions: 6

Compression:

Stored size: 914 Bytes

Contents

# coding: utf-8

# Require support code, used by all the examples.
require_relative 'example_support'
session = Hallon::Session.instance

while username = prompt("Enter a Spotify username: ")
  begin
    puts "Loading #{username}."
    user = Hallon::User.new(username)

    puts "Fetching published playlists for #{username}..."
    published = user.published.load

    puts "Loading #{published.size} playlists."
    all_playlists = published.contents.find_all do |playlist|
      playlist.is_a?(Hallon::Playlist) # ignore folders
    end

    all_playlists.each(&:load)

    all_playlists.each do |playlist|
      puts
      puts "Listing tracks for #{playlist.name} (#{playlist.to_str}):"

      tracks = playlist.tracks.to_a.map(&:load)
      tracks.each_with_index do |track, i|
        puts "\t (#{i+1}/#{playlist.size}) #{track.name}"
      end
    end
  rescue Interrupt
    puts "Interrupted!"
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hallon-0.18.2 examples/show_published_playlists_of_user.rb
hallon-0.18.1 examples/show_published_playlists_of_user.rb
hallon-0.18.0 examples/show_published_playlists_of_user.rb
hallon-0.17.0 examples/show_published_playlists_of_user.rb
hallon-0.16.0 examples/show_published_playlists_of_user.rb
hallon-0.15.0 examples/show_published_playlists_of_user.rb