Skip to content

Commit

Permalink
update num_photos when it changes
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinerousseau committed Sep 3, 2019
1 parent b3d929f commit cebece4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions start.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ const main = async () => {
const path = getAlbumPath(set.id)
if (fileExists(path)) {
albums_cache[set.id] = readJson(path)
if (albums_cache[set.id].num_photos !== set.photos) {
// number of photos has changed since last time, update:
albums_cache[set.id].num_photos = set.photos
writeJson(path, albums_cache[set.id])
}
} else {
albums_cache[set.id] = {
title: set.title && set.title._content,
Expand Down Expand Up @@ -69,10 +74,6 @@ const main = async () => {
})
photoset = body.photos
photoset.title = "Photos not in a set"
if (!data.num_photos) {
data.num_photos = Number(photoset.total)
writeJson(path, data)
}
} else {
const { body } = await flickr.photosets.getPhotos({
// https://www.flickr.com/services/api/flickr.photosets.getPhotos.html
Expand All @@ -87,7 +88,7 @@ const main = async () => {

const { title, photo: photos, pages, total } = photoset

log(`Processing "${title}" set (${total} photos); Flickr id: ${photoset_id}; page ${page}/${pages}`)
log(`Processing "${title}" set (${total} items); Flickr id: ${photoset_id}; page ${page}/${pages}`)

if (!data.google_album) {
const albumRequest = {
Expand Down

0 comments on commit cebece4

Please sign in to comment.