mirror of
https://github.com/SuperBFG7/ympd
synced 2024-11-23 13:27:18 +00:00
Merge pull request #12 from notandy/master
Merge recent commits to notandy/ympd master
This commit is contained in:
commit
3dac7ce3dc
@ -1,7 +1,7 @@
|
||||
language: c
|
||||
|
||||
sudo: required
|
||||
dist: precise
|
||||
dist: trusty
|
||||
|
||||
compiler:
|
||||
- gcc
|
||||
|
@ -24,8 +24,8 @@ include_directories(${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR} ${LIBMPDCLIENT_I
|
||||
|
||||
include(CheckCSourceCompiles)
|
||||
|
||||
set(CMAKE_C_FLAGS "-std=gnu99 -Wall")
|
||||
set(CMAKE_C_FLAGS_DEBUG "-ggdb -pedantic")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb -pedantic")
|
||||
if(WITH_IPV6)
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS NS_ENABLE_IPV6)
|
||||
endif()
|
||||
|
13
Dockerfile
Normal file
13
Dockerfile
Normal file
@ -0,0 +1,13 @@
|
||||
FROM alpine:3.5
|
||||
WORKDIR /app/build
|
||||
COPY . /app
|
||||
RUN apk add --no-cache g++ make cmake libmpdclient-dev openssl-dev
|
||||
RUN cmake ..
|
||||
RUN make
|
||||
|
||||
FROM alpine:3.5
|
||||
RUN apk add --no-cache libmpdclient openssl
|
||||
EXPOSE 8080
|
||||
COPY --from=0 /app/build/ympd /usr/bin/ympd
|
||||
COPY --from=0 /app/build/mkdata /usr/bin/mkdata
|
||||
CMD ympd
|
@ -13,11 +13,12 @@ Dependencies
|
||||
------------
|
||||
- libmpdclient 2: http://www.musicpd.org/libs/libmpdclient/
|
||||
- cmake 2.6: http://cmake.org/
|
||||
- OpenSSL: https://www.openssl.org/
|
||||
|
||||
Unix Build Instructions
|
||||
-----------------------
|
||||
|
||||
1. install dependencies, cmake and libmpdclient are available from all major distributions.
|
||||
1. install dependencies. cmake, libmpdclient (dev), and OpenSSL (dev) are available from all major distributions.
|
||||
2. create build directory ```cd /path/to/src; mkdir build; cd build```
|
||||
3. create makefile ```cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/usr```
|
||||
4. build ```make```
|
||||
@ -31,6 +32,7 @@ Usage: ./ympd [OPTION]...
|
||||
-h, --host <host> connect to mpd at host [localhost]
|
||||
-p, --port <port> connect to mpd at port [6600]
|
||||
-w, --webport [ip:]<port> listen interface/port for webserver [8080]
|
||||
-d, --dirbletoken <apitoken> Dirble API token
|
||||
-u, --user <username> drop priviliges to user after socket bind
|
||||
-V, --version get version
|
||||
--help this help
|
||||
|
@ -24,6 +24,7 @@ YMPD_USER=nobody
|
||||
MPD_HOST=localhost
|
||||
MPD_PORT=6600
|
||||
WEB_PORT=8080
|
||||
DIRBLE_API_TOKEN=2e223c9909593b94fc6577361a
|
||||
|
||||
|
||||
# Exit if the package is not installed
|
||||
@ -35,7 +36,7 @@ WEB_PORT=8080
|
||||
# Load the VERBOSE setting and other rcS variables
|
||||
[ -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 --mpdpass '$MPD_PASSWORD' --webport $WEB_PORT --host $MPD_HOST --port $MPD_PORT --dirbletoken $DIRBLE_API_TOKEN"
|
||||
|
||||
do_start()
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
MPD_HOST=localhost
|
||||
MPD_PORT=6600
|
||||
MPD_PASSWORD=
|
||||
WEB_PORT=8080
|
||||
YMPD_USER=nobody
|
||||
DIRBLE_API_TOKEN=2e223c9909593b94fc6577361a
|
||||
|
29
contrib/ympd.freebsd
Executable file
29
contrib/ympd.freebsd
Executable file
@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
|
||||
# PROVIDE: ympd
|
||||
# REQUIRE: DAEMON musicpd
|
||||
# KEYWORD: shutdown
|
||||
|
||||
# Add the following line to /etc/rc.conf to enable ympd:
|
||||
#
|
||||
# ympd_enable="YES"
|
||||
|
||||
. /etc/rc.subr
|
||||
|
||||
name="ympd"
|
||||
rcvar="${name}_enable"
|
||||
command="/usr/local/bin/ympd"
|
||||
pidfile="/var/run/${name}.pid"
|
||||
start_cmd="ympd_start"
|
||||
|
||||
load_rc_config "$name"
|
||||
: ${ympd_enable:="NO"}
|
||||
: ${ympd_user:="nobody"}
|
||||
|
||||
ympd_start()
|
||||
{
|
||||
check_startmsgs && echo "Starting ${name}."
|
||||
/usr/sbin/daemon -f -p "${pidfile}" -t "${name}" -u "${ympd_user}" "${command}"
|
||||
}
|
||||
|
||||
run_rc_command "$1"
|
@ -5,10 +5,12 @@ Requires=network.target local-fs.target
|
||||
[Service]
|
||||
Environment=MPD_HOST=localhost
|
||||
Environment=MPD_PORT=6600
|
||||
Environment=MPD_PASSWORD=
|
||||
Environment=WEB_PORT=8080
|
||||
Environment=YMPD_USER=nobody
|
||||
Environment=DIRBLE_API_TOKEN=2e223c9909593b94fc6577361a
|
||||
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 --mpdpass "$MPD_PASSWORD" --webport $WEB_PORT --host $MPD_HOST --port $MPD_PORT --dirbletoken $DIRBLE_API_TOKE
|
||||
Type=simple
|
||||
|
||||
[Install]
|
||||
|
@ -55,6 +55,11 @@
|
||||
<span class="glyphicon glyphicon-forward"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button id="btnlove" type="button" class="btn btn-default" onclick="clickLove();">
|
||||
<span class="glyphicon glyphicon-heart"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<div class="btn btn-toolbar btn-default">
|
||||
<span id="volume-icon" class="glyphicon glyphicon-volume-up"></span>
|
||||
@ -99,7 +104,7 @@
|
||||
<ol id="breadcrump" class="breadcrumb">
|
||||
</ol>
|
||||
|
||||
<div class="col-md-12">
|
||||
<div class="col-md-12" id="filter">
|
||||
<button id="add-all-songs" class="btn btn-primary pull-right">Add all</button>
|
||||
</div>
|
||||
|
||||
@ -169,6 +174,21 @@
|
||||
<div id="btn-outputs-block" class="btn-group-vertical btn-block btn-group-lg">
|
||||
</div>
|
||||
|
||||
<div id="trashmode" class="btn-group-vertical btn-block btn-group-lg" data-toggle="radio">
|
||||
<button id="btntrashmodeup" type="button" class="btn btn-default">
|
||||
<span class="glyphicon glyphicon-chevron-up"></span>
|
||||
<span class="glyphicon glyphicon-trash"></span> up
|
||||
</button>
|
||||
<button id="btntrashmodesingle" type="button" class="btn btn-default active">
|
||||
<span class="glyphicon glyphicon-star-empty"></span>
|
||||
<span class="glyphicon glyphicon-trash"></span> single
|
||||
</button>
|
||||
<button id="btntrashmodedown" type="button" class="btn btn-default">
|
||||
<span class="glyphicon glyphicon-chevron-down"></span>
|
||||
<span class="glyphicon glyphicon-trash"></span> down
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div id="btn-responsive-block" class="btn-group-vertical btn-block btn-group-lg">
|
||||
<button type="button" class="btn btn-default" onclick="socket.send('MPD_API_RM_ALL');">
|
||||
<span class="glyphicon glyphicon-trash"></span> Clear queue
|
||||
@ -329,6 +349,7 @@
|
||||
<script src="js/bootstrap-notify.js"></script>
|
||||
<script src="js/bootstrap-slider.js"></script>
|
||||
<script src="js/sammy.js"></script>
|
||||
<script src="js/jquery-ui-sortable.min.js"></script>
|
||||
<script src="js/mpd.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
5
htdocs/js/jquery-ui-sortable.min.js
vendored
Normal file
5
htdocs/js/jquery-ui-sortable.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
206
htdocs/js/mpd.js
206
htdocs/js/mpd.js
@ -1,6 +1,6 @@
|
||||
/* ympd
|
||||
(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
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -29,6 +29,9 @@ var dirble_selected_cat = "";
|
||||
var dirble_catid = "";
|
||||
var dirble_page = 1;
|
||||
var isTouch = Modernizr.touch ? 1 : 0;
|
||||
var filter = undefined;
|
||||
var dirble_api_token = "";
|
||||
var dirble_stations = false;
|
||||
|
||||
var app = $.sammy(function() {
|
||||
|
||||
@ -36,6 +39,7 @@ var app = $.sammy(function() {
|
||||
current_app = 'queue';
|
||||
|
||||
$('#breadcrump').addClass('hide');
|
||||
$('#filter').addClass('hide');
|
||||
$('#salamisandwich').removeClass('hide').find("tr:gt(0)").remove();
|
||||
$('#dirble_panel').addClass('hide');
|
||||
socket.send('MPD_API_GET_QUEUE,'+pagination);
|
||||
@ -63,7 +67,8 @@ var app = $.sammy(function() {
|
||||
browsepath = this.params['splat'][1];
|
||||
pagination = parseInt(this.params['splat'][0]);
|
||||
current_app = 'browse';
|
||||
$('#breadcrump').removeClass('hide').empty().append("<li><a href=\"#/browse/0/\">root</a></li>");
|
||||
$('#breadcrump').removeClass('hide').empty().append("<li><a href=\"#/browse/0/\" onclick=\"set_filter()\">root</a></li>");
|
||||
$('#filter').removeClass('hide');
|
||||
$('#salamisandwich').removeClass('hide').find("tr:gt(0)").remove();
|
||||
$('#dirble_panel').addClass('hide');
|
||||
socket.send('MPD_API_GET_BROWSE,'+pagination+','+(browsepath ? browsepath : "/"));
|
||||
@ -127,7 +132,13 @@ var app = $.sammy(function() {
|
||||
dirble_catid = this.params['splat'][0];
|
||||
dirble_page = this.params['splat'][1];
|
||||
|
||||
dirble_stations = true;
|
||||
|
||||
if(dirble_api_token) {
|
||||
dirble_load_stations();
|
||||
} else {
|
||||
getDirbleApiToken();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -144,7 +155,13 @@ var app = $.sammy(function() {
|
||||
$('#panel-heading').text("Dirble");
|
||||
$('#dirble').addClass('active');
|
||||
|
||||
dirble_stations = false;
|
||||
|
||||
if(dirble_api_token) {
|
||||
dirble_load_categories();
|
||||
} else {
|
||||
getDirbleApiToken();
|
||||
}
|
||||
});
|
||||
|
||||
this.get("/", function(context) {
|
||||
@ -178,6 +195,8 @@ $(document).ready(function(){
|
||||
else
|
||||
if ($.cookie("notification") === "true")
|
||||
$('#btnnotify').addClass("active")
|
||||
|
||||
add_filter();
|
||||
});
|
||||
|
||||
|
||||
@ -224,27 +243,39 @@ function webSocketConnect() {
|
||||
"</td><td></td></tr>");
|
||||
}
|
||||
|
||||
if(obj.data[obj.data.length-1].pos + 1 >= pagination + MAX_ELEMENTS_PER_PAGE)
|
||||
if(obj.data.length && obj.data[obj.data.length-1].pos + 1 >= pagination + MAX_ELEMENTS_PER_PAGE)
|
||||
$('#next').removeClass('hide');
|
||||
if(pagination > 0)
|
||||
$('#prev').removeClass('hide');
|
||||
if ( isTouch ) {
|
||||
$('#salamisandwich > tbody > tr > td:last-child').append(
|
||||
"<a class=\"pull-right btn-group-hover\" href=\"#/\" " +
|
||||
"onclick=\"socket.send('MPD_API_RM_TRACK,' + $(this).parents('tr').attr('trackid')); $(this).parents('tr').remove();\">" +
|
||||
"onclick=\"trash($(this).parents('tr'));\">" +
|
||||
"<span class=\"glyphicon glyphicon-trash\"></span></a>");
|
||||
} else {
|
||||
$('#salamisandwich > tbody > tr').on({
|
||||
mouseover: function(){
|
||||
var doomed = $(this);
|
||||
if ( $('#btntrashmodeup').hasClass('active') )
|
||||
doomed = $("#salamisandwich > tbody > tr:lt(" + ($(this).index() + 1) + ")");
|
||||
if ( $('#btntrashmodedown').hasClass('active') )
|
||||
doomed = $("#salamisandwich > tbody > tr:gt(" + ($(this).index() - 1) + ")");
|
||||
$.each(doomed, function(){
|
||||
if($(this).children().last().has("a").length == 0)
|
||||
$(this).children().last().append(
|
||||
"<a class=\"pull-right btn-group-hover\" href=\"#/\" " +
|
||||
"onclick=\"socket.send('MPD_API_RM_TRACK," + $(this).attr("trackid") +"'); $(this).parents('tr').remove();\">" +
|
||||
"onclick=\"trash($(this).parents('tr'));\">" +
|
||||
"<span class=\"glyphicon glyphicon-trash\"></span></a>")
|
||||
.find('a').fadeTo('fast',1);
|
||||
});
|
||||
},
|
||||
mouseleave: function(){
|
||||
$(this).children().last().find("a").stop().remove();
|
||||
var doomed = $(this);
|
||||
if ( $('#btntrashmodeup').hasClass('active') )
|
||||
doomed = $("#salamisandwich > tbody > tr:lt(" + ($(this).index() + 1) + ")");
|
||||
if ( $('#btntrashmodedown').hasClass('active') )
|
||||
doomed = $("#salamisandwich > tbody > tr:gt(" + ($(this).index() - 1) + ")");
|
||||
$.each(doomed, function(){$(this).children().last().find("a").stop().remove();});
|
||||
}
|
||||
});
|
||||
};
|
||||
@ -256,6 +287,22 @@ function webSocketConnect() {
|
||||
$(this).addClass('active');
|
||||
},
|
||||
});
|
||||
//Helper function to keep table row from collapsing when being sorted
|
||||
var fixHelperModified = function(e, tr) {
|
||||
var $originals = tr.children();
|
||||
var $helper = tr.clone();
|
||||
$helper.children().each(function(index)
|
||||
{
|
||||
$(this).width($originals.eq(index).width())
|
||||
});
|
||||
return $helper;
|
||||
};
|
||||
|
||||
//Make queue table sortable
|
||||
$("#salamisandwich > tbody").sortable({
|
||||
helper: fixHelperModified,
|
||||
stop: function(event,ui) {renumber_table('#salamisandwich',ui.item)}
|
||||
}).disableSelection();
|
||||
break;
|
||||
case "search":
|
||||
$('#wait').modal('hide');
|
||||
@ -267,19 +314,37 @@ function webSocketConnect() {
|
||||
* some browsers, such as Safari, from changing the normalization form of the
|
||||
* URI from NFD to NFC, breaking our link with MPD.
|
||||
*/
|
||||
if ($('#salamisandwich > tbody').is(':ui-sortable')) {
|
||||
$('#salamisandwich > tbody').sortable('destroy');
|
||||
}
|
||||
for (var item in obj.data) {
|
||||
switch(obj.data[item].type) {
|
||||
case "directory":
|
||||
var clazz = 'dir';
|
||||
if (filter !== undefined) {
|
||||
var first = obj.data[item].dir[0];
|
||||
if (filter === "#" && isNaN(first)) {
|
||||
clazz += ' hide';
|
||||
} else if (filter >= "A" && filter <= "Z" && first.toUpperCase() !== filter) {
|
||||
clazz += ' hide';
|
||||
} else if (filter === "||") {
|
||||
clazz += ' hide';
|
||||
}
|
||||
}
|
||||
$('#salamisandwich > tbody').append(
|
||||
"<tr uri=\"" + encodeURI(obj.data[item].dir) + "\" class=\"dir\">" +
|
||||
"<tr uri=\"" + encodeURI(obj.data[item].dir) + "\" class=\"" + clazz + "\">" +
|
||||
"<td><span class=\"glyphicon glyphicon-folder-open\"></span></td>" +
|
||||
"<td><a>" + basename(obj.data[item].dir) + "</a></td>" +
|
||||
"<td></td><td></td></tr>"
|
||||
);
|
||||
break;
|
||||
case "playlist":
|
||||
var clazz = 'plist';
|
||||
if (filter !== "||") {
|
||||
clazz += ' hide';
|
||||
}
|
||||
$('#salamisandwich > tbody').append(
|
||||
"<tr uri=\"" + encodeURI(obj.data[item].plist) + "\" class=\"plist\">" +
|
||||
"<tr uri=\"" + encodeURI(obj.data[item].plist) + "\" class=\"" + clazz + "\">" +
|
||||
"<td><span class=\"glyphicon glyphicon-list\"></span></td>" +
|
||||
"<td><a>" + basename(obj.data[item].plist) + "</a></td>" +
|
||||
"<td></td><td></td></tr>"
|
||||
@ -466,6 +531,8 @@ function webSocketConnect() {
|
||||
$('#album').text("");
|
||||
$('#artist').text("");
|
||||
|
||||
$('#btnlove').removeClass("active");
|
||||
|
||||
$('#currenttrack').text(" " + obj.data.title);
|
||||
var notification = "<strong><h4>" + obj.data.title + "</h4></strong>";
|
||||
|
||||
@ -493,6 +560,15 @@ function webSocketConnect() {
|
||||
if(obj.data.passwort_set)
|
||||
$('#mpd_password_set').removeClass('hide');
|
||||
break;
|
||||
case "dirbleapitoken":
|
||||
dirble_api_token = obj.data;
|
||||
|
||||
if(dirble_stations) {
|
||||
dirble_load_stations();
|
||||
} else {
|
||||
dirble_load_categories();
|
||||
}
|
||||
break;
|
||||
case "error":
|
||||
$('.top-right').notify({
|
||||
message:{text: obj.data},
|
||||
@ -525,6 +601,7 @@ function get_appropriate_ws_url()
|
||||
{
|
||||
var pcol;
|
||||
var u = document.URL;
|
||||
var separator;
|
||||
|
||||
/*
|
||||
/* We open the websocket encrypted if this page came on an
|
||||
@ -542,7 +619,13 @@ function get_appropriate_ws_url()
|
||||
|
||||
u = u.split('#');
|
||||
|
||||
return pcol + u[0] + "/ws";
|
||||
if (/\/$/.test(u[0])) {
|
||||
separator = "";
|
||||
} else {
|
||||
separator = "/";
|
||||
}
|
||||
|
||||
return pcol + u[0] + separator + "ws";
|
||||
}
|
||||
|
||||
var updateVolumeIcon = function(volume)
|
||||
@ -594,10 +677,41 @@ function clickPlay() {
|
||||
socket.send('MPD_API_SET_PAUSE');
|
||||
}
|
||||
|
||||
function trash(tr) {
|
||||
if ( $('#btntrashmodeup').hasClass('active') ) {
|
||||
socket.send('MPD_API_RM_RANGE,0,' + (tr.index() + 1));
|
||||
tr.remove();
|
||||
} else if ( $('#btntrashmodesingle').hasClass('active') ) {
|
||||
socket.send('MPD_API_RM_TRACK,' + tr.attr('trackid'));
|
||||
tr.remove();
|
||||
} else if ( $('#btntrashmodedown').hasClass('active') ) {
|
||||
socket.send('MPD_API_RM_RANGE,' + tr.index() + ',-1');
|
||||
tr.remove();
|
||||
};
|
||||
}
|
||||
|
||||
function renumber_table(tableID,item) {
|
||||
was = item.children("td").first().text();//Check if first item exists!
|
||||
is = item.index() + 1;//maybe add pagination
|
||||
|
||||
if (was != is) {
|
||||
socket.send("MPD_API_MOVE_TRACK," + was + "," + is);
|
||||
socket.send('MPD_API_GET_QUEUE,'+pagination);
|
||||
}
|
||||
}
|
||||
|
||||
function basename(path) {
|
||||
return path.split('/').reverse()[0];
|
||||
}
|
||||
|
||||
function clickLove() {
|
||||
socket.send("MPD_API_SEND_MESSAGE,mpdas," + ($('#btnlove').hasClass('active') ? "unlove" : "love"));
|
||||
if ( $('#btnlove').hasClass('active') )
|
||||
$('#btnlove').removeClass("active");
|
||||
else
|
||||
$('#btnlove').addClass("active");
|
||||
}
|
||||
|
||||
$('#btnrandom').on('click', function (e) {
|
||||
socket.send("MPD_API_TOGGLE_RANDOM," + ($(this).hasClass('active') ? 0 : 1));
|
||||
|
||||
@ -620,6 +734,11 @@ function toggleoutput(button, id) {
|
||||
socket.send("MPD_API_TOGGLE_OUTPUT,"+id+"," + ($(button).hasClass('active') ? 0 : 1));
|
||||
}
|
||||
|
||||
$('#trashmode').children("button").on('click', function(e) {
|
||||
$('#trashmode').children("button").removeClass("active");
|
||||
$(this).addClass("active");
|
||||
});
|
||||
|
||||
$('#btnnotify').on('click', function (e) {
|
||||
if($.cookie("notification") === "true") {
|
||||
$.cookie("notification", false);
|
||||
@ -652,6 +771,10 @@ function getHost() {
|
||||
$('#mpd_pw_con').keypress(onEnter);
|
||||
}
|
||||
|
||||
function getDirbleApiToken() {
|
||||
socket.send('MPD_API_GET_DIRBLEAPITOKEN');
|
||||
}
|
||||
|
||||
$('#search').submit(function () {
|
||||
app.setLocation("#/search/"+$('#search > div > input').val());
|
||||
$('#wait').modal('show');
|
||||
@ -784,7 +907,7 @@ function dirble_load_categories() {
|
||||
|
||||
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');
|
||||
|
||||
@ -832,7 +955,7 @@ function dirble_load_categories() {
|
||||
|
||||
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');
|
||||
if (data.length == 20) $('#next').removeClass('hide');
|
||||
@ -859,7 +982,7 @@ function dirble_load_stations() {
|
||||
click: function() {
|
||||
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);
|
||||
$('.top-right').notify({
|
||||
@ -877,7 +1000,7 @@ function dirble_load_stations() {
|
||||
"<span class=\"glyphicon glyphicon-play\"></span></a>").find('a').click(function(e) {
|
||||
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);
|
||||
$('.top-right').notify({
|
||||
@ -898,7 +1021,7 @@ function dirble_load_stations() {
|
||||
click: function() {
|
||||
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);
|
||||
$('.top-right').notify({
|
||||
@ -916,7 +1039,7 @@ function dirble_load_stations() {
|
||||
"<span class=\"glyphicon glyphicon-play\"></span></a>").find('a').click(function(e) {
|
||||
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);
|
||||
$('.top-right').notify({
|
||||
@ -934,3 +1057,56 @@ function dirble_load_stations() {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function set_filter (c) {
|
||||
filter = c;
|
||||
|
||||
$.each($('#salamisandwich > tbody > tr.dir'), function(i, line) {
|
||||
var first = $(line).attr('uri')[0];
|
||||
|
||||
if (filter === undefined) {
|
||||
$(line).removeClass('hide');
|
||||
}
|
||||
|
||||
else if (filter === "#") {
|
||||
if (!isNaN(first)) {
|
||||
$(line).removeClass('hide');
|
||||
} else {
|
||||
$(line).addClass('hide');
|
||||
}
|
||||
}
|
||||
|
||||
else if (filter >= "A" && filter <= "Z") {
|
||||
if (first.toUpperCase() === filter) {
|
||||
$(line).removeClass('hide');
|
||||
} else {
|
||||
$(line).addClass('hide');
|
||||
}
|
||||
}
|
||||
|
||||
else if (filter === "||") {
|
||||
$(line).addClass('hide');
|
||||
}
|
||||
});
|
||||
|
||||
$.each($('#salamisandwich > tbody > tr.plist'), function(i, line) {
|
||||
if (filter === undefined) {
|
||||
$(line).removeClass('hide');
|
||||
} else if (filter === "||") {
|
||||
$(line).removeClass('hide');
|
||||
} else {
|
||||
$(line).addClass('hide');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function add_filter () {
|
||||
$('#filter').append(' <a onclick="set_filter(\'#\')" href="#/browse/0/">#</a>');
|
||||
|
||||
for (i = 65; i <= 90; i++) {
|
||||
var c = String.fromCharCode(i);
|
||||
$('#filter').append(' <a onclick="set_filter(\'' + c + '\')" href="#/browse/0/">' + c + '</a>');
|
||||
}
|
||||
|
||||
$('#filter').append(' <a onclick="set_filter(\'||\')" href="#/browse/0/" class="glyphicon glyphicon-list"></a>');
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <libgen.h>
|
||||
#include <mpd/client.h>
|
||||
#include <mpd/message.h>
|
||||
|
||||
#include "mpd_client.h"
|
||||
#include "config.h"
|
||||
@ -63,7 +64,8 @@ int callback_mpd(struct mg_connection *c)
|
||||
return MG_TRUE;
|
||||
|
||||
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;
|
||||
|
||||
switch(cmd_id)
|
||||
@ -93,6 +95,18 @@ int callback_mpd(struct mg_connection *c)
|
||||
if(sscanf(c->content, "MPD_API_RM_TRACK,%u", &uint_buf))
|
||||
mpd_run_delete_id(mpd.conn, uint_buf);
|
||||
break;
|
||||
case MPD_API_RM_RANGE:
|
||||
if(sscanf(c->content, "MPD_API_RM_RANGE,%u,%u", &uint_buf, &uint_buf_2))
|
||||
mpd_run_delete_range(mpd.conn, uint_buf, uint_buf_2);
|
||||
break;
|
||||
case MPD_API_MOVE_TRACK:
|
||||
if (sscanf(c->content, "MPD_API_MOVE_TRACK,%u,%u", &uint_buf, &uint_buf_2) == 2)
|
||||
{
|
||||
uint_buf -= 1;
|
||||
uint_buf_2 -= 1;
|
||||
mpd_run_move(mpd.conn, uint_buf, uint_buf_2);
|
||||
}
|
||||
break;
|
||||
case MPD_API_PLAY_TRACK:
|
||||
if(sscanf(c->content, "MPD_API_PLAY_TRACK,%u", &uint_buf))
|
||||
mpd_run_play_id(mpd.conn, uint_buf);
|
||||
@ -229,6 +243,27 @@ out_save_queue:
|
||||
out_search:
|
||||
free(p_charbuf);
|
||||
break;
|
||||
case MPD_API_SEND_MESSAGE:
|
||||
p_charbuf = strdup(c->content);
|
||||
if(strcmp(strtok(p_charbuf, ","), "MPD_API_SEND_MESSAGE"))
|
||||
goto out_send_message;
|
||||
|
||||
if((token = strtok(NULL, ",")) == NULL)
|
||||
goto out_send_message;
|
||||
|
||||
free(p_charbuf);
|
||||
p_charbuf = strdup(get_arg1(c->content));
|
||||
|
||||
if ( strtok(p_charbuf, ",") == NULL )
|
||||
goto out_send_message;
|
||||
|
||||
if ( (token = strtok(NULL, ",")) == NULL )
|
||||
goto out_send_message;
|
||||
|
||||
mpd_run_send_message(mpd.conn, p_charbuf, token);
|
||||
out_send_message:
|
||||
free(p_charbuf);
|
||||
break;
|
||||
#ifdef WITH_MPD_HOST_CHANGE
|
||||
/* Commands allowed when disconnected from MPD server */
|
||||
case MPD_API_SET_MPDHOST:
|
||||
@ -256,6 +291,10 @@ out_host_change:
|
||||
"{\"host\" : \"%s\", \"port\": \"%d\", \"passwort_set\": %s}"
|
||||
"}", mpd.host, mpd.port, mpd.password ? "true" : "false");
|
||||
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:
|
||||
p_charbuf = strdup(c->content);
|
||||
if(strcmp(strtok(p_charbuf, ","), "MPD_API_SET_MPDPASS"))
|
||||
|
@ -40,14 +40,18 @@
|
||||
X(MPD_API_GET_QUEUE) \
|
||||
X(MPD_API_GET_BROWSE) \
|
||||
X(MPD_API_GET_MPDHOST) \
|
||||
X(MPD_API_GET_DIRBLEAPITOKEN) \
|
||||
X(MPD_API_ADD_TRACK) \
|
||||
X(MPD_API_ADD_PLAY_TRACK) \
|
||||
X(MPD_API_ADD_PLAYLIST) \
|
||||
X(MPD_API_PLAY_TRACK) \
|
||||
X(MPD_API_SAVE_QUEUE) \
|
||||
X(MPD_API_RM_TRACK) \
|
||||
X(MPD_API_RM_RANGE) \
|
||||
X(MPD_API_RM_ALL) \
|
||||
X(MPD_API_MOVE_TRACK) \
|
||||
X(MPD_API_SEARCH) \
|
||||
X(MPD_API_SEND_MESSAGE) \
|
||||
X(MPD_API_SET_VOLUME) \
|
||||
X(MPD_API_SET_PAUSE) \
|
||||
X(MPD_API_SET_PLAY) \
|
||||
@ -94,6 +98,8 @@ struct t_mpd {
|
||||
unsigned queue_version;
|
||||
} mpd;
|
||||
|
||||
char dirble_api_token[28];
|
||||
|
||||
struct t_mpd_client_session {
|
||||
int song_id;
|
||||
unsigned queue_version;
|
||||
|
14
src/ympd.c
14
src/ympd.c
@ -80,17 +80,21 @@ int main(int argc, char **argv)
|
||||
mpd.port = 6600;
|
||||
strcpy(mpd.host, "127.0.0.1");
|
||||
|
||||
strcpy(dirble_api_token, "2e223c9909593b94fc6577361a");
|
||||
|
||||
static struct option long_options[] = {
|
||||
{"host", required_argument, 0, 'h'},
|
||||
{"port", required_argument, 0, 'p'},
|
||||
{"webport", required_argument, 0, 'w'},
|
||||
{"dirbletoken", required_argument, 0, 'd'},
|
||||
{"user", required_argument, 0, 'u'},
|
||||
{"version", no_argument, 0, 'v'},
|
||||
{"help", no_argument, 0, 0 },
|
||||
{"mpdpass", required_argument, 0, 'm'},
|
||||
{0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
while((n = getopt_long(argc, argv, "h:p:w:u:v",
|
||||
while((n = getopt_long(argc, argv, "h:p:w:u:vm:",
|
||||
long_options, &option_index)) != -1) {
|
||||
switch (n) {
|
||||
case 'h':
|
||||
@ -102,9 +106,15 @@ int main(int argc, char **argv)
|
||||
case 'w':
|
||||
webport = strdup(optarg);
|
||||
break;
|
||||
case 'd':
|
||||
strncpy(dirble_api_token, optarg, sizeof(dirble_api_token));
|
||||
break;
|
||||
case 'u':
|
||||
run_as_user = strdup(optarg);
|
||||
break;
|
||||
case 'm':
|
||||
mpd.password = strdup(optarg);
|
||||
break;
|
||||
case 'v':
|
||||
fprintf(stdout, "ympd %d.%d.%d\n"
|
||||
"Copyright (C) 2014 Andrew Karpow <andy@ndyk.de>\n"
|
||||
@ -118,7 +128,9 @@ int main(int argc, char **argv)
|
||||
" -p, --port <port>\t\tconnect to mpd at port [6600]\n"
|
||||
" -w, --webport [ip:]<port>\tlisten interface/port for webserver [8080]\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"
|
||||
" -m, --mpdpass <password>\tspecifies the password to use when connecting to mpd\n"
|
||||
" --help\t\t\t\tthis help\n"
|
||||
, argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
|
3
ympd.1
3
ympd.1
@ -23,6 +23,9 @@ specifies the port for the webserver to listen to, defaults to 8080
|
||||
\fB\-u\fR, \fB\-\-user username\fR
|
||||
drop privileges to the provided username after socket binding
|
||||
.TP
|
||||
\fB\-m\fR, \fB\-\-mpdpass password\fR
|
||||
specifies the password to use when connecting to mpd
|
||||
.TP
|
||||
\fB\-V\fR, \fB\-\-version\fR
|
||||
print version and exit
|
||||
.TP
|
||||
|
Loading…
Reference in New Issue
Block a user