Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
senpos committed Apr 15, 2018
2 parents 7105cd3 + 499ad07 commit da8ebe0
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 33 deletions.
55 changes: 33 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
Important Information
=================
From Firefox 57 onwards, WebExtensions will be the only supported extension type, and Firefox will not load other types. Which mean that the actual version of **UNP won't work anymore**.

UNP rely on io/file api which doesn't exist in WebExtension API (https://bugzilla.mozilla.org/show_bug.cgi?id=1246236). This means I'll have to create an external app in addition to simply porting UNP to WebExtension.
Starting from **Firefox 57** and onwards, *WebExtensions* will be the only supported extension type, and *Firefox* will not load other types. Which mean that the actual version of **UNP won't work anymore**.

To be honest, I kind of lost interest in developping browser extension (and I'm not using UNP since years).

You can do whatever you want with this. It's now MIT licenced.

Still interested in using UNP?
=================
Even if new Firefox won't support this extension anymore, other browsers, like [Waterfox](https://www.waterfoxproject.org/) and [Cyberfox](https://cyberfox.8pecxstudios.com), which are built on top of Firefox older versions - **would**. At least for some more time.

I've tried [Waterfox](https://www.waterfoxproject.org/) as a replacement and it worked perfectly fine with the latest build of **Untamed Now Playing**.

Check [**Install > Latest unreviewed release**](#latest-unreviewed-release) section for installation instructions.


[Untamed Now Playing](https://github.com/Wylk/Untamed-Now-Playing-Next)
=================

"Untamed Now Playing" is a Firefox extension which parses the song title and artist from popular online radio/music sites, and writes it to a file on your hard drive. Programs such as Xsplit or OBS can then read the file and display it on an overlay, allowing viewers to easily see what song is currently being played.
**Untamed Now Playing** is a Firefox extension which parses the song title and artist from popular online radio/music sites, and writes it to a file on your hard drive. Programs such as Xsplit or OBS can then read the file and display it on an overlay, allowing viewers to easily see what song is currently being played.
Support Windows / Linux / OSX.

Supported Sites
--------------------------------------
## Supported Sites
* [8tracks.com](http://8tracks.com)
* [ah.fm](http://ah.fm)
* [beatport.com](https://www.beatport.com/listen)
Expand Down Expand Up @@ -67,31 +73,36 @@ Supported Sites
* [jombly.com](http://www.jombly.com)
* [listen.tidal.com](https://listen.tidal.com)

Support for more sites will be added over time. If you have a suggestion for a site, please open an issue or reply to the obs topic.
Support for more sites will be added over time. If you have a suggestion for a site, please open an issue.

Install
--------------------------------------
### Latest Mozilla reviewed version
On Mozilla Add-ons (AMO) :
# Install
> Supported browser versions: **49** - **56**
## Latest Mozilla reviewed version

### On Mozilla Add-ons (AMO)
[![amo-button_1](https://cloud.githubusercontent.com/assets/1236069/11095684/7c37b7d4-8896-11e5-9e3e-6b7913983a8c.png)](https://addons.mozilla.org/en-US/firefox/addon/untamed-now-playing/)

### Latest unreviewed release:
Get it here : https://github.com/Wykks/Untamed-Now-Playing-Next/releases.
Then drag the downloaded file onto a Firefox extension page (about:addons).
## Latest unreviewed release
> **Unsigned**, can be easily installed on Firefox-based browsers (e.g. [Waterfox](https://www.waterfoxproject.org/), [Cyberfox](https://cyberfox.8pecxstudios.com))
**Download** the latest build from [releases page](https://github.com/Wykks/Untamed-Now-Playing-Next/releases).

It will automatically promt you to install extension (
[short video explanation](https://drive.google.com/uc?id=1umZOEK1NBpDHPk1FSOimFd_WfmNh2kE2)). If it does not, then drag the downloaded file onto a Firefox extension page (`about:addons`).

### Build Latest dev version:
To build UNP you'll need npm and jpm.
## Build Latest dev version
To build UNP you'll need `npm` and `jpm`.

To install npm, read this: https://github.com/npm/npm#super-easy-install
To install `npm`, read this: https://github.com/npm/npm#super-easy-install

Then install jpm:
Then install `jpm`:

npm install jpm -g
And finally build UNP (do this where package.json is located):
And finally build UNP (do this where `package.json` is located):

jpm xpi

Then drag the xpi generated file onto a Firefox extension page (about:addons).
Then drag generated `xpi` file onto a Firefox extension page (`about:addons`).

Configuration
--------------------------------------
Expand All @@ -103,11 +114,11 @@ Limitations
--------------------------------------
At the moment, now playing data is only saved when the song intially plays and is only updated when the next song starts playing. Thus if you stop playing music, the output file will still contain the last song played.

Firefox may limits what directories can be saved to, if you run into problems, try saving to a subdirectory of your profile (C:\Users\USERNAME\* or C:\Documents and Settings\USERNAME\*).
Firefox may limits what directories can be saved to, if you run into problems, try saving to a subdirectory of your profile (`C:\Users\USERNAME\*` or `C:\Documents and Settings\USERNAME\*`).

Known Issues
--------------------------------------
Nightbot support and Stream check feature disabled (not ported to Firefox yet), ask me if you need them !
Nightbot support and Stream check features are not available.


Licence
Expand Down
13 changes: 9 additions & 4 deletions data/common/options/components/settingsForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,25 @@
tooltip: t('opt_tt_11')
}),
this.state.autoClear ? h(formOption, {
title: t('opt_13'),
title: t('opt_14'),
value: this.state.noMusicMessage,
onChange: this.linkState('noMusicMessage'),
type: 'input',
tooltip: t('opt_tt_13')
tooltip: t('opt_tt_14')
}) : null,
h(formOption, {
title: t('opt_12'),
value: this.state.browserNotification,
onChange: this.linkState('browserNotification'),
type: 'checkbox',
tooltip: t('opt_tt_12')
}),
h(formOption, {
title: t('opt_13'),
value: this.state.appendOutput,
onChange: this.linkState('appendOutput'),
type: 'checkbox',
tooltip: t('opt_tt_13')
})
),
h('p', { class: 'save' },
Expand Down Expand Up @@ -143,5 +150,3 @@

window.UNPSettingsFormComponent = SettingsForm;
})();


4 changes: 3 additions & 1 deletion data/common/options/pages/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
disableYoutube: this._getConfigBool(options.unpDisableYoutube, false),
autoClear: this._getConfigBool(options.unpAutoClear, false),
noMusicMessage: this._getConfigValue(options.unpNoMusicMessage, ''),
browserNotification: this._getConfigBool(options.unpNotification, true)
browserNotification: this._getConfigBool(options.unpNotification, true),
appendOutput: this._getConfigBool(options.unpAppendOutput, false)
},
isSaving: false,
message
Expand Down Expand Up @@ -71,6 +72,7 @@
BrowserFunc.setOption('unpAutoClear', options.autoClear);
BrowserFunc.setOption('unpNoMusicMessage', options.noMusicMessage);
BrowserFunc.setOption('unpNotification', options.browserNotification);
BrowserFunc.setOption('unpAppendOutput', options.appendOutput);
this.setState({
message: {
type: 'success',
Expand Down
6 changes: 4 additions & 2 deletions data/common/options/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"opt_10_select_twitch": "Twitch",
"opt_11": "Clear the file(s) automatically",
"opt_12": "Activate browser notifications",
"opt_13": "Custom message",
"opt_13": "Append to output",
"opt_14": "Custom message",
"opt_tt_0": "The directory where the now playing file is saved, may also be used for caching stream status",
"opt_tt_1": "The file format that the now playing file is saved as. Xsplit supports both XML and TXT, OBS just supports TXT. XML allows you display different info in different text titles in your scenes",
"opt_tt_2": "Don't include file extension",
Expand All @@ -50,7 +51,8 @@
"opt_tt_10": "Your Stream details, only used if the 'Check stream' option is enabled",
"opt_tt_11": "The file(s) will be cleared each time a page supported by UNP is closed",
"opt_tt_12": "This activate browser notification when the music change.",
"opt_tt_13": "This custom message will be written instead",
"opt_tt_13": "This causes the output file when txt, to be appended instead of overwritten each time.",
"opt_tt_14": "This custom message will be written instead",
"sites_des": "This is a list of the supported sites, and their available features. <strong>This information is only for users who want more customisation, and is irrelevant for the majority of users.</strong> The symbols in brackets are the variables used for formatting the 'Plain text' save as option.",
"sites_des_2": "<strong>'Now Playing' (%s%), 'Time Started' (%t%) and 'URL' (%u%) variables are fully supported by every site.</strong> The magnifying glass icon denotes sites which don't display the artist and title information seperately, for these sites UNP will try to split the information into Artist and Title, but accuracy can't be guaranteed.",
"sites_th_artist": "Artist (%a%)",
Expand Down
3 changes: 2 additions & 1 deletion data/common/websites-support/website.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ window.UNPCommon = (function () {
}

function nowPlaying(play) {
const timeStarted = new Intl.DateTimeFormat(undefined, { hour: 'numeric', minute: 'numeric', second: 'numeric' }).format(new Date());
//const timeStarted = new Intl.DateTimeFormat(undefined, { hour: 'numeric', minute: 'numeric', second: 'numeric' }).format(new Date());
const timeStarted = new Date().toString(); // jevan 2017dec3
window.UNPBrowserFunc.updateNowPlaying({
nowPlaying: play,
trackName: getValue(this.trackName),
Expand Down
38 changes: 36 additions & 2 deletions lib/nowPlayingIO.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ const notifications = require('sdk/notifications');
const system = require('sdk/system');
const base64 = require('./base64');

// jevan 2017dec3
// https://stackoverflow.com/questions/24174046/os-file-in-firefox-sdk-add-on
const { Cc, Ci, Cu } = require("chrome");
const { OS, TextEncoder, TextDecoder } = Cu.import("resource://gre/modules/osfile.jsm", {});

const AWS_LAMBDA_ENDPOINT = 'https://1byq43a3ca.execute-api.us-west-2.amazonaws.com/p/UNP_image_convert';

function getPath() {
Expand Down Expand Up @@ -67,7 +72,7 @@ function clearNp(path, emptyMessage) {
} else if (ss.storage.unpSaveFormat === 'json') {
promise = writeFile(path.filePath, emptyMessage && `{"nowPlaying":"${emptyMessage}"}` || '');
} else if (ss.storage.unpSaveFormat === 'txt') {
promise = writeFile(path.filePath, emptyMessage && emptyMessage || '');
promise = appendFile(path.filePath, emptyMessage && emptyMessage || '');
} else if (ss.storage.unpSaveFormat === 'multi') {
path.filePath = fileIO.dirname(path.filePath);
promise = Promise.all(
Expand Down Expand Up @@ -113,7 +118,7 @@ function writeNp(opts, path) {
} else {
fileContent = fileContent.replace(/%n%/g, '\n');
}
promise = writeFile(path, fileContent);
promise = appendFile(path, fileContent);
} else if (ss.storage.unpSaveFormat === 'multi') {
path = fileIO.dirname(path);
promise = Promise.all(
Expand Down Expand Up @@ -246,6 +251,35 @@ function writeFile(filename, text) {
});
}

// jevan 2017dec3
function appendText(filename, text) {
// https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/OSFile.jsm/OS.File_for_the_main_thread
//filename = OS.Path.join(OS.Constants.Path.tmpDir, filename);
OS.File.open(filename, {write: true, append: true}).then(valOpen => {
//console.log('valOpen:', valOpen);
var txtEncoded = new TextEncoder().encode(text);
valOpen.write(txtEncoded).then(valWrite => {
//console.log('valWrite:', valWrite);
valOpen.close().then(valClose => {
//console.log('valClose:', valClose);
//console.log('successfully appended');
});
});
});
}

// jevan 2017dec3
function appendFile(filename, text) {
if (ss.storage.unpAppendOutput === true) {
return new Promise((resolve, reject) => {
appendText(filename, text+"\r\n");
resolve();
});
} else {
return writeFile(filename, text);
}
}

function createDirIfNotExists(directory) {
try {
fileIO.mkpath(directory);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"engines": {
"firefox": ">=49.0"
},
"license": "CC BY-SA 3.0",
"license": "MIT",
"preferences": [
{
"name": "options_button",
Expand Down

0 comments on commit da8ebe0

Please sign in to comment.