-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorderAlbums.php
More file actions
38 lines (28 loc) · 805 Bytes
/
orderAlbums.php
File metadata and controls
38 lines (28 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
require_once 'STFU.php';
$stfu = new SimpleTerminalFlickrUtility('Albums Sorter');
Color::text("List all albums...\t");
$sets = $stfu->api->photosets_getList();
Color::ok();
$albums = array();
$error = false;
foreach($sets['photoset'] as $album) {
$title = $album['title']['_content'];
$albums[$album['id']] = $title;
if (substr_count($title, ':')%2 != 0) {
echo "\nProblem found with ";
Color::text($title, Color::blue);
$error = true;
}
}
if ($error) {
Color::text("\nFix errors before ordering albums.", Color::red);
exit();
}
arsort($albums);
$ids = array();
foreach ($albums as $id => $title) $ids[] = $id;
Color::text("Sorting all albums...\t");
$ret = $stfu->api->photosets_orderSets($ids);
if ($ret) Color::ok();
else Color::text("Something went wrong...", Color::red);