Skip to content

Commit

Permalink
Merge branch 'streamproviders'
Browse files Browse the repository at this point in the history
  • Loading branch information
bastimeyer committed Nov 5, 2016
2 parents 62c749d + 8348a22 commit fdad4cb
Show file tree
Hide file tree
Showing 14 changed files with 446 additions and 186 deletions.
31 changes: 18 additions & 13 deletions src/app/components/link/DocumentationLinkComponent.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
import {
get,
computed
computed,
inject
} from "Ember";
import { livestreamer } from "config";
import { streamprovider } from "config";
import ExternalLinkComponent from "components/link/ExternalLinkComponent";
import layout from "templates/components/link/DocumentationLinkComponent.hbs";


const { "docs-url": livestreamerDocsUrl } = livestreamer;
const { service } = inject;
const {
providers,
"docs-url": docsUrl
} = streamprovider;


export default ExternalLinkComponent.extend({
layout,

// default baseUrl is the livestreamer docs url
baseUrl: livestreamerDocsUrl,
settings: service(),

// default baseUrl
baseUrl: computed( "settings.streamprovider", function() {
let streamprovider = get( this, "settings.streamprovider" );
let type = providers[ streamprovider ].type;

return docsUrl[ type ];
}),

tagName: "span",
classNameBindings: [ ":documentation-link-component", "url:with-url" ],
attributeBindings: [ "title" ],

title: computed( "baseUrl", "url", function() {
return get( this, "url" )
// keep default behavior
? get( this, "baseUrl" ) === livestreamerDocsUrl
? "Read the documentation of this livestreamer parameter"
: "Read the documentation in your web browser"
: "";
}),
title: "Read the documentation in your web browser",

url: computed( "baseUrl", "item", function() {
var baseUrl = get( this, "baseUrl" );
Expand Down
28 changes: 22 additions & 6 deletions src/app/components/modal/ModalLivestreamerComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
inject,
run
} from "Ember";
import { livestreamer } from "config";
import { streamprovider } from "config";
import ModalDialogComponent from "components/modal/ModalDialogComponent";
import qualities from "models/LivestreamerQualities";
import openBrowser from "nwjs/openBrowser";
Expand All @@ -16,13 +16,15 @@ const { readOnly } = computed;
const { service } = inject;
const { schedule } = run;
const {
"download-url": livestreamerDownloadUrl,
providers,
"download-url": downloadUrl,
"version-min": versionMin
} = livestreamer;
} = streamprovider;


export default ModalDialogComponent.extend({
livestreamer: service(),
settings: service(),

layout,

Expand All @@ -32,13 +34,27 @@ export default ModalDialogComponent.extend({
active: readOnly( "livestreamer.active" ),

qualities,
versionMin,
versionMin: computed( "settings.streamprovider", function() {
let streamprovider = get( this, "settings.streamprovider" );
let type = providers[ streamprovider ][ "type" ];

return versionMin[ type ];
}),

providername: computed( "settings.streamprovider", function() {
let streamprovider = get( this, "settings.streamprovider" );

return providers[ streamprovider ][ "name" ];
}),


actions: {
download( success ) {
if ( livestreamerDownloadUrl ) {
openBrowser( livestreamerDownloadUrl );
let streamprovider = get( this, "settings.streamprovider" );
let provider = providers[ streamprovider ][ "type" ];

if ( downloadUrl[ provider ] ) {
openBrowser( downloadUrl[ provider ] );
if ( success instanceof Function ) {
success();
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import vars from "root/config/vars.json";
import update from "root/config/update.json";
import themes from "root/config/themes.json";
import langs from "root/config/langs.json";
import livestreamer from "root/config/livestreamer.json";
import streamprovider from "root/config/streamprovider.json";
import players from "root/config/players.json";
import twitch from "root/config/twitch.json";
import notification from "root/config/notification.json";
Expand All @@ -20,7 +20,7 @@ export {
update,
themes,
langs,
livestreamer,
streamprovider,
players,
twitch,
notification,
Expand Down
17 changes: 17 additions & 0 deletions src/app/controllers/SettingsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Controller
} from "Ember";
import {
streamprovider,
players,
langs,
themes
Expand All @@ -21,6 +22,7 @@ import { delimiter } from "path";

const { alias, equal } = computed;
const { service } = inject;
const { providers } = streamprovider;
const { themes: themesList } = themes;

const kPlayers = Object.keys( players );
Expand Down Expand Up @@ -61,6 +63,21 @@ export default Controller.extend( RetryTransitionMixin, {
retryOpenMin : settingsAttrMeta( "retry_open", "min" ),
retryOpenMax : settingsAttrMeta( "retry_open", "max" ),

streamproviders: providers,
streamprovidersDropDown: computed(function() {
return Object.keys( providers )
.filter(function( key ) {
// exclude unsupported providers
return providers[ key ][ "exec" ][ platform.platform ];
})
.map(function( key ) {
return {
id: key,
label: providers[ key ][ "label" ]
};
});
}),

players,
playerPresets: computed(function() {
let presetList = kPlayers
Expand Down
5 changes: 5 additions & 0 deletions src/app/initializers/localstorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ function upgradeSettings() {
settings.gui_homepage = "/user/followedStreams";
}

// translate old livestreamer data into the executable format
if ( typeof settings.livestreamer === "string" ) {
delete settings[ "livestreamer" ];
}

// translate old player data into the player presets format
if ( typeof settings.player === "string" ) {
settings.player = {
Expand Down
44 changes: 42 additions & 2 deletions src/app/models/localstorage/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,56 @@ import {
Model
} from "EmberData";
import {
streamprovider,
players,
langs
} from "config";
import qualities from "models/LivestreamerQualities";
import { isWin } from "utils/node/platform";
import {
platform as platformName,
isWin
} from "utils/node/platform";


const {
providers,
"default-provider": defaultProvider,
} = streamprovider;
const langCodes = Object.keys( langs );



function defaultStreamprovider() {
let supported = Object.keys( providers )
.filter(function( provider ) {
return providers[ provider ][ "exec" ][ platformName ];
});

let indexDefault = supported.indexOf( defaultProvider );
if ( indexDefault !== -1 ) {
return supported[ indexDefault ];
}

return supported[0] || defaultProvider;
}

function defaultStreamproviders() {
return Object.keys( providers )
.reduce(function( obj, provider ) {
let execObj = providers[ provider ];

let item = {};
item.exec = "";
if ( execObj[ "python" ] ) {
item.pythonscript = "";
}

obj[ provider ] = item;

return obj;
}, {} );
}

function defaultQualityPresets() {
return qualities.reduce(function( obj, quality ) {
obj[ quality.id ] = "";
Expand Down Expand Up @@ -68,7 +107,8 @@ function defaultLangFilterValue() {
*/
export default Model.extend({
advanced : attr( "boolean", { defaultValue: false } ),
livestreamer : attr( "string", { defaultValue: "" } ),
streamprovider : attr( "string", { defaultValue: defaultStreamprovider } ),
streamproviders : attr( "", { defaultValue: defaultStreamproviders } ),
livestreamer_params : attr( "string", { defaultValue: "" } ),
livestreamer_oauth : attr( "boolean", { defaultValue: true } ),
quality : attr( "string", { defaultValue: "source" } ),
Expand Down
Loading

0 comments on commit fdad4cb

Please sign in to comment.