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(); createWindow();
//Create Tray //Create Tray
if (nativeTheme.shouldUseDarkColors) if (settings.forceWhiteTrayIcon || nativeTheme.shouldUseDarkColors)
tray = new Tray(assetPath("icon-taskbar-white.png")); tray = new Tray(assetPath("icon-taskbar-white.png"));
else else
tray = new Tray(assetPath("icon-taskbar-black.png")); tray = new Tray(assetPath("icon-taskbar-black.png"));

View File

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

View File

@ -128,5 +128,7 @@
"Removed from playlist!": "Removed from playlist!", "Removed from playlist!": "Removed from playlist!",
"Playlist deleted!": "Playlist deleted!", "Playlist deleted!": "Playlist deleted!",
"Delete": "Delete", "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' :src='$root.track.albumArt.full'
:lazy-src="$root.track.albumArt.thumb" :lazy-src="$root.track.albumArt.thumb"
aspect-ratio="1" aspect-ratio="1"
max-height="calc(90vh - 285px)" max-height="calc(90vh - 310px)"
class='ma-4' class='ma-4'
contain> contain>
</v-img> </v-img>
@ -70,7 +70,7 @@
</v-row> </v-row>
<!-- Bottom actions --> <!-- Bottom actions -->
<div class='d-flex my-1 mx-2 '> <div class='d-flex mx-2 mb-2'>
<v-btn icon @click='repeatClick'> <v-btn icon @click='repeatClick'>
<v-icon v-if='$root.repeat == 0'>mdi-repeat</v-icon> <v-icon v-if='$root.repeat == 0'>mdi-repeat</v-icon>
@ -134,7 +134,7 @@
<v-tabs-items v-model='tab'> <v-tabs-items v-model='tab'>
<!-- Queue tab --> <!-- Queue tab -->
<v-tab-item key='queue'> <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 <v-lazy
min-height="1" min-height="1"
transition="fade-transition" transition="fade-transition"
@ -151,7 +151,7 @@
</v-tab-item> </v-tab-item>
<!-- Info tab --> <!-- Info tab -->
<v-tab-item key='info'> <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> <h1>{{$root.track.title}}</h1>
<!-- Album --> <!-- Album -->
<h3>Album:</h3> <h3>Album:</h3>
@ -182,7 +182,7 @@
</v-tab-item> </v-tab-item>
<!-- Lyrics --> <!-- Lyrics -->
<v-tab-item key='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-tab-item>
</v-tabs-items> </v-tabs-items>
@ -204,19 +204,20 @@
<style scoped> <style scoped>
.main { .main {
width: 100vw; width: 100vw;
} }
.notop { .notop {
height: 100vh; height: 100vh;
width: 100vw;
} }
.electron { .electron {
height: calc(100vh - 28px); height: calc(100vh - 28px);
margin-top: 28px; margin-top: 28px;
width: 100vw;
} }
@media screen and (max-height: 864px) { @media screen and (max-height: 900px) {
.imagescale { .imagescale {
max-height: 50vh; 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-subtitle>{{$t("Don't minimize to tray")}}</v-list-item-subtitle>
</v-list-item-content> </v-list-item-content>
</v-list-item> </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 --> <!-- Logout -->
<v-btn block color='red' class='mt-4' @click='logout'> <v-btn block color='red' class='mt-4' @click='logout'>

View File

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

View File

@ -144,7 +144,42 @@ class DeezerAPI {
return true; return true;
} }
//Wrapper because electron is piece of shit
async callPublicApi(path, params) { 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({ let res = await axios({
url: `https://api.deezer.com/${encodeURIComponent(path)}/${encodeURIComponent(params)}`, url: `https://api.deezer.com/${encodeURIComponent(path)}/${encodeURIComponent(params)}`,
responseType: 'json', responseType: 'json',
@ -212,7 +247,7 @@ class DeezerAPI {
return this.fallback(newTrack.streamUrl); return this.fallback(newTrack.streamUrl);
} }
} catch (e) { } catch (e) {
logger.warn('TrackID Fallback failed: ' + e); logger.warn('TrackID Fallback failed: ' + e + ' Original ID: ' + qualityInfo.trackId);
} }
//ISRC Fallback //ISRC Fallback
try { try {
@ -222,7 +257,7 @@ class DeezerAPI {
let newTrack = new Track(newTrackData.results.DATA); let newTrack = new Track(newTrackData.results.DATA);
return this.fallback(newTrack.streamUrl); return this.fallback(newTrack.streamUrl);
} catch (e) { } catch (e) {
logger.warn('ISRC Fallback failed: ' + e); logger.warn('ISRC Fallback failed: ' + e + ' Original ID: ' + qualityInfo.trackId);
} }
return null; return null;
} }

View File

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

View File

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

View File

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