LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 04-18-2014, 04:33 PM   #1
epimenidecretese
LQ Newbie
 
Registered: Dec 2013
Distribution: Slackware
Posts: 20

Rep: Reputation: 0
mpc as player for gPodder


Hi dear All,

I started using gPodder on my slackware and I like it very much. I have an old laptop and for this reason I like to use as less resources as possible. For this reason I would like to use mpc/mpd as player for my podcast.

Problem is: how to properly write down the command? Now, in gPodder configurations I have "gmplayer %F". But how could I do the same thing with mpc/mpd? (BTW, I already have mpc and mpd installed and they work perfectly. I just don't know how to play from gPodder).
 
Old 04-19-2014, 09:18 PM   #2
the dsc
Member
 
Registered: May 2009
Distribution: Debian
Posts: 175
Blog Entries: 243

Rep: Reputation: 47
Mpd/mpc can be quite a bit annoying to configure.

As far as I know, you need to have all the audio/media (it will play the audio of some video formats) in a given folder (or symlink into that folder), and the "database" has to be up-to-date. It does update automatically periodically according to some settings probably.

Once you have this set up, the "standard", built-in way to command a certain song to play is "mpc tracknumber". And the problem is that unless you're like Rain Man, you have no way to tell beforehand.

As far as I know this is the only way, so, for similar reasons, I've made a humongous script that makes things somewhat easy, I'll type "mpcr keywords from the file name" (parhaps it "greps" from the tag, I don't remember).

It basically does a "mpc listall" with a format that I've set to more handily grep and "trim", so that I get the track number.


Here it is:

Code:
for i in $* ; do # search term parsing loop

a="$a grep -i $i |" # makes a chain of greps from the search terms 

done

a="mpc playlist -f \"[(@(%position%)@) %artist% %title% %file%]\" | $a" # add a start to the grep chain

mpc play `shuf -e $(eval $(echo $a| sed 's/.\{2\}$//') | sed 's:)@).*::g' | sed 's:(@(::g') -n 1 `
I don't know why I did it that way anymore. I think it may not deal well with some characters like parenthesis and there also may be some issues with file names or titles including numbers. :-/


I called it "mpcr[andom]" because, as you can see by the "shuf" command, it will pick something random from the keywords I've used. If the input is restrictive enough, though, it will play an exact track, as there will be only one to "shuf".


I'm not sure if it will work for you to use exactly as it is with gpodder, because I don't use this program. In fact now that I think about it I wonder how it would deal with this sort of "percent variable". Perhaps you'd have to "sed" out "file://" or something, I don't know.


Incidentally, I listen to podcasts with mpc, but I've also created a helper script do more or less the opposite; to make the currently playing track open with either gmplayer or vlc, as they're far better to rewind back just a bit, at least without some GUI for mpc.



...

This thread reawakened my curiosity on whether only with such monstrosity we could do that, so I searched a little bit and it seems that indeed a script is needed. I've found another one, surely looks prettier than mine, with all the licensing header and sh*t:


Code:
#!/bin/sh

# Copyright 2011 H.Gökhan Sarı (email : th0th@returnfalse.net)
#
# 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

FILTERS=$@

if [ ! -z "$FILTERS" ]; then
    PLAYLIST=$(mpc --format "%position% %artist% - %title%" playlist)
    FILTERED=$PLAYLIST

    for FILTER in $FILTERS;
    do
        FILTERED=$(echo "$FILTERED"|egrep -i $FILTER)
    done

    FILTERED=$(echo "$FILTERED"|head -n 1)

    set -- $FILTERED

    mpc play $1
fi

From:

http://th0th.me/log/mpd-music-player...-jump-to-song/



Eventually I'll test/check out and to try to figure or test whether it have the same flaws or not.

Last edited by the dsc; 04-19-2014 at 09:42 PM.
 
Old 04-19-2014, 09:47 PM   #3
the dsc
Member
 
Registered: May 2009
Distribution: Debian
Posts: 175
Blog Entries: 243

Rep: Reputation: 47
Actually, "%F" means a list of files, so perhaps it wouldn't be of much help.

You'd probably have to create a script that takes this %F and creates a playlist from it, and then just tell mpc to play the playlist from the start, non-randomly. Supposing the playlist/sequence matters, because %F can also be used for a list of a single file, anyway.
 
Old 04-20-2014, 03:15 AM   #4
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
When trying to use mpd to play music streamed in Second Life I found that adding the URLs to a playlist in .mpd/playlists/ in my home directory (where mpd is configured to look) would make them appear on tab 3 (the playlists tab) of ncmpcpp. I dare say you could script something to auto-generate a playlist of the files you want in that directory then open it in mpd.
 
Old 04-21-2014, 12:02 AM   #5
the dsc
Member
 
Registered: May 2009
Distribution: Debian
Posts: 175
Blog Entries: 243

Rep: Reputation: 47
If %F has several files in a single line (sometimes it does, but I don't know if it's a universal standard), one can do something like:

Code:
echo $* | sed 's|file://|\n|g' > /home/user/mpd-music_directory-set-on-mpd.conf/generated-playlist.m3u

Last edited by the dsc; 04-21-2014 at 12:03 AM.
 
Old 04-28-2014, 07:54 AM   #6
epimenidecretese
LQ Newbie
 
Registered: Dec 2013
Distribution: Slackware
Posts: 20

Original Poster
Rep: Reputation: 0
I've tried all the solutions proposed here and none of them worked. I am trying to understand what %F really means. On the documentation page of gPodder I've not been able to find anything useful.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] What does the Archive feature in gPodder do? linustalman Linux - Software 2 03-24-2014 03:13 PM
[SOLVED] Gpodder configuration issues Fritz_Monroe Linux - Software 1 07-31-2012 05:24 PM
gpodder crashing on lmde Furgar Linux Mint 0 11-26-2010 08:11 PM
gpodder in Suse kyleinc SUSE / openSUSE 0 09-09-2006 06:15 PM
gPodder on Suse 10? russh SUSE / openSUSE 2 06-01-2006 09:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 06:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration