programming:python:libgal3
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
programming:python:libgal3 [2010/12/16 18:44] – [Downloading] jay | programming:python:libgal3 [2012/02/22 23:22] – [Donations] jay | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== What is it? ====== | + | ====== Python Gallery 3 Library ====== |
+ | |||
+ | ===== What is it? ===== | ||
This is a library to wrap the new Gallery 3 REST API in a nice, handy Python library. | This is a library to wrap the new Gallery 3 REST API in a nice, handy Python library. | ||
This is still an early release, but it functions quite well and has some nice features from a performance standpoint like //lazy// access to sub-items (the images in an album, for example). | This is still an early release, but it functions quite well and has some nice features from a performance standpoint like //lazy// access to sub-items (the images in an album, for example). | ||
- | ====== License | + | ===== License ===== |
This project is licensed under the GPLv3. | This project is licensed under the GPLv3. | ||
- | ====== Downloading | + | ===== Downloading ===== |
- | You can download the package here: {{: | + | You can download the package here: {{: |
You can also track this project on [[https:// | You can also track this project on [[https:// | ||
- | ====== | + | ===== Donations |
+ | By no means should anyone feel they //have// to donate. | ||
+ | |||
+ | < | ||
+ | <form action=" | ||
+ | <input type=" | ||
+ | <input type=" | ||
+ | <input type=" | ||
+ | <img alt="" | ||
+ | </ | ||
+ | </ | ||
+ | ===== Installing | ||
Install is pretty easy if you've ever installed another Python package. | Install is pretty easy if you've ever installed another Python package. | ||
< | < | ||
- | $ tar -xvzf pylibgal3-*.tar.gz | + | # tar -xvzf pylibgal3-*.tar.gz |
- | $ cd pylibgal3-* | + | # cd pylibgal3-* |
- | $ sudo python setup.py install | + | # sudo python setup.py install |
</ | </ | ||
That's about it for the install. | That's about it for the install. | ||
- | ====== Usage ====== | + | ===== Usage ===== |
- | ===== Logging In ===== | + | ==== Logging In ==== |
This is a pretty simple to use library. | This is a pretty simple to use library. | ||
Line 40: | Line 53: | ||
# access with ssl=True. | # access with ssl=True. | ||
# standard ssl port of 443, you would use this for your constructor: | # standard ssl port of 443, you would use this for your constructor: | ||
- | # gal = libg3.Gallery3(hostname , apiKey , g3Base=g3Base , port=443 , ssl=True | + | # gal = libg3.Gallery3(hostname , apiKey , g3Base=g3Base , port=443 , ssl=True) |
</ | </ | ||
We'll get to usage on the '' | We'll get to usage on the '' | ||
Line 56: | Line 69: | ||
Now that you have your Gallery3 object, let's get to what you can do with it. | Now that you have your Gallery3 object, let's get to what you can do with it. | ||
- | ===== Core Gallery Items ===== | + | ==== Core Gallery Items ==== |
First, lets give you a brief explanation of the basic elements you will be dealing with, There are a total of five core Gallery elements that we will explore here. | First, lets give you a brief explanation of the basic elements you will be dealing with, There are a total of five core Gallery elements that we will explore here. | ||
- **Album** - Basically, this is a container to hold other items, including other albums. | - **Album** - Basically, this is a container to hold other items, including other albums. | ||
Line 65: | Line 78: | ||
- | ===== Exploring the Root Album ===== | + | ==== Exploring the Root Album ==== |
As you may, or may not, be aware, the root of your gallery is considered to be an album just like any other album you create within it. This means that it is the base of a tree structure you create. | As you may, or may not, be aware, the root of your gallery is considered to be an album just like any other album you create within it. This means that it is the base of a tree structure you create. | ||
Line 150: | Line 163: | ||
An important thing to note with some of the above. | An important thing to note with some of the above. | ||
- | ===== Images | + | ==== Images ==== |
Now, let's take a look at a RemoteImage: | Now, let's take a look at a RemoteImage: | ||
<code python> | <code python> | ||
Line 224: | Line 237: | ||
</ | </ | ||
- | ===== Comments | + | ==== Comments ==== |
We will only look at comments (and tags) briefly. | We will only look at comments (and tags) briefly. | ||
Line 259: | Line 272: | ||
</ | </ | ||
- | ===== Tags ===== | + | ==== Tags ==== |
Tags are a bit like comments. | Tags are a bit like comments. | ||
<code python> | <code python> | ||
Line 285: | Line 298: | ||
</ | </ | ||
- | ===== Additional | + | ==== Additional Info ==== |
That about finishes up with the basics of the readable attributes for each of the core items. | That about finishes up with the basics of the readable attributes for each of the core items. | ||
* pydoc libg3.G3Items.Album | * pydoc libg3.G3Items.Album | ||
Line 292: | Line 305: | ||
* pydoc libg3.G3Items.Comment | * pydoc libg3.G3Items.Comment | ||
* pydoc libg3.G3Items.Tag | * pydoc libg3.G3Items.Tag | ||
+ | * pydoc libg3.Gallery3 | ||
Now, let's move on to working with our different items. | Now, let's move on to working with our different items. | ||
- | ===== Working With Albums | + | ==== Working With Albums ==== |
This is about as easy as it gets. You just call the '' | This is about as easy as it gets. You just call the '' | ||
<code python> | <code python> | ||
Line 332: | Line 346: | ||
To do the same with a movie, just use " | To do the same with a movie, just use " | ||
- | ===== Working With Images | + | ==== Working With Images ==== |
Now, there are not as many things you can do with images (or movies) as you can with albums so this will be brief. | Now, there are not as many things you can do with images (or movies) as you can with albums so this will be brief. | ||
Line 359: | Line 373: | ||
# Then you can just write this out as a local file | # Then you can just write this out as a local file | ||
open(newRemoteImage.name , ' | open(newRemoteImage.name , ' | ||
- | < | + | |
+ | # Get a handle to the resized image and download it | ||
+ | resized = firstImage.getResizeHandle() | ||
+ | outfile = open(' | ||
+ | outfile.write(resized.read()) | ||
+ | outfile.close() | ||
+ | |||
+ | # Get a handle to the resized image and download it | ||
+ | thumb = firstImage.getThumbHandle() | ||
+ | outfile = open(' | ||
+ | outfile.write(thumb.read()) | ||
+ | outfile.close() | ||
+ | </code> | ||
Of course, you can tag images too. | Of course, you can tag images too. | ||
Line 369: | Line 395: | ||
You can perform all these same operations with a RemoteMovie object as well. | You can perform all these same operations with a RemoteMovie object as well. | ||
- | ===== The Future | + | ==== Another Item of Interest ==== |
+ | It should also be pointed out that almost all of the functionality described above can also be done with different objects and method calls to your main Gallery3 object. | ||
+ | <code python> | ||
+ | gal = libg3.Gallery3(hostname , apiKey , g3Base=g3Base) | ||
+ | root = gal.getRoot() | ||
+ | firstAlbum = root.Albums[0] | ||
+ | # Now let's get the first image out of the first sub-album: | ||
+ | image = firstAlbum.Images[0] | ||
+ | # Now, we can always tag this image with the following: | ||
+ | image.tag(' | ||
+ | # But, we can also tag an item (image or album) by using our main " | ||
+ | gal.tagItem(image , ' | ||
+ | # For another example, let's show the 2 ways we can set the cover for an album | ||
+ | # First is using an album object: | ||
+ | firstAlbum.setCover(image) | ||
+ | # But we can also use our main " | ||
+ | gal.setAlbumCover(firstAlbum , image) | ||
+ | </ | ||
+ | It's worth noting that calling '' | ||
+ | ==== The Future ==== | ||
As you can see, there is a good deal of functionality here, but it is by no means complete. | As you can see, there is a good deal of functionality here, but it is by no means complete. | ||
* Make images and thumbnails resizable | * Make images and thumbnails resizable | ||
- | * Access to thumbnail downloads | ||
* Reordering of members in an album | * Reordering of members in an album | ||
* Make all editable properties editable | * Make all editable properties editable | ||
- | * I'm not sure about member access with large albums (over 100 images). | ||
If anyone has any problems, suggestions or whatever, feel free to email me directly at < | If anyone has any problems, suggestions or whatever, feel free to email me directly at < |
programming/python/libgal3.txt · Last modified: 2023/11/10 20:06 by jay