mirror of
https://github.com/jorisbertomeu/web-screensaver.git
synced 2026-04-19 16:27:40 +02:00
Fixes relative to fresh unsplash conf
This commit is contained in:
@@ -18,7 +18,7 @@ export class PhotoController {
|
|||||||
collections = Array.isArray(collections) ? collections : [collections];
|
collections = Array.isArray(collections) ? collections : [collections];
|
||||||
}
|
}
|
||||||
|
|
||||||
const photo = await this.photoService.pickPictureFromFile(collections, false);
|
const photo = await this.photoService.pickPictureFromFile(collections, false, settings.unsplash);
|
||||||
|
|
||||||
if (!photo) {
|
if (!photo) {
|
||||||
return res.status(500).json({ error: 'Failed to fetch photo' });
|
return res.status(500).json({ error: 'Failed to fetch photo' });
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export class PhotoService {
|
|||||||
this.fileService = fileService;
|
this.fileService = fileService;
|
||||||
}
|
}
|
||||||
|
|
||||||
async pickPictureFromFile(collections = [], burnPic = true) {
|
async pickPictureFromFile(collections = [], burnPic = true, unsplashCreds = null) {
|
||||||
try {
|
try {
|
||||||
const filename = generatePictureFilename(collections.join(','));
|
const filename = generatePictureFilename(collections.join(','));
|
||||||
let pics = this.fileService.readJsonFile(filename);
|
let pics = this.fileService.readJsonFile(filename);
|
||||||
@@ -22,7 +22,11 @@ export class PhotoService {
|
|||||||
|
|
||||||
return pic;
|
return pic;
|
||||||
}
|
}
|
||||||
const newPics = await UnsplashService.getRandomPhotos(collections);
|
const unsplashService = new UnsplashService({
|
||||||
|
accessKey: unsplashCreds?.accessKey || '',
|
||||||
|
secretKey: unsplashCreds?.secretKey || ''
|
||||||
|
});
|
||||||
|
const newPics = await unsplashService.getRandomPhotos(collections);
|
||||||
if (newPics.length === 0) {
|
if (newPics.length === 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export class UnsplashService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async getRandomPhotos(collections = [], count = DEFAULT_PHOTO_COUNT) {
|
async getRandomPhotos(collections = [], count = 30) {
|
||||||
try {
|
try {
|
||||||
const { response } = await this.api.photos.getRandom({
|
const { response } = await this.api.photos.getRandom({
|
||||||
orientation: 'landscape',
|
orientation: 'landscape',
|
||||||
|
|||||||
Reference in New Issue
Block a user