lib/get_happy/cli.rb in get_happy-1.0.0 vs lib/get_happy/cli.rb in get_happy-1.0.1

- old
+ new

@@ -20,11 +20,11 @@ list end desc "list", "list collection" def list - @collection ||= GetHappy.get_collection + @collection = GetHappy.get_collection user = `echo $USER`.gsub("\n", "") say " \n" say "\e[1m\e[4m#{user} Total #{@collection.size}\e[0m \n\n" @collection.each do |item| @@ -35,28 +35,41 @@ desc "clean", "clean collection" def clean @collection = [] GetHappy.write_collection([]) - say "Collection is empty" + say "Collection is empty", :green end desc "seed", "seed with some sample urls" def seed GetHappy.seed - @collection = GetHappy.get_collection list end desc "delete", "delete a url" def delete(url) - @collection ||= GetHappy.get_collection - @collection.delete(url.to_s) + @collection = GetHappy.get_collection + deleted = !!@collection.delete(url.to_s) GetHappy.write_collection(@collection) - list + say deleted, deleted ? :green : :red end + + desc "import_playlist [ID]", "import a youtube playlist" + def import_playlist(id) + GetHappy.ensure_user_data! + + playlist = GetHappy.get_playlist(id) + say "Found #{playlist.size} items" + + unless playlist.empty? + if yes?("Import playlist?", :green) + GetHappy.write_collection(playlist) + list + end + end + + end + end end - - -