Esempio n. 1
0
 def test_get_months(self):
     """Should return a list of months to be downloaded"""
     months = get_months(self.EXISTANT_DIR)
     expected = [
         FakeDatetime(2008, 05, 01), FakeDatetime(2008, 06, 01), FakeDatetime(2008, 07, 01)
     ]
Esempio n. 2
0
                response = http.get(photo['url'], stream=True)
            except http.DownloadError:
                continue
            with open(file_path, 'wb') as f:
                shutil.copyfileobj(response.raw, f)
            if not file_path.endswith('.gif'):
                write_caption(file_path, photo['caption'])
    else:
        log.info(u'Photo album "{0}" already downloaded, skipping...'.format(name))


if __name__ == '__main__':
    print 'Big Picture Cataloguer v{0}'.format(VERSION)
    print 'Aengus Walton - http://ventolin.org'
    print '==========================='
    print ''
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "directory", help="The directory in which photos are to be stored")
    args = parser.parse_args()
    if not os.path.exists(args.directory):
        log.info('{0} does not exist, creating...'.format(args.directory))
        os.makedirs(args.directory)
    months = get_months(args.directory)
    for dt in months:
        albums = list_albums(dt.year, dt.month)
        for album in albums:
            album_path = os.path.join(sys.argv[-1], str(dt.year),
                                      '{0:02d}'.format(dt.month), album['name'])
            download_album(album['name'], album_path, album['url'])