1.1.6 UI fixes, electron public api call

This commit is contained in:
exttex 2020-11-06 18:10:42 +01:00
parent 9fab54951c
commit 8648e6df41
10 changed files with 77 additions and 18 deletions

View File

@ -88,7 +88,7 @@ app.on('ready', async () => {
createWindow();
//Create Tray
if (nativeTheme.shouldUseDarkColors)
if (settings.forceWhiteTrayIcon || nativeTheme.shouldUseDarkColors)
tray = new Tray(assetPath("icon-taskbar-white.png"));
else
tray = new Tray(assetPath("icon-taskbar-black.png"));

View File

@ -173,7 +173,7 @@
<v-container
class='overflow-y-auto'
fluid
style='height: calc(100vh - 118px);'>
style='height: calc(100vh - 140px);'>
<keep-alive include='Search,PlaylistPage,HomeScreen,DeezerPage'>
<router-view></router-view>

View File

@ -128,5 +128,7 @@
"Removed from playlist!": "Removed from playlist!",
"Playlist deleted!": "Playlist deleted!",
"Delete": "Delete",
"Are you sure you want to delete this playlist?": "Are you sure you want to delete this playlist?"
"Are you sure you want to delete this playlist?": "Are you sure you want to delete this playlist?",
"Force white tray icon": "Force white tray icon",
"Force default (white) tray icon if theme incorrectly detected. Requires restart.": "Force default (white) tray icon if theme incorrectly detected. Requires restart."
}

View File

@ -16,7 +16,7 @@
:src='$root.track.albumArt.full'
:lazy-src="$root.track.albumArt.thumb"
aspect-ratio="1"
max-height="calc(90vh - 285px)"
max-height="calc(90vh - 310px)"
class='ma-4'
contain>
</v-img>
@ -70,7 +70,7 @@
</v-row>
<!-- Bottom actions -->
<div class='d-flex my-1 mx-2 '>
<div class='d-flex mx-2 mb-2'>
<v-btn icon @click='repeatClick'>
<v-icon v-if='$root.repeat == 0'>mdi-repeat</v-icon>
@ -134,7 +134,7 @@
<v-tabs-items v-model='tab'>
<!-- Queue tab -->
<v-tab-item key='queue'>
<v-list two-line avatar class='overflow-y-auto' style='max-height: calc(100vh - 140px)'>
<v-list two-line avatar class='overflow-y-auto' style='max-height: calc(100vh - 160px)'>
<v-lazy
min-height="1"
transition="fade-transition"
@ -151,7 +151,7 @@
</v-tab-item>
<!-- Info tab -->
<v-tab-item key='info'>
<v-list two-line avatar class='overflow-y-auto text-center' style='max-height: calc(100vh - 140px)'>
<v-list two-line avatar class='overflow-y-auto text-center' style='max-height: calc(100vh - 160px)'>
<h1>{{$root.track.title}}</h1>
<!-- Album -->
<h3>Album:</h3>
@ -182,7 +182,7 @@
</v-tab-item>
<!-- Lyrics -->
<v-tab-item key='lyrics'>
<Lyrics :songId='$root.track.id' height='calc(100vh - 140px)'></Lyrics>
<Lyrics :songId='$root.track.id' height='calc(100vh - 160px)'></Lyrics>
</v-tab-item>
</v-tabs-items>
@ -204,19 +204,20 @@
<style scoped>
.main {
width: 100vw;
}
.notop {
height: 100vh;
width: 100vw;
}
.electron {
height: calc(100vh - 28px);
margin-top: 28px;
width: 100vw;
}
@media screen and (max-height: 864px) {
@media screen and (max-height: 900px) {
.imagescale {
max-height: 50vh;
}

View File

@ -230,6 +230,16 @@
<v-list-item-subtitle>{{$t("Don't minimize to tray")}}</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
<!-- Force white tray icon -->
<v-list-item v-if='$root.settings.electron'>
<v-list-item-action>
<v-checkbox v-model='$root.settings.forceWhiteTrayIcon' class='pl-2'></v-checkbox>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>{{$t("Force white tray icon")}}</v-list-item-title>
<v-list-item-subtitle>{{$t("Force default (white) tray icon if theme incorrectly detected. Requires restart.")}}</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
<!-- Logout -->
<v-btn block color='red' class='mt-4' @click='logout'>

View File

@ -1,7 +1,7 @@
{
"name": "freezer",
"private": true,
"version": "1.1.5",
"version": "1.1.6",
"description": "",
"main": "background.js",
"scripts": {

View File

@ -144,7 +144,42 @@ class DeezerAPI {
return true;
}
//Wrapper because electron is piece of shit
async callPublicApi(path, params) {
if (this.electron) return await this._callPublicApiElectron(path, params);
return await this._callPublicApiAxios(path, params);
}
async _callPublicApiElectron(path, params) {
const net = require('electron').net;
let data = await new Promise((resolve, reject) => {
//Create request
let req = net.request({
method: 'GET',
url: `https://api.deezer.com/${encodeURIComponent(path)}/${encodeURIComponent(params)}`
});
req.on('response', (res) => {
let data = Buffer.alloc(0);
//Response data
res.on('data', (buffer) => {
data = Buffer.concat([data, buffer]);
});
res.on('end', () => {
resolve(data);
})
});
req.on('error', (err) => {
reject(err);
});
req.end();
});
data = JSON.parse(data.toString('utf-8'));
return data;
}
async _callPublicApiAxios(path, params) {
let res = await axios({
url: `https://api.deezer.com/${encodeURIComponent(path)}/${encodeURIComponent(params)}`,
responseType: 'json',
@ -212,7 +247,7 @@ class DeezerAPI {
return this.fallback(newTrack.streamUrl);
}
} catch (e) {
logger.warn('TrackID Fallback failed: ' + e);
logger.warn('TrackID Fallback failed: ' + e + ' Original ID: ' + qualityInfo.trackId);
}
//ISRC Fallback
try {
@ -222,7 +257,7 @@ class DeezerAPI {
let newTrack = new Track(newTrackData.results.DATA);
return this.fallback(newTrack.streamUrl);
} catch (e) {
logger.warn('ISRC Fallback failed: ' + e);
logger.warn('ISRC Fallback failed: ' + e + ' Original ID: ' + qualityInfo.trackId);
}
return null;
}

View File

@ -10,6 +10,7 @@ const sanitize = require('sanitize-filename');
const ID3Writer = require('browser-id3-writer');
const Metaflac = require('metaflac-js2');
const { Track, Lyrics } = require('./definitions');
const { throwDeprecation } = require('process');
let deezer;
@ -220,15 +221,23 @@ class DownloadThread {
this.qualityInfo = await deezer.fallback(this.download.track.streamUrl, this.download.quality);
if (!this.qualityInfo) {
this.download.state = -1;
this._cb();
return;
}
//Get track info
if (!this.isUserUploaded) {
this.rawTrack = await deezer.callApi('deezer.pageTrack', {'sng_id': this.download.track.id});
this.track = new Track(this.rawTrack.results.DATA);
this.publicTrack = await deezer.callPublicApi('track', this.track.id);
this.publicAlbum = await deezer.callPublicApi('album', this.track.album.id);
try {
this.rawTrack = await deezer.callApi('deezer.pageTrack', {'sng_id': this.qualityInfo.trackId});
this.track = new Track(this.rawTrack.results.DATA);
this.publicTrack = await deezer.callPublicApi('track', this.track.id);
this.publicAlbum = await deezer.callPublicApi('album', this.track.album.id);
} catch (e) {
logger.error(`Error fetching metadata for ID: ${this.qualityInfo.trackId}, Error: ${e}`);
this.download.state = -1;
this._cb();
return;
}
}
//Check if exists

View File

@ -38,6 +38,8 @@ class Settings {
this.crossfadeDuration = 3000;
this.lightTheme = false;
this.playlistFolder = false;
this.forceWhiteTrayIcon = false;
}
//Based on electorn app.getPath

View File

@ -1,7 +1,7 @@
{
"name": "freezer",
"private": true,
"version": "1.1.5",
"version": "1.1.6",
"description": "",
"scripts": {
"pack": "electron-builder --dir",