-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
E.Azer Koçulu
committed
Jun 15, 2014
0 parents
commit 6ac83fa
Showing
6 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.env | ||
node_modules | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.env | ||
test | ||
test.js | ||
example | ||
examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
## flickr-photo-urls | ||
|
||
Get source urls with varied sizes of a Flickr photo | ||
|
||
## Install | ||
|
||
```bash | ||
$ npm install flickr-photo-urls | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
var urls = require('flickr-photo-urls')({ | ||
key: 'api-key' | ||
}) | ||
|
||
urls('14321741011', function (error, result) { | ||
if (error) return callback(error); | ||
|
||
result.square | ||
// => { "label": "Square", "width": 75, "height": 75, "source": "https:\/\/farm3.staticflickr.com\/2922\/14321741011_aeb3b41d62_s.jpg", "url": "https:\/\/www.flickr.com\/photos\/azer\/14321741011\/sizes\/sq\/", "photo": true } | ||
|
||
result.large2048 | ||
// => { "label": "Large 2048", "width": 2048, "height": 1365, "source": "https:\/\/farm3.staticflickr.com\/2922\/14321741011_3c581b37ec_k.jpg", "url": "https:\/\/www.flickr.com\/photos\/azer\/14321741011\/sizes\/k\/", "photo": true } | ||
}) | ||
``` | ||
|
||
See `test.js` for more info. | ||
|
||
[flickr-client](http://github.com/npm-flickr/flickr-client) can be passed to avoid repeating auth options: | ||
|
||
```js | ||
var client = require('flickr-client')({ | ||
key: 'api-key' | ||
}); | ||
|
||
var urls = require('flickr-photo-urls')(client) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
var createClient = require("flickr-client"); | ||
var variableName = require("variable-name"); | ||
|
||
var client; | ||
|
||
module.exports = setup; | ||
|
||
function setup (options) { | ||
client = createClient(options); | ||
return photoURLs; | ||
} | ||
|
||
function photoURLs (photoId, callback) { | ||
client('photos.getSizes', { photo_id: photoId }, function (error, response) { | ||
if (error) return callback(error); | ||
|
||
var result = {}; | ||
|
||
var i = response.sizes.size.length; | ||
while (i--) { | ||
if (response.sizes.size[i].media == 'video') response.sizes.size[i].video = true; | ||
if (response.sizes.size[i].media == 'photo') response.sizes.size[i].photo = true; | ||
delete response.sizes.size[i].media == 'photo'; | ||
|
||
response.sizes.size[i].width = Number(response.sizes.size[i].width); | ||
response.sizes.size[i].height = Number(response.sizes.size[i].height); | ||
|
||
result[variableName(response.sizes.size[i].label)] = response.sizes.size[i]; | ||
} | ||
|
||
callback(undefined, result); | ||
|
||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "flickr-photo-urls", | ||
"version": "0.0.0", | ||
"description": "Get source urls with varied sizes of a Flickr photo", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "node test" | ||
}, | ||
"keywords": [ | ||
"flickr", | ||
"photos", | ||
"photography", | ||
"api", | ||
"client" | ||
], | ||
"repository": { | ||
"url": "[email protected]:azer/flickr-photo-urls.git", | ||
"type": "git" | ||
}, | ||
"author": "azer", | ||
"license": "BSD", | ||
"dependencies": { | ||
"variable-name": "0.0.1", | ||
"with-env": "^0.1.0", | ||
"flickr-client": "0.0.2" | ||
}, | ||
"devDependencies": { | ||
"prova": "^1.11.1" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.