Skip to content

Commit

Permalink
Merge pull request #18 from OrangeJedi/v0.5.2
Browse files Browse the repository at this point in the history
V0.5.2
  • Loading branch information
OrangeJedi authored Apr 18, 2020
2 parents ca56d44 + 5da6be0 commit 92f4f7a
Show file tree
Hide file tree
Showing 8 changed files with 345 additions and 156 deletions.
132 changes: 87 additions & 45 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@ const https = require('https');
const fs = require('fs');
let screens = [];
let nq = false;
const cachePath = `${app.getPath('userData')}/videos`;
let cachePath = store.get('cachePath') ?? `${app.getPath('userData')}/videos`;
let downloading = false;

//make video cache directory
if (!fs.existsSync(`${app.getPath('userData')}/videos/`)) {
fs.mkdirSync(`${app.getPath('userData')}/videos/`);
}

global.shared = {
currentlyPlaying: ''
};
Expand Down Expand Up @@ -67,9 +62,9 @@ function createSSWindow() {
frame: false
});
win.setMenu(null);
if(store.get("onlyShowVideoOnPrimaryMonitor") && i !== 0){
if (store.get("onlyShowVideoOnPrimaryMonitor") && displays[i].id !== screen.getPrimaryDisplay().id) {
win.loadFile('web/black.html');
}else {
} else {
win.loadFile('web/screensaver.html');
}
win.on('closed', function () {
Expand Down Expand Up @@ -106,35 +101,34 @@ function createSSPWindow(argv) {
app.whenReady().then(startUp);

function startUp() {
if(store.get("version") !== "v0.5.1"){
store.set('downloadedVideos', []);
store.set('alwaysDownloadVideos', []);
store.set('neverDownloadVideos', []);
store.set('videoProfiles', []);
store.set('videoTransitionLength', 1000);
store.set('videoCache', false);
store.set('videoCacheProfiles', false);
store.set('videoCacheSize', getCacheSize());
store.set('videoCacheRemoveUnallowed', false);
store.set('cachePath', cachePath);
store.set('customVideos', []);
store.set('avoidDuplicateVideos', true);
store.set('onlyShowVideoOnPrimaryMonitor', false);
store.set('version', "v0.5.1");
}
if (!store.get("configured")) {
let allowedVideos = [];
for (let i = 0; i < videos.length; i++) {
allowedVideos.push(videos[i].id);
if (!store.get("configured") || store.get("version") !== "v0.5.2") {
//make video cache directory
if (!fs.existsSync(`${app.getPath('userData')}/videos/`)) {
fs.mkdirSync(`${app.getPath('userData')}/videos/`);
}
store.set('allowedVideos', allowedVideos);
store.set('timeOfDay', false);
store.set('sunrise', "06:00");
store.set('sunset', "18:00");
store.set('playbackSpeed', 1);
store.set('skipVideosWithKey', true);
store.set("configured", true);
store.set('videoFilters', [
//video lists
if (!store.get('allowedVideos')) {
let allowedVideos = [];
for (let i = 0; i < videos.length; i++) {
allowedVideos.push(videos[i].id);
}
store.set('allowedVideos', allowedVideos);
}
store.set('downloadedVideos', store.get('downloadedVideos') ?? []);
store.set('alwaysDownloadVideos', store.get('alwaysDownloadVideos') ?? []);
store.set('neverDownloadVideos', store.get('neverDownloadVideos') ?? []);
store.set('videoProfiles', store.get('videoProfiles') ?? []);
store.set('customVideos', store.get('customVideos') ?? []);

//general settings
store.set('timeOfDay', store.get('timeOfDay') ?? false);
store.set('sunrise', store.get('sunrise') ?? "06:00");
store.set('sunset', store.get('sunset') ?? "18:00");
store.set('playbackSpeed', store.get('playbackSpeed') ?? 1);
store.set('skipVideosWithKey', store.get('skipVideosWithKey') ?? true);
store.set('avoidDuplicateVideos', store.get('avoidDuplicateVideos') ?? true);
//playback settings
store.set('videoFilters', store.get('videoFilters') ?? [
{name: 'blur', value: 0, min: 0, max: 100, suffix: "px", defaultValue: 0},
{name: 'brightness', value: 100, min: 0, max: 100, suffix: "%", defaultValue: 100},
{name: 'grayscale', value: 0, min: 0, max: 100, suffix: "%", defaultValue: 0},
Expand All @@ -143,12 +137,21 @@ function startUp() {
{name: 'saturate', value: 100, min: 0, max: 256, suffix: "%", defaultValue: 100},
{name: 'sepia', value: 0, min: 0, max: 100, suffix: "%", defaultValue: 0},
]);
store.set('sameVideoOnScreens', false);
store.set('timeString', "dddd, MMMM Do YYYY, h:mm:ss a");
store.set('textFont', "Segoe UI");
store.set('textSize', "2");
store.set('textColor', "#FFFFFF");
store.set('displayText', {
store.set('videoTransitionLength', store.get('videoTransitionLength') ?? 1000);
//multi-screen settings
store.set('sameVideoOnScreens', store.get('sameVideoOnScreens') ?? false);
store.set('onlyShowVideoOnPrimaryMonitor', store.get('onlyShowVideoOnPrimaryMonitor') ?? false);
//cache settings
store.set('videoCache', store.get('videoCache') ?? false);
store.set('videoCacheProfiles', store.get('videoCacheProfiles') ?? false);
store.set('videoCacheSize', getCacheSize());
store.set('videoCacheRemoveUnallowed', store.get('videoCacheRemoveUnallowed') ?? false);
store.set('cachePath', store.get('cachePath') ?? cachePath);
//text settings
store.set('textFont', store.get('textFont') ?? "Segoe UI");
store.set('textSize', store.get('textSize') ?? "2");
store.set('textColor', store.get('textColor') ?? "#FFFFFF");
store.set('displayText', store.get('displayText') ?? {
'positionList': ["topleft", "topright", "bottomleft", "bottomright", "left", "right", "middle", "topmiddle", "bottommiddle"],
'topleft': {'type': "none", "defaultFont": true},
'topright': {'type': "none", "defaultFont": true},
Expand All @@ -159,7 +162,12 @@ function startUp() {
'middle': {'type': "none", "defaultFont": true},
'topmiddle': {'type': "none", "defaultFont": true},
'bottommiddle': {'type': "none", "defaultFont": true}
})
});
store.set('videoQuality', store.get('videoQuality') ?? false);

//config
store.set('version', "v0.5.2");
store.set("configured", true);
}
if (process.argv.includes("/nq")) {
nq = true;
Expand Down Expand Up @@ -214,7 +222,7 @@ ipcMain.on('keyPress', (event, key) => {
});

ipcMain.on('updateCache', (event) => {
const path = `${app.getPath('userData')}/videos`;
const path = cachePath;
let videoList = [];
fs.readdir(path, (err, files) => {
files.forEach(file => {
Expand All @@ -228,6 +236,7 @@ ipcMain.on('updateCache', (event) => {
store.set('videoCacheSize', getCacheSize());
event.reply('displaySettings');
});
updateCustomVideos();
});

ipcMain.on('deleteCache', (event) => {
Expand Down Expand Up @@ -257,6 +266,36 @@ ipcMain.on('selectCustomLocation', async (event, arg) => {
//event.reply('filePath', result.filePaths);
});

ipcMain.on('selectCacheLocation', async (event, arg) => {
const result = await dialog.showOpenDialog(screens[0], {
properties: ['openDirectory']
});
const path = result.filePaths[0];
//removeAllVideosInCache();
cachePath = path;
store.set('cachePath', path);
updateVideoCache(()=>{event.reply('displaySettings');});
});

function updateCustomVideos() {
let allowedVideos = store.get('allowedVideos');
let customVideos = store.get('customVideos');
for (let i = 0; i < allowedVideos.length; i++) {
if (allowedVideos[i][0] === "_") {
let index = customVideos.findIndex((e) => {
if (allowedVideos[i] === e.id) {
return true;
}
});
if (index === -1) {
allowedVideos.splice(index, 1);
i--;
}
}
}
store.set('allowedVideos', allowedVideos);
}

//file download
function downloadFile(file_url, targetPath, callback) {
// Save variable to know progress
Expand Down Expand Up @@ -403,7 +442,7 @@ function getVideosToDownload() {
return allowedVideos;
}

function updateVideoCache() {
function updateVideoCache(callback) {
let videoList = [];
fs.readdir(cachePath, (err, files) => {
files.forEach(file => {
Expand All @@ -415,5 +454,8 @@ function updateVideoCache() {
store.set('downloadedVideos', videoList);
}
store.set('videoCacheSize', getCacheSize());
if(callback) {
callback();
}
});
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aerial",
"version": "0.5.0",
"version": "0.5.2",
"description": "Apple TV screen saver for Windows",
"main": "app.js",
"scripts": {
Expand Down
10 changes: 7 additions & 3 deletions web/config.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
cursor: pointer;
}

:focus{
:focus {
outline: 0;
}

Expand All @@ -30,6 +30,7 @@
position: relative;
display: inline-block;
}

.autocomplete-items {
position: absolute;
border: 1px solid #d4d4d4;
Expand All @@ -41,28 +42,31 @@
left: 0;
right: 0;
}

.autocomplete-items div {
padding: 10px;
cursor: pointer;
background-color: #fff;
border-bottom: 1px solid #d4d4d4;
}

.autocomplete-items div:hover {
/*when hovering an item:*/
background-color: #e9e9e9;
}

.autocomplete-active {
/*when navigating through the items using the arrow keys:*/
background-color: DodgerBlue !important;
color: #ffffff;
}

.imagePositionRadio{
.imagePositionRadio {
padding: 2%;
padding-top: .5%;
}

.videoInfo{
.videoInfo {
position: absolute;
padding-top: 55%;
padding-left: 5%;
Expand Down
Loading

0 comments on commit 92f4f7a

Please sign in to comment.