Up to date commit
authorRemixDev <DeezloaderRemix@gmail.com>
Sat, 25 Aug 2018 20:37:54 +0000 (22:37 +0200)
committerRemixDev <DeezloaderRemix@gmail.com>
Sat, 25 Aug 2018 20:37:54 +0000 (22:37 +0200)
.gitignore
app/app.js
app/deezer-api.js
app/default.json
app/logger.js [deleted file]
app/main.js
app/public/index.html
app/public/js/main.js
app/utils/localpaths.js [new file with mode: 0644]
app/utils/logger.js [new file with mode: 0644]
update [new file with mode: 0644]

index a946a3598dda40c9cc29accb361367117d8e28fc..65356b393a91de051f7710b53488921985bdc025 100644 (file)
@@ -65,4 +65,4 @@ app/authCredentials.js
 .DS_Store
 */.DS_Store
 /package-lock.json
-*/package-lock.json
+*/package-lock.json
\ No newline at end of file
index 50c61c55ca752cc44598b940b08387bbfea720f0..c5775558443d7140abcc71ed7282bb5dbdb161c9 100644 (file)
@@ -10,7 +10,7 @@
  *
  *  Original work by ZzMTV <https://boerse.to/members/zzmtv.3378614/>
  * */
-
+//test
 const express = require('express');
 const app = express();
 const server = require('http').createServer(app);
@@ -24,56 +24,39 @@ const ID3Writer = require('./lib/browser-id3-writer');
 const Deezer = require('./deezer-api');
 const path = require('path');
 const crypto = require('crypto');
-const logger = require('./logger.js');
+const logger = require('./utils/logger.js');
 const Spotify = require('spotify-web-api-node');
-const authCredentials = require('./authCredentials.js')
-const queue = require('queue')
-
-// Load Config File
-var userdata = "";
-var homedata = "";
-if(process.env.APPDATA){
-       homedata = os.homedir();
-       userdata = process.env.APPDATA + path.sep + "Deezloader Remix" + path.sep;
-}else if(process.platform == "darwin"){
-       homedata = os.homedir();
-       userdata = homedata + '/Library/Application Support/Deezloader Remix/';
-}else if(process.platform == "android"){
-       homedata = os.homedir() + "/storage/shared";
-       userdata = homedata + "/Deezloader Remix/";
-}else{
-       homedata = os.homedir();
-       userdata = homedata + '/.config/Deezloader Remix/';
-}
+const authCredentials = require('./authCredentials.js');
+const queue = require('queue');
+const localpaths = require('./utils/localpaths.js');
+const package = require('./package.json');
 
