mirror of
https://github.com/SuperBFG7/ympd
synced 2024-11-29 16:09:55 +00:00
parent
ec008a4995
commit
d9ec70a9da
13
README.md
13
README.md
@ -28,12 +28,13 @@ Run flags
|
|||||||
```
|
```
|
||||||
Usage: ./ympd [OPTION]...
|
Usage: ./ympd [OPTION]...
|
||||||
|
|
||||||
-h, --host <host> connect to mpd at host [localhost]
|
-h, --host <host> connect to mpd at host [localhost]
|
||||||
-p, --port <port> connect to mpd at port [6600]
|
-p, --port <port> connect to mpd at port [6600]
|
||||||
-w, --webport [ip:]<port> listen interface/port for webserver [8080]
|
-w, --webport [ip:]<port> listen interface/port for webserver [8080]
|
||||||
-u, --user <username> drop priviliges to user after socket bind
|
-d, --dirbletoken <apitoken> Dirble API token
|
||||||
-V, --version get version
|
-u, --user <username> drop priviliges to user after socket bind
|
||||||
--help this help
|
-V, --version get version
|
||||||
|
--help this help
|
||||||
```
|
```
|
||||||
|
|
||||||
SSL Support
|
SSL Support
|
||||||
|
@ -24,6 +24,7 @@ YMPD_USER=nobody
|
|||||||
MPD_HOST=localhost
|
MPD_HOST=localhost
|
||||||
MPD_PORT=6600
|
MPD_PORT=6600
|
||||||
WEB_PORT=8080
|
WEB_PORT=8080
|
||||||
|
DIRBLE_API_TOKEN=2e223c9909593b94fc6577361a
|
||||||
|
|
||||||
|
|
||||||
# Exit if the package is not installed
|
# Exit if the package is not installed
|
||||||
@ -35,7 +36,7 @@ WEB_PORT=8080
|
|||||||
# Load the VERBOSE setting and other rcS variables
|
# Load the VERBOSE setting and other rcS variables
|
||||||
[ -f /etc/default/rcS ] && . /etc/default/rcS
|
[ -f /etc/default/rcS ] && . /etc/default/rcS
|
||||||
|
|
||||||
DAEMON_OPT="--user $YMPD_USER --webport $WEB_PORT --host $MPD_HOST --port $MPD_PORT"
|
DAEMON_OPT="--user $YMPD_USER --webport $WEB_PORT --host $MPD_HOST --port $MPD_PORT --dirbletoken $DIRBLE_API_TOKEN"
|
||||||
|
|
||||||
do_start()
|
do_start()
|
||||||
{
|
{
|
||||||
|
@ -2,3 +2,4 @@ MPD_HOST=localhost
|
|||||||
MPD_PORT=6600
|
MPD_PORT=6600
|
||||||
WEB_PORT=8080
|
WEB_PORT=8080
|
||||||
YMPD_USER=nobody
|
YMPD_USER=nobody
|
||||||
|
DIRBLE_API_TOKEN=2e223c9909593b94fc6577361a
|
||||||
|
@ -7,8 +7,9 @@ Environment=MPD_HOST=localhost
|
|||||||
Environment=MPD_PORT=6600
|
Environment=MPD_PORT=6600
|
||||||
Environment=WEB_PORT=8080
|
Environment=WEB_PORT=8080
|
||||||
Environment=YMPD_USER=nobody
|
Environment=YMPD_USER=nobody
|
||||||
|
Environment=DIRBLE_API_TOKEN=2e223c9909593b94fc6577361a
|
||||||
EnvironmentFile=/etc/default/ympd
|
EnvironmentFile=/etc/default/ympd
|
||||||
ExecStart=/usr/bin/ympd --user $YMPD_USER --webport $WEB_PORT --host $MPD_HOST --port $MPD_PORT
|
ExecStart=/usr/bin/ympd --user $YMPD_USER --webport $WEB_PORT --host $MPD_HOST --port $MPD_PORT --dirbletoken $DIRBLE_API_TOKEN
|
||||||
Type=simple
|
Type=simple
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* ympd
|
/* ympd
|
||||||
(c) 2013-2014 Andrew Karpow <andy@ndyk.de>
|
(c) 2013-2014 Andrew Karpow <andy@ndyk.de>
|
||||||
This project's homepage is: http://www.ympd.org
|
This project's homepage is: https://www.ympd.org
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -29,6 +29,8 @@ var dirble_selected_cat = "";
|
|||||||
var dirble_catid = "";
|
var dirble_catid = "";
|
||||||
var dirble_page = 1;
|
var dirble_page = 1;
|
||||||
var isTouch = Modernizr.touch ? 1 : 0;
|
var isTouch = Modernizr.touch ? 1 : 0;
|
||||||
|
var dirble_api_token = "";
|
||||||
|
var dirble_stations = false;
|
||||||
|
|
||||||
var app = $.sammy(function() {
|
var app = $.sammy(function() {
|
||||||
|
|
||||||
@ -127,7 +129,13 @@ var app = $.sammy(function() {
|
|||||||
dirble_catid = this.params['splat'][0];
|
dirble_catid = this.params['splat'][0];
|
||||||
dirble_page = this.params['splat'][1];
|
dirble_page = this.params['splat'][1];
|
||||||
|
|
||||||
dirble_load_stations();
|
dirble_stations = true;
|
||||||
|
|
||||||
|
if(dirble_api_token) {
|
||||||
|
dirble_load_stations();
|
||||||
|
} else {
|
||||||
|
getDirbleApiToken();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -144,7 +152,13 @@ var app = $.sammy(function() {
|
|||||||
$('#panel-heading').text("Dirble");
|
$('#panel-heading').text("Dirble");
|
||||||
$('#dirble').addClass('active');
|
$('#dirble').addClass('active');
|
||||||
|
|
||||||
dirble_load_categories();
|
dirble_stations = false;
|
||||||
|
|
||||||
|
if(dirble_api_token) {
|
||||||
|
dirble_load_categories();
|
||||||
|
} else {
|
||||||
|
getDirbleApiToken();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.get("/", function(context) {
|
this.get("/", function(context) {
|
||||||
@ -493,6 +507,15 @@ function webSocketConnect() {
|
|||||||
if(obj.data.passwort_set)
|
if(obj.data.passwort_set)
|
||||||
$('#mpd_password_set').removeClass('hide');
|
$('#mpd_password_set').removeClass('hide');
|
||||||
break;
|
break;
|
||||||
|
case "dirbleapitoken":
|
||||||
|
dirble_api_token = obj.data;
|
||||||
|
|
||||||
|
if(dirble_stations) {
|
||||||
|
dirble_load_stations();
|
||||||
|
} else {
|
||||||
|
dirble_load_categories();
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "error":
|
case "error":
|
||||||
$('.top-right').notify({
|
$('.top-right').notify({
|
||||||
message:{text: obj.data},
|
message:{text: obj.data},
|
||||||
@ -652,6 +675,10 @@ function getHost() {
|
|||||||
$('#mpd_pw_con').keypress(onEnter);
|
$('#mpd_pw_con').keypress(onEnter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDirbleApiToken() {
|
||||||
|
socket.send('MPD_API_GET_DIRBLEAPITOKEN');
|
||||||
|
}
|
||||||
|
|
||||||
$('#search').submit(function () {
|
$('#search').submit(function () {
|
||||||
app.setLocation("#/search/"+$('#search > div > input').val());
|
app.setLocation("#/search/"+$('#search > div > input').val());
|
||||||
$('#wait').modal('show');
|
$('#wait').modal('show');
|
||||||
@ -784,7 +811,7 @@ function dirble_load_categories() {
|
|||||||
|
|
||||||
dirble_page = 1;
|
dirble_page = 1;
|
||||||
|
|
||||||
$.getJSON( "http://api.dirble.com/v2/categories?token=2e223c9909593b94fc6577361a", function( data ) {
|
$.getJSON( "https://api.dirble.com/v2/categories?token=" + dirble_api_token, function( data ) {
|
||||||
|
|
||||||
$('#dirble_loading').addClass('hide');
|
$('#dirble_loading').addClass('hide');
|
||||||
|
|
||||||
@ -832,7 +859,7 @@ function dirble_load_categories() {
|
|||||||
|
|
||||||
function dirble_load_stations() {
|
function dirble_load_stations() {
|
||||||
|
|
||||||
$.getJSON( "http://api.dirble.com/v2/category/"+dirble_catid+"/stations?page="+dirble_page+"&per_page=20&token=2e223c9909593b94fc6577361a", function( data ) {
|
$.getJSON( "https://api.dirble.com/v2/category/"+dirble_catid+"/stations?page="+dirble_page+"&per_page=20&token=" + dirble_api_token, function( data ) {
|
||||||
|
|
||||||
$('#dirble_loading').addClass('hide');
|
$('#dirble_loading').addClass('hide');
|
||||||
if (data.length == 20) $('#next').removeClass('hide');
|
if (data.length == 20) $('#next').removeClass('hide');
|
||||||
@ -859,7 +886,7 @@ function dirble_load_stations() {
|
|||||||
click: function() {
|
click: function() {
|
||||||
var _this = $(this);
|
var _this = $(this);
|
||||||
|
|
||||||
$.getJSON( "http://api.dirble.com/v2/station/"+$(this).attr("radioid")+"?token=2e223c9909593b94fc6577361a", function( data ) {
|
$.getJSON( "https://api.dirble.com/v2/station/"+$(this).attr("radioid")+"?token=" + dirble_api_token, function( data ) {
|
||||||
|
|
||||||
socket.send("MPD_API_ADD_TRACK," + data.streams[0].stream);
|
socket.send("MPD_API_ADD_TRACK," + data.streams[0].stream);
|
||||||
$('.top-right').notify({
|
$('.top-right').notify({
|
||||||
@ -877,7 +904,7 @@ function dirble_load_stations() {
|
|||||||
"<span class=\"glyphicon glyphicon-play\"></span></a>").find('a').click(function(e) {
|
"<span class=\"glyphicon glyphicon-play\"></span></a>").find('a').click(function(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
$.getJSON( "http://api.dirble.com/v2/station/"+_this.attr("radioid")+"?token=2e223c9909593b94fc6577361a", function( data ) {
|
$.getJSON( "https://api.dirble.com/v2/station/"+_this.attr("radioid")+"?token=" + dirble_api_token, function( data ) {
|
||||||
|
|
||||||
socket.send("MPD_API_ADD_PLAY_TRACK," + data.streams[0].stream);
|
socket.send("MPD_API_ADD_PLAY_TRACK," + data.streams[0].stream);
|
||||||
$('.top-right').notify({
|
$('.top-right').notify({
|
||||||
@ -898,7 +925,7 @@ function dirble_load_stations() {
|
|||||||
click: function() {
|
click: function() {
|
||||||
var _this = $(this);
|
var _this = $(this);
|
||||||
|
|
||||||
$.getJSON( "http://api.dirble.com/v2/station/"+$(this).attr("radioid")+"?token=2e223c9909593b94fc6577361a", function( data ) {
|
$.getJSON( "https://api.dirble.com/v2/station/"+$(this).attr("radioid")+"?token=" + dirble_api_token, function( data ) {
|
||||||
|
|
||||||
socket.send("MPD_API_ADD_TRACK," + data.streams[0].stream);
|
socket.send("MPD_API_ADD_TRACK," + data.streams[0].stream);
|
||||||
$('.top-right').notify({
|
$('.top-right').notify({
|
||||||
@ -916,7 +943,7 @@ function dirble_load_stations() {
|
|||||||
"<span class=\"glyphicon glyphicon-play\"></span></a>").find('a').click(function(e) {
|
"<span class=\"glyphicon glyphicon-play\"></span></a>").find('a').click(function(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
$.getJSON( "http://api.dirble.com/v2/station/"+_this.attr("radioid")+"?token=2e223c9909593b94fc6577361a", function( data ) {
|
$.getJSON( "https://api.dirble.com/v2/station/"+_this.attr("radioid")+"?token=" + dirble_api_token, function( data ) {
|
||||||
|
|
||||||
socket.send("MPD_API_ADD_PLAY_TRACK," + data.streams[0].stream);
|
socket.send("MPD_API_ADD_PLAY_TRACK," + data.streams[0].stream);
|
||||||
$('.top-right').notify({
|
$('.top-right').notify({
|
||||||
|
@ -63,7 +63,8 @@ int callback_mpd(struct mg_connection *c)
|
|||||||
return MG_TRUE;
|
return MG_TRUE;
|
||||||
|
|
||||||
if(mpd.conn_state != MPD_CONNECTED && cmd_id != MPD_API_SET_MPDHOST &&
|
if(mpd.conn_state != MPD_CONNECTED && cmd_id != MPD_API_SET_MPDHOST &&
|
||||||
cmd_id != MPD_API_GET_MPDHOST && cmd_id != MPD_API_SET_MPDPASS)
|
cmd_id != MPD_API_GET_MPDHOST && cmd_id != MPD_API_SET_MPDPASS &&
|
||||||
|
cmd_id != MPD_API_GET_DIRBLEAPITOKEN)
|
||||||
return MG_TRUE;
|
return MG_TRUE;
|
||||||
|
|
||||||
switch(cmd_id)
|
switch(cmd_id)
|
||||||
@ -256,6 +257,10 @@ out_host_change:
|
|||||||
"{\"host\" : \"%s\", \"port\": \"%d\", \"passwort_set\": %s}"
|
"{\"host\" : \"%s\", \"port\": \"%d\", \"passwort_set\": %s}"
|
||||||
"}", mpd.host, mpd.port, mpd.password ? "true" : "false");
|
"}", mpd.host, mpd.port, mpd.password ? "true" : "false");
|
||||||
break;
|
break;
|
||||||
|
case MPD_API_GET_DIRBLEAPITOKEN:
|
||||||
|
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\":\"dirbleapitoken\", \""
|
||||||
|
"data\": \"%s\"}", dirble_api_token);
|
||||||
|
break;
|
||||||
case MPD_API_SET_MPDPASS:
|
case MPD_API_SET_MPDPASS:
|
||||||
p_charbuf = strdup(c->content);
|
p_charbuf = strdup(c->content);
|
||||||
if(strcmp(strtok(p_charbuf, ","), "MPD_API_SET_MPDPASS"))
|
if(strcmp(strtok(p_charbuf, ","), "MPD_API_SET_MPDPASS"))
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
X(MPD_API_GET_QUEUE) \
|
X(MPD_API_GET_QUEUE) \
|
||||||
X(MPD_API_GET_BROWSE) \
|
X(MPD_API_GET_BROWSE) \
|
||||||
X(MPD_API_GET_MPDHOST) \
|
X(MPD_API_GET_MPDHOST) \
|
||||||
|
X(MPD_API_GET_DIRBLEAPITOKEN) \
|
||||||
X(MPD_API_ADD_TRACK) \
|
X(MPD_API_ADD_TRACK) \
|
||||||
X(MPD_API_ADD_PLAY_TRACK) \
|
X(MPD_API_ADD_PLAY_TRACK) \
|
||||||
X(MPD_API_ADD_PLAYLIST) \
|
X(MPD_API_ADD_PLAYLIST) \
|
||||||
@ -94,6 +95,8 @@ struct t_mpd {
|
|||||||
unsigned queue_version;
|
unsigned queue_version;
|
||||||
} mpd;
|
} mpd;
|
||||||
|
|
||||||
|
char dirble_api_token[28];
|
||||||
|
|
||||||
struct t_mpd_client_session {
|
struct t_mpd_client_session {
|
||||||
int song_id;
|
int song_id;
|
||||||
unsigned queue_version;
|
unsigned queue_version;
|
||||||
|
@ -80,10 +80,13 @@ int main(int argc, char **argv)
|
|||||||
mpd.port = 6600;
|
mpd.port = 6600;
|
||||||
strcpy(mpd.host, "127.0.0.1");
|
strcpy(mpd.host, "127.0.0.1");
|
||||||
|
|
||||||
|
strcpy(dirble_api_token, "2e223c9909593b94fc6577361a");
|
||||||
|
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{"host", required_argument, 0, 'h'},
|
{"host", required_argument, 0, 'h'},
|
||||||
{"port", required_argument, 0, 'p'},
|
{"port", required_argument, 0, 'p'},
|
||||||
{"webport", required_argument, 0, 'w'},
|
{"webport", required_argument, 0, 'w'},
|
||||||
|
{"dirbletoken", required_argument, 0, 'd'},
|
||||||
{"user", required_argument, 0, 'u'},
|
{"user", required_argument, 0, 'u'},
|
||||||
{"version", no_argument, 0, 'v'},
|
{"version", no_argument, 0, 'v'},
|
||||||
{"help", no_argument, 0, 0 },
|
{"help", no_argument, 0, 0 },
|
||||||
@ -102,6 +105,9 @@ int main(int argc, char **argv)
|
|||||||
case 'w':
|
case 'w':
|
||||||
webport = strdup(optarg);
|
webport = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'd':
|
||||||
|
strncpy(dirble_api_token, optarg, sizeof(dirble_api_token));
|
||||||
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
run_as_user = strdup(optarg);
|
run_as_user = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
@ -118,6 +124,7 @@ int main(int argc, char **argv)
|
|||||||
" -p, --port <port>\t\tconnect to mpd at port [6600]\n"
|
" -p, --port <port>\t\tconnect to mpd at port [6600]\n"
|
||||||
" -w, --webport [ip:]<port>\tlisten interface/port for webserver [8080]\n"
|
" -w, --webport [ip:]<port>\tlisten interface/port for webserver [8080]\n"
|
||||||
" -u, --user <username>\t\tdrop priviliges to user after socket bind\n"
|
" -u, --user <username>\t\tdrop priviliges to user after socket bind\n"
|
||||||
|
" -d, --dirbletoken <apitoken>\tDirble API token\n"
|
||||||
" -V, --version\t\t\tget version\n"
|
" -V, --version\t\t\tget version\n"
|
||||||
" --help\t\t\t\tthis help\n"
|
" --help\t\t\t\tthis help\n"
|
||||||
, argv[0]);
|
, argv[0]);
|
||||||
|
Loading…
Reference in New Issue
Block a user