diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..18deb34 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,13 @@ +version: 2 +jobs: + build: + machine: # for docker --privileged + image: circleci/classic:latest + working_directory: ~/workdir + steps: + - checkout + - run: + name: Install deps & check project + command: wget https://raw.githubusercontent.com/tiliado/nuvolasdk/master/scripts/circleci.sh && chmod a+x circleci.sh && ./circleci.sh + - store_artifacts: + path: ~/workdir/keep diff --git a/CHANGELOG.md b/CHANGELOG.md index 6812e8a..c24ea9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ Pretzel Change Log ====================== -1.1 - unreleased +1.0 - unreleased ---------------- * Initial release. diff --git a/README.md b/README.md index 6830308..695ac81 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,9 @@ Integration of Pretzel into your linux desktop via Support ------- -Follow [Bug reporting guidelines](https://github.com/tiliado/nuvolaruntime/wiki/Bug-Reporting-Guidelines). + - Use [Nuvola Runtime issue tracker](https://github.com/tiliado/nuvolaruntime/issues/new/choose) + to report bugs, ask questions or suggest features. + - Follow [Bug reporting guidelines](https://github.com/tiliado/nuvolaruntime/wiki/Bug-Reporting-Guidelines). Installation ------------ diff --git a/configure b/configure index 6321158..0b035da 100755 --- a/configure +++ b/configure @@ -1,3 +1,3 @@ #!/usr/bin/env python3 import nuvolasdk -nuvolasdk.gen_makefile("4.18.1") +nuvolasdk.gen_makefile("4.18.0") diff --git a/integrate.js b/integrate.js index 10cd3b1..1d3c6e1 100644 --- a/integrate.js +++ b/integrate.js @@ -25,6 +25,9 @@ 'use strict'; (function (Nuvola) { + const PLAY_SVG = 'M16.032 31.584c-8.64 0-15.616-6.976-15.616-15.616S7.392.416 16.032.416s15.552 6.976 15.552 15.616c0 8.576-6.976 15.552-15.552 15.552zm0-30.08c-8.064 0-14.528 6.464-14.528 14.528S7.968 30.56 16.032 30.56 30.56 24.096 30.56 16.032c-.064-8.064-6.528-14.528-14.528-14.528zm-3.776 8.992l9.568 5.536-9.568 5.536V10.496M11.168 8.64v14.72l12.672-7.328L11.168 8.64z' + const PAUSE_SVG = 'M16.032 31.584c-8.64 0-15.616-6.976-15.616-15.616S7.392.416 16.032.416s15.552 6.976 15.552 15.616c0 8.576-6.976 15.552-15.552 15.552zm0-30.08c-8.064 0-14.528 6.464-14.528 14.528S7.968 30.56 16.032 30.56 30.56 24.096 30.56 16.032c-.064-8.064-6.528-14.528-14.528-14.528zm-3.776 8.064h1.696v12.864h-1.696V9.568zm5.888 0h1.664v12.864h-1.664V9.568z' + // Create media player component const player = Nuvola.$object(Nuvola.MediaPlayer) @@ -58,16 +61,31 @@ // Extract data from the web page WebApp.update = function () { + const elms = this._getElements() const track = { - title: null, - artist: null, - album: null, - artLocation: null, + title: Nuvola.queryText('.hOOKvw span.oKpSL'), + artist: Nuvola.queryAttribute('.hOOKvw p.ZSqOQ', 'title'), + album: Nuvola.queryAttribute('.hOOKvw p.ZSqOQ:last-child', 'title'), + artLocation: Nuvola.queryAttribute('.hOOKvw img.hFdXsU', 'src'), rating: null } player.setTrack(track) - player.setPlaybackState(PlaybackState.UNKNOWN) + + let state + if (elms.pause) { + state = PlaybackState.PLAYING + } else if (elms.play) { + state = PlaybackState.PAUSED + } else { + state = PlaybackState.UNKNOWN + } + player.setPlaybackState(state) + + player.setCanGoPrev(!!elms.prev) + player.setCanGoNext(!!elms.next) + player.setCanPlay(!!elms.play) + player.setCanPause(!!elms.pause) // Schedule the next update setTimeout(this.update.bind(this), 500) @@ -75,11 +93,66 @@ // Handler of playback actions WebApp._onActionActivated = function (emitter, name, param) { + const elms = this._getElements() switch (name) { - case PlayerAction.Play: + case PlayerAction.TOGGLE_PLAY: + if (elms.play) { + Nuvola.clickOnElement(elms.play) + } else { + Nuvola.clickOnElement(elms.pause) + } + break + case PlayerAction.PLAY: + Nuvola.clickOnElement(elms.play) + break + case PlayerAction.PAUSE: + case PlayerAction.STOP: + Nuvola.clickOnElement(elms.pause) + break + case PlayerAction.PREV_SONG: + Nuvola.clickOnElement(elms.prev) + break + case PlayerAction.NEXT_SONG: + Nuvola.clickOnElement(elms.next) break } } + WebApp._getElements = function () { + // Interesting elements + const elms = { + play: document.querySelector('.hOOKvw button.hrAWUR > svg.jStubB'), + pause: null, + next: document.querySelector('.hOOKvw button.ionnrC > svg.betPcV'), + prev: document.querySelector('.hOOKvw button.ionnrC > svg.cIilyo') + } + + if (elms.play) { + const svg = elms.play.firstElementChild.getAttribute('d') + if (svg === PAUSE_SVG) { + elms.pause = elms.play + elms.play = null + } else if (svg !== PLAY_SVG) { + elms.play = null + } + } + + for (const key in elms) { + if (elms[key]) { + // Get parent buttons + if (elms[key].tagName == 'svg') { + elms[key] = elms[key].parentElement + } + + // Ignore disabled buttons + if (elms[key].disabled) { + elms[key] = null + } + } + } + + return elms + } + WebApp.start() })(this) // function(Nuvola) diff --git a/metadata.in.json b/metadata.in.json index 3892592..711b1af 100644 --- a/metadata.in.json +++ b/metadata.in.json @@ -1,7 +1,7 @@ { "id": "pretzel", "name": "Pretzel", - "home_url": "https://app.pretzel.rocks", + "home_url": "https://play.pretzel.rocks", "maintainer_name": "Jiří Janoušek", "maintainer_link": "https://github.com/fenryxo", "version_major": 1, @@ -17,5 +17,6 @@ "src/icon-xs.svg 16 22 24", "src/icon-sm.svg 32 48" ] - } + }, + "dark_theme": true } diff --git a/src/webview.png b/src/webview.png new file mode 100644 index 0000000..79b0a0c Binary files /dev/null and b/src/webview.png differ