-if(!fs.existsSync(userdata+"config.json")){
-       fs.outputFileSync(userdata+"config.json",fs.readFileSync(__dirname+path.sep+"default.json",'utf8'));
+if(!fs.existsSync(localpaths.user+"config.json")){
+       fs.outputFileSync(localpaths.user+"config.json",fs.readFileSync(__dirname+path.sep+"default.json",'utf8'));
 }
 
 var spotifyApi = new Spotify(authCredentials);
 
 // Main Constants
-const configFileLocation = userdata+"config.json";
-const autologinLocation = userdata+"autologin";
+const configFileLocation = localpaths.user+"config.json";
+const autologinLocation = localpaths.user+"autologin";
 const coverArtFolder = os.tmpdir() + path.sep + 'deezloader-imgs' + path.sep;
-const defaultDownloadDir = homedata + path.sep + "Music" + path.sep + 'Deezloader' + path.sep;
+const defaultDownloadDir = localpaths.music + 'Deezloader' + path.sep;
 const defaultSettings = require('./default.json').userDefined;
 
 // Setup the folders START
 var mainFolder = defaultDownloadDir;
 
 // Settings update fix
-var configFile = require(userdata+path.sep+"config.json");
+var configFile = require(localpaths.user+path.sep+"config.json");
 for (let x in defaultSettings){
        if (typeof configFile.userDefined[x] != typeof defaultSettings[x]){
                configFile.userDefined[x] = defaultSettings[x]
        }
 }
-
 if (configFile.userDefined.downloadLocation != "") {
        mainFolder = configFile.userDefined.downloadLocation;
 }
-
 initFolders();
 // END
 
@@ -114,6 +97,22 @@ function aldecrypt(encoded) {
 
 // START sockets clusterfuck
 io.sockets.on('connection', function (socket) {
+       var curVersion = package.version.replace('.', '');
+       request({
+               url: "https://notabug.org/RemixDevs/DeezloaderRemix/raw/master/update",
+               json: true
+       }, function(error, response, body) {
+               if (!error && response.statusCode === 200) {
+                       console.log("Got response: " + JSON.stringify(body));
+                       console.log("Current version: " + curVersion.replace('.', '') + "\nLatest Version: " + body.version);
+                       if ((parseInt(body.version) > parseInt(curVersion.replace('.', '')))) {
+                               console.log("\n\nUpdate Available\n\n");
+                               socket.emit("message", {title: "Update Available", msg: body.changelog});
+                       }
+               } else {
+                       console.log("ERROR: " + error + " " + response.statusCode);
+               }
+       })
        socket.downloadQueue = {};
        socket.currentItem = null;
        socket.lastQueueId = null;
@@ -323,13 +322,13 @@ io.sockets.on('connection', function (socket) {
                        };
                        data.settings.albumInfo = slimDownAlbumInfo(album)
                        _album.settings = data.settings || {};
-                       Deezer.getAdvancedAlbumTracks(data.id, function (playlist, err) {
+                       Deezer.getAdvancedAlbumTracks(data.id, function (album, err) {
                                if (err){
                                        logger.error(err)
                                        return;
                                }
-                               _album.size = playlist.data.length
-                               _album.tracks = playlist.data
+                               _album.size = album.data.length
+                               _album.tracks = album.data
                                addToQueue(JSON.parse(JSON.stringify(_album)));
                        })
                });
@@ -345,7 +344,7 @@ io.sockets.on('connection', function (socket) {
                        (function sendAllAlbums(i) {
                                setTimeout(function () {
                      data.id = albums.data[albums.data.length-1-i].id;
-                                       socketDownloadAlbum(data);
+                                       socketDownloadAlbum(JSON.parse(JSON.stringify(data)));
                      if (--i+1) sendAllAlbums(i);
                        }, 100)
                        })(albums.data.length-1);
@@ -1144,7 +1143,7 @@ io.sockets.on('connection', function (socket) {
                let track = data;
                track.trackSocket = socket;
                temp = new Promise((resolve, reject)=>{
-                       if (parseInt(t.id)>0){
+                       if (parseInt(t.id)>0 && !altmetadata){
                                if (!settings.albumInfo){
                                        logger.info("Getting album data");
                                        Deezer.getAlbum(track["ALB_ID"], function(res, err){
@@ -1198,7 +1197,7 @@ io.sockets.on('connection', function (socket) {
                                resolve(ajson.totalDiskNumber)
                        })
                }else{
-                       if ((settings.tags.discTotal || settings.createCDFolder) && parseInt(t.id)>0){
+                       if (((settings.tags.discTotal || settings.createCDFolder) && parseInt(t.id)>0) && !altmetadata){
                                logger.info("Getting total disc number");
                                temp = new Promise((resolve, reject) =>{
                                        Deezer.getATrack(ajson.tracks.data[ajson.tracks.data.length-1].id, function(tres){
@@ -1213,7 +1212,7 @@ io.sockets.on('connection', function (socket) {
                }
                temp.then(discTotal=>{
                let totalDiskNumber = discTotal;
-               if (settings.tags.bpm && parseInt(t.id)>0){
+               if ((settings.tags.bpm && parseInt(t.id)>0) && !altmetadata){
                        logger.info("Getting BPM");
                        temp = new Promise((resolve, reject) =>{
                                Deezer.getATrack(t.id, function(tres, err){
@@ -1392,7 +1391,7 @@ io.sockets.on('connection', function (socket) {
                                        t.id = t.fallback
                                        t.fallback = 0
                                        settings.trackInfo = null;
-                                       downloadTrack(t, settings, metadata, callback);
+                                       downloadTrack(t, settings, JSON.parse(JSON.stringify(metadata)), callback);
                                }else if(!t.searched){
                                        logger.warn("Failed to download track, searching for alternative");
                                        Deezer.track2ID(t.artist, t.name, null, data=>{
@@ -1400,7 +1399,7 @@ io.sockets.on('connection', function (socket) {
                                                t.id = data.id;
                                                t.artist = data.artist;
                                                t.name = data.name;
-                                               downloadTrack(t, settings, metadata, callback);
+                                               downloadTrack(t, settings, JSON.parse(JSON.stringify(metadata)), callback);
                                        });
                                }else{
                                        logger.error(`Failed to download ${t.artist} - ${t.name}: ${err}`);
@@ -1429,9 +1428,13 @@ io.sockets.on('connection', function (socket) {
                                        if (settings.tags.isrc)
                                                flacComments.push('ISRC=' + metadata.ISRC);
                                        if (settings.tags.artist && metadata.artists)
-                                               metadata.artists.forEach(x=>{
-                                                       flacComments.push('ARTIST=' + x);
-                                               });
+                                               if (Array.isArray(metadata.artists)){
+                                                       metadata.artists.forEach(x=>{
+                                                               flacComments.push('ARTIST=' + x);
+                                                       });
+                                               }else{
+                                                       flacComments.push('ARTIST=' + metadata.artists);
+                                               }
                                        if (settings.tags.discTotal)
                                                flacComments.push('DISCTOTAL='+splitNumber(metadata.discTotal,true));
                                        if (settings.tags.length)
@@ -1441,9 +1444,13 @@ io.sockets.on('connection', function (socket) {
                                        if (metadata.unsynchronisedLyrics && settings.tags.unsynchronisedLyrics)
                                                flacComments.push('LYRICS='+metadata.unsynchronisedLyrics.lyrics);
                                        if (metadata.genre && settings.tags.genre)
-                                               metadata.genre.forEach(x=>{
-                                                       flacComments.push('GENRE=' + x);
-                                               });
+                                               if (Array.isArray(metadata.genre)){
+                                                       metadata.genre.forEach(x=>{
+                                                               flacComments.push('GENRE=' + x);
+                                                       });
+                                               }else{
+                                                       flacComments.push('GENRE=' + metadata.genre);
+                                               }
                                        if (metadata.copyright && settings.tags.copyright)
                                                flacComments.push('COPYRIGHT=' + metadata.copyright);
                                        if (0 < parseInt(metadata.year)){
@@ -1457,33 +1464,61 @@ io.sockets.on('connection', function (socket) {
                                        if(metadata.publisher && settings.tags.publisher)
                                                flacComments.push('PUBLISHER=' + metadata.publisher);
                                        if(metadata.composer && settings.tags.composer)
-                                               metadata.composer.forEach(x=>{
-                                                       flacComments.push('COMPOSER=' + x);
-                                               });
+                                               if (Array.isArray(metadata.composer)){
+                                                       metadata.composer.forEach(x=>{
+                                                               flacComments.push('COMPOSER=' + x);
+                                                       });
+                                               }else{
+                                                       flacComments.push('COMPOSER=' + metadata.composer);
+                                               }
                                        if(metadata.musicpublisher && settings.tags.musicpublisher)
-                                               metadata.musicpublisher.forEach(x=>{
-                                                       flacComments.push('ORGANIZATION=' + x);
-                                               });
+                                               if (Array.isArray(metadata.musicpublisher)){
+                                                       metadata.musicpublisher.forEach(x=>{
+                                                               flacComments.push('ORGANIZATION=' + x);
+                                                       });
+                                               }else{
+                                                       flacComments.push('ORGANIZATION=' + metadata.musicpublisher);
+                                               }
                                        if(metadata.mixer && settings.tags.mixer)
-                                               metadata.mixer.forEach(x=>{
-                                                       flacComments.push('MIXER=' + x);
-                                               });
+                                               if (Array.isArray(metadata.mixer)){
+                                                       metadata.mixer.forEach(x=>{
+                                                               flacComments.push('MIXER=' + x);
+                                                       });
+                                               }else{
+                                                       flacComments.push('MIXER=' + metadata.mixer);
+                                               }
                                        if(metadata.author && settings.tags.author)
-                                               metadata.author.forEach(x=>{
-                                                       flacComments.push('AUTHOR=' + x);
-                                               });
+                                               if (Array.isArray(metadata.author)){
+                                                       metadata.author.forEach(x=>{
+                                                               flacComments.push('AUTHOR=' + x);
+                                                       });
+                                               }else{
+                                                       flacComments.push('AUTHOR=' + metadata.author);
+                                               }
                                        if(metadata.writer && settings.tags.writer)
-                                               metadata.writer.forEach(x=>{
-                                                       flacComments.push('WRITER=' + x);
-                                               });
+                                               if (Array.isArray(metadata.writer)){
+                                                       metadata.writer.forEach(x=>{
+                                                               flacComments.push('WRITER=' + x);
+                                                       });
+                                               }else{
+                                                       flacComments.push('WRITER=' + metadata.writer);
+                                               }
                                        if(metadata.engineer && settings.tags.engineer)
-                                               metadata.engineer.forEach(x=>{
-                                                       flacComments.push('ENGINEER=' + x);
-                                               });
+                                               if (Array.isArray(metadata.engineer)){
+                                                       metadata.engineer.forEach(x=>{
+                                                               flacComments.push('ENGINEER=' + x);
+                                                       });
+                                               }else{
+                                                       flacComments.push('ENGINEER=' + metadata.engineer);
+                                               }
                                        if(metadata.producer && settings.tags.producer)
-                                               metadata.producer.forEach(x=>{
-                                                       flacComments.push('PRODUCER=' + x);
-                                               });
+                                               if (Array.isArray(metadata.producer)){
+                                                       metadata.producer.forEach(x=>{
+                                                               flacComments.push('PRODUCER=' + x);
+                                                       });
+                                               }else{
+                                                       flacComments.push('PRODUCER=' + metadata.producer);
+                                               }
                                        if(metadata.replayGain && settings.tags.replayGain)
                                                flacComments.push('REPLAYGAIN_TRACK_GAIN=' + metadata.replayGain);
 
@@ -1497,7 +1532,7 @@ io.sockets.on('connection', function (socket) {
                                        }
                                        let mdbVorbisPicture;
                                        let mdbVorbisComment;
-                                       processor.on('preprocess', function(mdb){
+                                       processor.on('preprocess', (mdb) => {
                                                // Remove existing VORBIS_COMMENT and PICTURE blocks, if any.
                                                if (mflac.Processor.MDB_TYPE_VORBIS_COMMENT === mdb.type) {
                                                        mdb.remove();
@@ -1505,18 +1540,23 @@ io.sockets.on('connection', function (socket) {
                                                        mdb.remove();
                                                }
                                                if (mdb.isLast) {
-                                                       mdbVorbisComment = mflac.data.MetaDataBlockVorbisComment.create(false, vendor, flacComments);
-                                                       processor.push(mdbVorbisComment.publish());
                                                        if(cover){
-                                                               mdbVorbisPicture = mflac.data.MetaDataBlockPicture.create(false, 3, `image/${(settings.PNGcovers ? "png" : "jpeg")}`, '', settings.artworkSize, settings.artworkSize, 24, 0, cover);
-                                                               processor.push(mdbVorbisPicture.publish());
+                                                               mdbVorbisPicture = mflac.data.MetaDataBlockPicture.create(true, 3, `image/${(settings.PNGcovers ? "png" : "jpeg")}`, '', settings.artworkSize, settings.artworkSize, 24, 0, cover);
                                                        }
+                                                       mdbVorbisComment = mflac.data.MetaDataBlockVorbisComment.create(!cover, vendor, flacComments);
+                                                       mdb.isLast = false;
                                                }
                                        });
                                        processor.on('postprocess', (mdb) => {
                                                if (mflac.Processor.MDB_TYPE_VORBIS_COMMENT === mdb.type && null !== mdb.vendor) {
                                                        vendor = mdb.vendor;
                                                }
+                                               if (mdbVorbisPicture && mdbVorbisComment) {
+                                                               processor.push(mdbVorbisComment.publish());
+                                                               processor.push(mdbVorbisPicture.publish());
+                                                       }else if(mdbVorbisComment){
+                                                               processor.push(mdbVorbisComment.publish());
+                                               }
                                        });
                                        reader.on('end', () => {
                                                fs.remove(tempPath);
@@ -1974,15 +2014,15 @@ function parseMetadata(track, ajson, totalDiskNumber, settings, position, altmet
                if (ajson.release_date) {
                        metadata.year = ajson.release_date.slice(0, 4);
                        metadata.date = {
-                               day: ajson.release_date.slice(5,7),
-                               month:  ajson.release_date.slice(8,10),
+                               day: ajson.release_date.slice(8,10),
+                               month: ajson.release_date.slice(5,7),
                                year: (settings.dateFormatYear == "2" ? ajson.release_date.slice(2, 4) : ajson.release_date.slice(0, 4))
                        }
                } else if(track["PHYSICAL_RELEASE_DATE"]){
                        metadata.year = track["PHYSICAL_RELEASE_DATE"].slice(0, 4);
                        metadata.date = {
-                               day: track["PHYSICAL_RELEASE_DATE"].slice(5,7),
-                               month:  track["PHYSICAL_RELEASE_DATE"].slice(8,10),
+                               day: track["PHYSICAL_RELEASE_DATE"].slice(8,10),
+                               month: track["PHYSICAL_RELEASE_DATE"].slice(5,7),
                                year: (settings.dateFormatYear == "2" ? track["PHYSICAL_RELEASE_DATE"].slice(2, 4) : track["PHYSICAL_RELEASE_DATE"].slice(0, 4))
                        }
                }
@@ -1993,7 +2033,8 @@ function parseMetadata(track, ajson, totalDiskNumber, settings, position, altmet
                                case "1": date = `${metadata.date.day}-${metadata.date.month}-${metadata.date.year}`; break;
                                case "2": date = `${metadata.date.month}-${metadata.date.day}-${metadata.date.year}`; break;
                                case "3": date = `${metadata.date.year}-${metadata.date.day}-${metadata.date.month}`; break;
-                               default: date = `${metadata.date.day}-${metadata.date.month}-${metadata.date.year}`; break;
+                               case "4": date = `${metadata.date.day}${metadata.date.month}`; break;
+                               default: date = `${metadata.date.day}${metadata.date.month}`; break;
                        }
                        metadata.date = date;
                }
index acf2e7a79e1a8dc2b51c3f71c623a6ebb7fb6d65..467659424a31210100adecc95b004a4fd12c3960 100644 (file)
@@ -1,7 +1,7 @@
 const request = require('requestretry').defaults({maxAttempts: 2147483647, retryDelay: 1000, timeout: 8000});
 const crypto = require('crypto');
 const fs = require("fs-extra");
-const logger = require('./logger.js');
+const logger = require('./utils/logger.js');
 
 module.exports = new Deezer();
 
@@ -19,7 +19,7 @@ function Deezer() {
        this.reqStream = {}
        this.delStream = []
 }
-
+console.log("hi");
 Deezer.prototype.init = function(username, password, callback) {
        var self = this;
        request.post({
index 9a16866e6e13c2631205c77654f305762c979db8..c8b5e5162bb879066b1fe3fff4350447d61a0852 100644 (file)
@@ -1,6 +1,7 @@
 {
        "serverPort": 1730,
        "userDefined": {
+               "minimizeToTray": true,
                "trackNameTemplate": "%artist% - %title%",
                "playlistTrackNameTemplate": "%number% - %artist% - %title%",
                "albumTrackNameTemplate": "%number% - %title%",
@@ -49,7 +50,7 @@
                        "length": false,
                        "barcode": false,
                        "bpm": true,
-                       "replayGain": true,
+                       "replayGain": false,
                        "publisher": true,
                        "unsynchronisedLyrics": false,
                        "copyright": false,
diff --git a/app/logger.js b/app/logger.js
deleted file mode 100644 (file)
index b1f95b5..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-const fs = require("fs-extra");
-const path = require('path');
-const os = require('os');
-const dateformat = require('dateformat');
-
-var userdata = "";
-var homedata = "";
-if(process.env.APPDATA){
-       userdata = process.env.APPDATA + path.sep + "Deezloader Remix" + path.sep;
-       homedata = os.homedir();
-}else if(process.platform == "darwin"){
-       homedata = os.homedir();
-       userdata = homedata + '/Library/Application Support/Deezloader Remix/';
-}else if(process.platform == "android"){
-       homedata = os.homedir() + "/storage/shared";
-       userdata = homedata + "/Deezloader Remix/";
-}else{
-       homedata = os.homedir();
-       userdata = homedata + '/.config/Deezloader Remix/';
-}
-
-fs.ensureDirSync(path.join(userdata, 'logs'))
-const logsLocation = path.join(userdata, 'logs', `${dateformat(new Date(), 'yyyy-mm-dd')}.txt`)
-fs.appendFileSync(logsLocation, "\r\n\r\n");
-
-function logs(level, message){
-       var str = "["+level+"] "+message;
-       console.log(str);
-       fs.appendFileSync(logsLocation, str+"\r\n");
-       return;
-}
-
-function removeColors(string){
-       return string.replace(/\x1b\[\d+m/g,"");
-}
-
-function debug(message){
-       var str = "[\x1b[32mDebug\x1b[0m] "+message;
-       console.log(str);
-       fs.appendFileSync(logsLocation, removeColors(str)+"\r\n");
-       return;
-}
-function info(message){
-       var str = "[\x1b[35mInfo\x1b[0m] "+message;
-       console.log(str);
-       fs.appendFileSync(logsLocation, removeColors(str)+"\r\n");
-       return;
-}
-function warn(message){
-       var str = "[\x1b[33mWarning\x1b[0m] "+message;
-       console.log(str);
-       fs.appendFileSync(logsLocation, removeColors(str)+"\r\n");
-       return;
-}
-function error(message){
-       var str = "[\x1b[31mError\x1b[0m] "+message;
-       console.log(str);
-       fs.appendFileSync(logsLocation, removeColors(str)+"\r\n");
-       return;
-}
-
-module.exports.logs = logs;
-
-module.exports.debug = debug;
-module.exports.info = info;
-module.exports.warn = warn;
-module.exports.error = error;
index f731fffc839dde5c1ab26122e9c2fed6080f974e..8b459cc0879b6a8060e483de84660267b642f572 100644 (file)
@@ -4,16 +4,17 @@ const fs = require("fs-extra");
 const path = require('path');
 const {app, BrowserWindow, ipcMain} = require('electron');
 const os = require('os');
+const {Menu, Tray} = require('electron')
 loadSettings();
 
 const theApp = require('./app');
 const WindowStateManager = require('electron-window-state-manager');
-
 const url = require('url');
 
+let tray = null;
 let mainWindow;
-
-
+let trayIcon = __dirname + "/icon.png";
+let isTray = false;
 // Create a new instance of the WindowStateManager
 const mainWindowState = new WindowStateManager('mainWindow', {
        defaultWidth: 1280,
@@ -78,15 +79,44 @@ function createWindow () {
                if (mainWindowState.maximized) {
                        mainWindow.maximize();
                }
-
+mainWindow.on('minimize',function(event){
+                               if(appConfig.userDefined.minimizeToTray){
+    event.preventDefault();
+        mainWindow.hide();
+}
+});
+tray.on('click', function(e){
+    if (mainWindow.isVisible()) {
+      mainWindow.hide()
+    } else {
+      mainWindow.show()
+    }
+  });
                // Save current window state
                mainWindow.on('close', () => {
+                       if(appConfig.userDefined.minimizeToTray){
+                           if(!app.isQuitting){
+        event.preventDefault();
+        mainWindow.hide();
+    } else {
                        mainWindowState.saveState(mainWindow);
+               }
+       } else {
+               mainWindowState.saveState(mainWindow);
+       }
                });
        }
-}
+       }
 
-app.on('ready', createWindow);
+app.on('ready', function(){
+       if(appConfig.userDefined.minimizeToTray){
+                   tray = new Tray(trayIcon);
+    const contextMenu = Menu.buildFromTemplate([]);
+    tray.setToolTip('Deezloader Remix');
+    tray.setContextMenu(contextMenu);
+       createWindow();
+}
+});
 
 // Quit when all windows are closed.
 app.on('window-all-closed', function () {
index 3a3e55a20646cea795c42cc6db43802b2d80c4af..8cceda7b339c0a8b6b5984d0ed0fe283c457eb26 100644 (file)
                                        <option value="1">DMY</option>
                                        <option value="2">MDY</option>
           <option value="3">YDM</option>
+          <option value="4">ID3 Defaut</option>
                                </select>
                                <label for="modal_settings_select_dateFormat">Date Format</label>
                        </div>
                                <span>Create M3U (Playlist) file</span>
         </label>
                        </p>
+            <p class="col s12 m4">
+        <label>
+          <input type="checkbox" id="modal_settings_cbox_minimizeToTray" class="filled-in"/>
+          <span>Minimize to system tray</span>
+        </label>
+      </p>
       <p class="col s12 m4">
         <label>
                                <input type="checkbox" id="modal_settings_cbox_syncedlyrics" class="filled-in"/>
                                <input type="checkbox" id="modal_settings_cbox_fallbackBitrate" class="filled-in"/>
                                <span>Fallback to lower bitrates</span>
         </label>
-                       </p>
+      </p>
                </div>
     <div class="row">
       <div class="col s12">
                        <h4 class="col s12" id="modal_msg_title"></h4>
                </div>
                <div class="row">
-                       <p class="col s12" id="modal_msg_message"></p>
+                       <p style="white-space: pre-line" class="col s12" id="modal_msg_message"></p>
                </div>
        </div>
        <div class="modal-footer">
index 22f30d0202f239a7f386d7ac8ba99c39fea18615..057caa89f78676e2cff0221a819a0558f75e7c7e 100644 (file)
@@ -13,8 +13,9 @@ let preview_stopped = true;
 
 socket.emit("autologin");
 
-socket.on("message", function(title, msg){
-       message(title, msg);
+socket.on("message", function(desc){
+       message(desc.title, desc.msg);
+       console.log({desc});
 });
 
 //Login button
@@ -70,7 +71,11 @@ $('#openDownloadsFolder').on('click', function () {
                alert("For security reasons, this button will do nothing.");
        }
 });
-
+$('#modal_tags_replayGain').on('click', function() {
+       if ($(this).is(':checked')) {
+       message('Warning','Saving replay gain causes tracks to be quieter for some users.');
+}
+})
 // Do misc stuff on page load
 $(document).ready(function () {
        M.AutoInit();
@@ -228,6 +233,7 @@ $('#modal_settings_btn_saveSettings').click(function () {
                dateFormat: $('#modal_settings_select_dateFormat').val(),
                dateFormatYear: $('#modal_settings_select_dateFormatYear').val(),
                fallbackBitrate : $('#modal_settings_cbox_fallbackBitrate').is(':checked'),
+               minimizeToTray : $('#modal_settings_cbox_minimizeToTray').is(':checked'),
                tags: {
                        title: $('#modal_tags_title').is(':checked'),
                        artist: $('#modal_tags_artist').is(':checked'),
@@ -324,6 +330,7 @@ function fillSettingsModal(settings) {
        $('#modal_settings_select_dateFormat').val(settings.dateFormat).formSelect();
        $('#modal_settings_select_dateFormatYear').val(settings.dateFormatYear).formSelect();
        $('#modal_settings_cbox_fallbackBitrate').prop('checked', settings.fallbackBitrate);
+       $('#modal_settings_cbox_minimizeToTray').prop('checked', settings.minimizeToTray);
 
        $('#modal_tags_title').prop('checked', settings.tags.title);
        $('#modal_tags_artist').prop('checked', settings.tags.artist);
diff --git a/app/utils/localpaths.js b/app/utils/localpaths.js
new file mode 100644 (file)
index 0000000..a659784
--- /dev/null
@@ -0,0 +1,27 @@
+const path = require('path');
+const os = require('os');
+const {app} = require('electron')
+
+var userdata = "";
+var homedata = os.homedir();
+var musicdata = ""
+if(typeof app !== "undefined"){
+  userdata = app.getPath("appData")+path.sep+"Deezloader Remix"+path.sep;
+  musicdata = app.getPath('music')+path.sep;
+}else{
+  if(process.env.APPDATA){
+       userdata = process.env.APPDATA + path.sep + "Deezloader Remix" + path.sep;
+  }else if(process.platform == "darwin"){
+       userdata = homedata + '/Library/Application Support/Deezloader Remix/';
+  }else if(process.platform == "android"){
+    homedata += "/storage/emulated/0";
+    userdata = homedata + "/Deezloader Remix/";
+  }else{
+       userdata = homedata + '/.config/Deezloader Remix/';
+  }
+  musicdata = homedata + path.sep + "Music" + path.sep;
+}
+
+module.exports.home = homedata;
+module.exports.user = userdata;
+module.exports.music = musicdata;
diff --git a/app/utils/logger.js b/app/utils/logger.js
new file mode 100644 (file)
index 0000000..5c59213
--- /dev/null
@@ -0,0 +1,60 @@
+const fs = require("fs-extra");
+const path = require('path');
+const dateformat = require('dateformat');
+const localpaths = require('./localpaths.js')
+const os = require('os');
+
+fs.ensureDirSync(path.join(localpaths.user, 'logs'))
+const logsLocation = path.join(localpaths.user, 'logs', `${dateformat(new Date(), 'yyyy-mm-dd-HH.MM.ss')}.txt`)
+fs.appendFileSync(logsLocation, `${os.platform()} - ${os.type()} ${os.release()} ${os.arch()}\r\n\r\n`);
+fs.readdir(path.join(localpaths.user, 'logs'), function (err, files) {
+  if (err) throw err;
+  else {
+    var logs = [];
+    files.forEach(function (file) {
+                       logs.push(file.substring(0, file.length-4));
+    });
+               logs.sort()
+               if (logs.length>5){
+                       for (let i=0; i<logs.length-5; i++){
+                               console.log(logs[i])
+                               fs.unlinkSync(path.join(localpaths.user, 'logs', logs[i]+".txt"));
+                       }
+               }
+  }
+});
+
+function removeColors(string){
+       return string.replace(/\x1b\[\d+m/g,"");
+}
+
+function debug(message){
+       var str = "[\x1b[32mDebug\x1b[0m] "+message;
+       console.log(str);
+       fs.appendFileSync(logsLocation, removeColors(str)+"\r\n");
+       return;
+}
+function info(message){
+       var str = "[\x1b[35mInfo\x1b[0m] "+message;
+       console.log(str);
+       fs.appendFileSync(logsLocation, removeColors(str)+"\r\n");
+       return;
+}
+function warn(message){
+       var str = "[\x1b[33mWarning\x1b[0m] "+message;
+       console.log(str);
+       fs.appendFileSync(logsLocation, removeColors(str)+"\r\n");
+       return;
+}
+function error(message){
+       var str = "[\x1b[31mError\x1b[0m] "+message;
+       console.log(str);
+       fs.appendFileSync(logsLocation, removeColors(str)+"\r\n");
+       return;
+}
+
+module.exports.debug = debug;
+module.exports.info = info;
+module.exports.warn = warn;
+module.exports.error = error;
+module.exports.logPath = logsLocation;
diff --git a/update b/update
new file mode 100644 (file)
index 0000000..94dff91
--- /dev/null
+++ b/update
@@ -0,0 +1 @@
+{"version":"413", "changelog":"Version 4.1.3\r\n- Playlist and Album tracks now have fallback support\r\n- M3U files now works correctly\r\n- Fixed problems with tags\r\n- Added option %explicit% for Track and Album names (Will add \"(Explicit)\" in that position if it's explicit)\r\n- Added option to remove \"(Album Version)\" from track title\r\n- Added options to select which format should the date tag have\r\n- Added option to not fallback if desired bitrate is not aviable\r\n- Logging enhancements\r\n- Other minor bug-fixing"}
\ No newline at end of file