Code Monkey home page Code Monkey logo

piwigo-api's Introduction

Piwigo-API

codecov Gem Version

Piwigo is open source web application to manage your collection of photos, and other medias. Piwigo provides an API for interacting with it.

This is a ruby-based client for interacting with a Piwigo instance using the Piwigo API.

Installation

Add this line to your application's Gemfile:

gem 'piwigo-api'

And then execute:

$ bundle

Or install it yourself as:

$ gem install piwigo-api

Usage

Just include 'piwigo/session' and the related classes, then querying Piwigo is fairly quick and straightforward. The latest RubyDocs for piwigo-api can be loacated on rubydoc.info.

Get the second album and all of it's children

require 'piwigo/session'
require 'piwigo/albums'

session = Piwigo::Session.login('mypiwigo.fqdn', 'Adrian', 'mypassword', https: false) 
unless session.nil? 
    albums = Piwigo::Albums.list(session, album_id: 2, recursive: true)
    albums.each { |album| p "#{album.id}, #{album.name} - # of photos: #{album.total_nb_images}" }
end

Add a new album

require 'piwigo/session'
require 'piwigo/albums'

session = Piwigo::Session.login('10.100.230.78', 'Adrian', 'mypassword', https: false) 
unless session.nil? 
    album = Piwigo::Albums::Album.new
    album.name = "My First Album"
    album = Piwigo::Albums.add(session, album)
end

List the Contents of an Album

require 'piwigo/session'
require 'piwigo/images'

session = Piwigo::Session.login('mypiwigo.fqdn', 'Adrian', 'mypassword', https: false) 
unless session.nil? 
    results = Piwigo::Images.getImages(session, album_id: 4)
    results[:images].each { |image| p "#{image.id}, #{image.name} - #{image.element_url}" }
end

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

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.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/kkdad/piwigo-ruby.

License

The gem is available as open source under the terms of the MIT License.

piwigo-api's People

Contributors

dependabot[bot] avatar kkdad avatar

Watchers

 avatar  avatar

Forkers

isaacfeliu

piwigo-api's Issues

fqn contains a port number

How do i enter a port number?

I get the error below

``check_host': bad component(expected host component): [localhost:8083] (URI::InvalidComponentError)`

401 error when uploading image

Hello,

thank you for the reply, I thought id open a new issue, i seem to be getting a 401 error at the time of the actual upload

I, [2022-01-18T21:23:43.321917 #19151] INFO -- : Login succeeded: {"stat":"ok","result":true} I, [2022-01-18T21:23:43.331532 #19151] INFO -- : Status succeeded I, [2022-01-18T21:23:43.343459 #19151] INFO -- : Album List succeeded: 1 albums retrieved. I, [2022-01-18T21:23:43.343791 #19151] INFO -- : Encoding: Feet First - UTF-8 Uploading I, [2022-01-18T21:23:43.894072 #19151] INFO -- : --> File::Stat: #<File::Stat dev=0x802, ino=6684768, mode=0100644, nlink=1, uid=1000, gid=1000, rdev=0x0, size=2105388, blksize=4096, blocks=4120, atime=2022-01-15 13:33:28 -0500, mtime=2022-01-15 13:33:28 -0500, ctime=2022-01-18 21:00:56 -0500> I, [2022-01-18T21:23:43.894181 #19151] INFO -- : {:date_creation=>"2022-01-18"} E, [2022-01-18T21:23:43.902640 #19151] ERROR -- : Unexpected error: 401
I used the example you provided and this is what I get, your example uses a windows path, I am using Linux not certain if this makes a difference

Using SSL with Net::HTTP

Initially I thought it would be enough to add this after line 98: http.use_ssl = https

http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri)

But after looking at the other files, I think we should either add this modification to the other files, since they initiate their own http connection, or make Session share its own http connection.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.