From 39145b23664d082d52f6d715a43fb4755b03d162 Mon Sep 17 00:00:00 2001 From: Benjamin Tan Date: Sun, 2 Oct 2016 18:37:18 +0800 Subject: [PATCH 01/16] Ensure that default file/protocol handlers are re-installed after updating. Previously, they were only installed when the preference was changed. This caused the handlers to point to non-existing files after updates occurred and older versions were removed by Squirrel. Closes #791, #911. --- src/renderer/lib/migrations.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/renderer/lib/migrations.js b/src/renderer/lib/migrations.js index 2fad6b1349..341c7824e8 100644 --- a/src/renderer/lib/migrations.js +++ b/src/renderer/lib/migrations.js @@ -29,10 +29,23 @@ function run (state) { if (semver.lt(version, '0.17.0')) migrate_0_17_0(saved) if (semver.lt(version, '0.17.2')) migrate_0_17_2(saved) + if (semver.lt(version, config.APP_VERSION)) { + installHandlers(state.saved) + } + // Config is now on the new version state.saved.version = config.APP_VERSION } +// Whenever the app is updated, re-install default handlers if the user has +// enabled them. +function installHandlers (saved) { + if (saved.prefs.isFileHandler) { + const ipcRenderer = require('electron').ipcRenderer + ipcRenderer.send('setDefaultFileHandler', true) + } +} + function migrate_0_7_0 (saved) { const cpFile = require('cp-file') const path = require('path') From 0e0b0e6d2c0cfa8c2e3be6b2d3dfe3b403e2abaa Mon Sep 17 00:00:00 2001 From: Borewit Date: Mon, 13 Aug 2018 11:41:48 +0200 Subject: [PATCH 02/16] webtorrent/webtorrent-desktop#1340: Switch to async metadata updates. --- src/renderer/pages/player-page.js | 4 +--- src/renderer/webtorrent.js | 13 +++++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index cf7de1cdd5..44e9682638 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -216,9 +216,7 @@ function renderAudioMetadata (state) { const elems = [] // Audio metadata: artist(s) - const artist = common.albumartist || common.artist || - (common.artists && common.artists.filter(function (a) { return a }).join(', ')) || - '(Unknown Artist)' + const artist = common.artist || common.albumartist if (artist) { elems.push((
diff --git a/src/renderer/webtorrent.js b/src/renderer/webtorrent.js index d6406da1f0..e328d36974 100644 --- a/src/renderer/webtorrent.js +++ b/src/renderer/webtorrent.js @@ -345,7 +345,13 @@ function getAudioMetadata (infoHash, index) { const metadata = { title: file.name } ipc.send('wt-audio-metadata', infoHash, index, metadata) - const options = {native: false, skipCovers: true, fileSize: file.length} + const options = {native: false, + skipCovers: true, + fileSize: file.length, + observer: (event) => { + console.log(`async-audio-metadata-update: file='${file.name}', type=${event.tag.type}, tag-id=${event.tag.id}`) + ipc.send('wt-audio-metadata', infoHash, index, event.metadata) + }} const onMetaData = file.done // If completed; use direct file access ? mm.parseFile(path.join(torrent.path, file.path), options) @@ -353,9 +359,8 @@ function getAudioMetadata (infoHash, index) { : mm.parseStream(file.createReadStream(), file.name, options) onMetaData - .then(function (metadata) { - console.log('got audio metadata for %s (length=%s): %o', file.name, file.length, metadata) - ipc.send('wt-audio-metadata', infoHash, index, metadata) + .then(function () { + console.log(`metadata for file='${file.name}' completed.`) }).catch(function (err) { return console.log('error getting audio metadata for ' + infoHash + ':' + index, err) }) From 198c62e9ad3881ee032f66723ad8b4ab41d10c52 Mon Sep 17 00:00:00 2001 From: Borewit Date: Mon, 13 Aug 2018 17:55:59 +0200 Subject: [PATCH 03/16] Use fat arrow --- src/renderer/webtorrent.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/webtorrent.js b/src/renderer/webtorrent.js index e328d36974..447db77428 100644 --- a/src/renderer/webtorrent.js +++ b/src/renderer/webtorrent.js @@ -348,7 +348,7 @@ function getAudioMetadata (infoHash, index) { const options = {native: false, skipCovers: true, fileSize: file.length, - observer: (event) => { + observer: event => { console.log(`async-audio-metadata-update: file='${file.name}', type=${event.tag.type}, tag-id=${event.tag.id}`) ipc.send('wt-audio-metadata', infoHash, index, event.metadata) }} @@ -359,7 +359,7 @@ function getAudioMetadata (infoHash, index) { : mm.parseStream(file.createReadStream(), file.name, options) onMetaData - .then(function () { + .then(() => { console.log(`metadata for file='${file.name}' completed.`) }).catch(function (err) { return console.log('error getting audio metadata for ' + infoHash + ':' + index, err) From a30d8046cc0a11915c39b5bbc450a35cee9d821e Mon Sep 17 00:00:00 2001 From: Borewit Date: Wed, 15 Aug 2018 21:45:48 +0200 Subject: [PATCH 04/16] Fix issue track number not displayed if total number of tracks is not defined (common.track.of === null). --- src/renderer/pages/player-page.js | 35 +++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index 7fb8114420..401a3fa0fe 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -204,6 +204,24 @@ function renderOverlay (state) { ) } +/** + * Render track or disk number string + * @param key should be either 'track' or 'disk' + * @param label should be either 'Track' or 'Disk' + */ +function renderTrack (common, key, label) { + // Audio metadata: track-number + if (common[key].no) { + let str = `${common[key].no}` + if (common[key].of) { + str += ` of ${common[key].of}` + } + return React.createElement('div', { key, className: 'audio-' + key }, + React.createElement('label', null, label), str + ) + } +} + function renderAudioMetadata (state) { const fileSummary = state.getPlayingFileSummary() if (!fileSummary.audioInfo) return @@ -269,15 +287,14 @@ function renderAudioMetadata (state) { )) } - // Audio metadata: track-number - if (common.track && common.track.no && common.track.of) { - const track = common.track.no + ' of ' + common.track.of - elems.push(( -
- {track} -
- )) - } + // Audio metadata: disk & track-number + const count = ['track'] + count.forEach(key => { + const nrElem = renderTrack(common, key, key[0].toUpperCase() + key.substring(1)) + if (nrElem) { + elems.push(nrElem) + } + }) // Audio metadata: format const format = [] From c2594f500d216a206e7f6c0d8cf8de9d4e2bcef6 Mon Sep 17 00:00:00 2001 From: Borewit Date: Wed, 15 Aug 2018 21:46:12 +0200 Subject: [PATCH 05/16] Add disk number in addition to track number. --- src/renderer/pages/player-page.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index 401a3fa0fe..3817938d07 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -288,7 +288,7 @@ function renderAudioMetadata (state) { } // Audio metadata: disk & track-number - const count = ['track'] + const count = ['track', 'disk'] count.forEach(key => { const nrElem = renderTrack(common, key, key[0].toUpperCase() + key.substring(1)) if (nrElem) { From c7f30df542abda4066bc38194a3cd17dbe123527 Mon Sep 17 00:00:00 2001 From: Borewit Date: Wed, 15 Aug 2018 21:48:27 +0200 Subject: [PATCH 06/16] Update order of audio properties from: album, track, disk, format to track, disk, album, format --- src/renderer/pages/player-page.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index 3817938d07..b300506ee8 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -245,6 +245,15 @@ function renderAudioMetadata (state) { )) } + // Audio metadata: disk & track-number + const count = ['track', 'disk'] + count.forEach(key => { + const nrElem = renderTrack(common, key, key[0].toUpperCase() + key.substring(1)) + if (nrElem) { + elems.push(nrElem) + } + }) + // Audio metadata: album if (common.album) { elems.push(( @@ -287,15 +296,6 @@ function renderAudioMetadata (state) { )) } - // Audio metadata: disk & track-number - const count = ['track', 'disk'] - count.forEach(key => { - const nrElem = renderTrack(common, key, key[0].toUpperCase() + key.substring(1)) - if (nrElem) { - elems.push(nrElem) - } - }) - // Audio metadata: format const format = [] fileSummary.audioInfo.format = fileSummary.audioInfo.format || '' From b73db82a130e6fe5cac0abde8c784b5e41f04115 Mon Sep 17 00:00:00 2001 From: Borewit Date: Thu, 16 Aug 2018 21:00:26 +0200 Subject: [PATCH 07/16] #1340 Update music-metadata to 2.5.0, enabling async 'per' tag updates #1452 Fix for playing some '.m4b' files --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1a07d4f68b..726ed4ab89 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "location-history": "^1.0.0", "material-ui": "^0.17.0", "mkdirp": "^0.5.1", - "music-metadata": "^2.4.2", + "music-metadata": "^2.5.0", "network-address": "^1.1.0", "parse-torrent": "^6.0.1", "prettier-bytes": "^1.0.1", From 8848534988dbc0c3f895ebd93f227e58a59b7d66 Mon Sep 17 00:00:00 2001 From: Borewit Date: Thu, 16 Aug 2018 21:03:26 +0200 Subject: [PATCH 08/16] #1340 Commented out the metadata event debug output. --- src/renderer/webtorrent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/webtorrent.js b/src/renderer/webtorrent.js index 447db77428..733f21c4c0 100644 --- a/src/renderer/webtorrent.js +++ b/src/renderer/webtorrent.js @@ -349,7 +349,7 @@ function getAudioMetadata (infoHash, index) { skipCovers: true, fileSize: file.length, observer: event => { - console.log(`async-audio-metadata-update: file='${file.name}', type=${event.tag.type}, tag-id=${event.tag.id}`) + // console.log(`async-audio-metadata-update: file='${file.name}', type=${event.tag.type}, tag-id=${event.tag.id}`) ipc.send('wt-audio-metadata', infoHash, index, event.metadata) }} const onMetaData = file.done From f925b1f471b499a55de51634410a47b0a95d1b1d Mon Sep 17 00:00:00 2001 From: Borewit Date: Thu, 16 Aug 2018 21:11:52 +0200 Subject: [PATCH 09/16] #1340 Remove line comment to get rid of max line length lint error --- src/renderer/webtorrent.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/renderer/webtorrent.js b/src/renderer/webtorrent.js index 733f21c4c0..1d61f8c296 100644 --- a/src/renderer/webtorrent.js +++ b/src/renderer/webtorrent.js @@ -349,7 +349,6 @@ function getAudioMetadata (infoHash, index) { skipCovers: true, fileSize: file.length, observer: event => { - // console.log(`async-audio-metadata-update: file='${file.name}', type=${event.tag.type}, tag-id=${event.tag.id}`) ipc.send('wt-audio-metadata', infoHash, index, event.metadata) }} const onMetaData = file.done From 090b9060499caca0a5923caf6d48880a5ec5acf3 Mon Sep 17 00:00:00 2001 From: Borewit Date: Fri, 17 Aug 2018 16:55:32 +0200 Subject: [PATCH 10/16] Update music-metadata 2.6.0 to fix some async events are getting triggered. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 07bfba846a..efcef9de89 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "location-history": "^1.0.0", "material-ui": "^0.17.0", "mkdirp": "^0.5.1", - "music-metadata": "^2.5.0", + "music-metadata": "^2.6.0", "network-address": "^1.1.0", "parse-torrent": "^6.0.1", "prettier-bytes": "^1.0.1", From e2448ca74040ab6f235101f3859914509d442d00 Mon Sep 17 00:00:00 2001 From: Borewit Date: Sat, 18 Aug 2018 20:45:51 +0200 Subject: [PATCH 11/16] Return JSX block. --- src/renderer/pages/player-page.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index b300506ee8..e289a11a28 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -216,8 +216,11 @@ function renderTrack (common, key, label) { if (common[key].of) { str += ` of ${common[key].of}` } - return React.createElement('div', { key, className: 'audio-' + key }, - React.createElement('label', null, label), str + const style = { textTransform: 'capitalize' } + return ( +
+ {str} +
) } } From 43065699852bd1652c0bf90ce76567294d21cfad Mon Sep 17 00:00:00 2001 From: Borewit Date: Sun, 19 Aug 2018 09:49:31 +0200 Subject: [PATCH 12/16] Get rid of third parameter which is replaced by CSS capitalize --- src/renderer/pages/player-page.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index e289a11a28..b9c7871353 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -206,10 +206,11 @@ function renderOverlay (state) { /** * Render track or disk number string + * @param common metadata.common part * @param key should be either 'track' or 'disk' - * @param label should be either 'Track' or 'Disk' + * @return track or disk number metadata as JSX block */ -function renderTrack (common, key, label) { +function renderTrack (common, key) { // Audio metadata: track-number if (common[key].no) { let str = `${common[key].no}` @@ -251,7 +252,7 @@ function renderAudioMetadata (state) { // Audio metadata: disk & track-number const count = ['track', 'disk'] count.forEach(key => { - const nrElem = renderTrack(common, key, key[0].toUpperCase() + key.substring(1)) + const nrElem = renderTrack(common, key) if (nrElem) { elems.push(nrElem) } From 8e9184084dc1ffbec45b273b71a92816018bbb00 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Sun, 19 Aug 2018 09:50:21 -0300 Subject: [PATCH 13/16] Fixed error when value is undefined. --- src/renderer/pages/player-page.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index b9c7871353..23713b0df1 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -212,7 +212,7 @@ function renderOverlay (state) { */ function renderTrack (common, key) { // Audio metadata: track-number - if (common[key].no) { + if (common[key] && common[key].no) { let str = `${common[key].no}` if (common[key].of) { str += ` of ${common[key].of}` From e34edc2629a327c0c55c4b937df37649b646b835 Mon Sep 17 00:00:00 2001 From: Borewit Date: Wed, 29 Aug 2018 08:31:58 +0200 Subject: [PATCH 14/16] Update music-metadata dependency to 2.6.1. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index efcef9de89..54ab87352a 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "location-history": "^1.0.0", "material-ui": "^0.17.0", "mkdirp": "^0.5.1", - "music-metadata": "^2.6.0", + "music-metadata": "^2.6.1", "network-address": "^1.1.0", "parse-torrent": "^6.0.1", "prettier-bytes": "^1.0.1", From db50e97d7dd21f7d95486b2599a5076b42603809 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Thu, 20 Sep 2018 01:31:07 +0000 Subject: [PATCH 15/16] fix(package): update music-metadata to version 3.1.0 Closes #1478 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6390034710..0774671ec5 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "location-history": "^1.0.0", "material-ui": "^0.17.0", "mkdirp": "^0.5.1", - "music-metadata": "^2.4.2", + "music-metadata": "^3.1.0", "network-address": "^1.1.0", "parse-torrent": "^6.0.1", "prettier-bytes": "^1.0.1", From 78b71d3fee40a940ddcdf61baadba9a1be32c883 Mon Sep 17 00:00:00 2001 From: Mathias Rasmussen Date: Wed, 26 Sep 2018 22:17:36 +0200 Subject: [PATCH 16/16] Revert "Ensure that default file/protocol handlers are re-installed after updating." This reverts commit 39145b23664d082d52f6d715a43fb4755b03d162. --- src/renderer/lib/migrations.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/renderer/lib/migrations.js b/src/renderer/lib/migrations.js index 1f9696c323..ece7125d32 100644 --- a/src/renderer/lib/migrations.js +++ b/src/renderer/lib/migrations.js @@ -29,23 +29,10 @@ function run (state) { if (semver.lt(version, '0.17.0')) migrate_0_17_0(saved) if (semver.lt(version, '0.17.2')) migrate_0_17_2(saved) - if (semver.lt(version, config.APP_VERSION)) { - installHandlers(state.saved) - } - // Config is now on the new version state.saved.version = config.APP_VERSION } -// Whenever the app is updated, re-install default handlers if the user has -// enabled them. -function installHandlers (saved) { - if (saved.prefs.isFileHandler) { - const ipcRenderer = require('electron').ipcRenderer - ipcRenderer.send('setDefaultFileHandler', true) - } -} - function migrate_0_7_0 (saved) { const cpFile = require('cp-file') const path = require('path')