You are not logged in.

#1 2013-09-08 23:57:36

*nixer
Member
Registered: 2011-11-11
Posts: 56

MPlayer shuffle script broken...

Hello all.

I seem to have run into a brick wall with a script problem concerning MPlayer. A while back I enlisted the help of some of the users here in creating a bash script that would allow me to run a mplayer playlist more or less shuffled.

[Solved] Mplayer - Is this possible without a GUI?

Well.. the issue is this. A couple weeks back I decided I was going to do a clean install of Arch, and as of yesterday I went ahead and did. After reinstalling, copying over my backup user config files, etc., I noticed that it was not working anymore.

This was my slightly modified version that I had changed over the months

#!/bin/bash
pls=/tmp/$RANDOM.pls
echo "$1" >$pls
find * -type f ! -name "*.srt"|grep -v "$1"|shuf>>$pls
mplayer -playlist $pls
rm $pls

This, and the original, keep trying to append the filenames in the playlist as if they were located in the /tmp directory.

ie;
original

Playing /tmp/./test.flv.
Cannot open file '/tmp/./test.flv': No such file or directory
Failed to open /tmp/./test.flv.

or
modified

Playing /tmp/test.flv.
Cannot open file '/tmp/test.flv': No such file or directory
Failed to open /tmp/test.flv.

After making the playlist generate in the same folder, the script was almost there. The continued problem was that grep was no longer filtering out the initial media file used to launch the playlist, and I was ending up with it being listed twice. I even tried passing the "$1" variable to find's exclude parameters with no luck.

#!/bin/bash -x
#/usr/local/bin/mpscur

pls=$RANDOM.pls
echo "$1" >$pls
find * -type f ! -name "*pls" ! -name "*srt"|grep -v "$1"|shuf>>$pls
mplayer -playlist $pls
#rm $pls

and

#!/bin/bash -x
#/usr/local/bin/mpscur

pls=$RANDOM.pls
echo "$1" >$pls
find * -type f ! -name "*pls" ! -name "*srt" ! -name "$1"|shuf>>$pls
mplayer -playlist $pls
#rm $pls

Neither works. You can run the script from an additional script to see the terminal output like so...

#!/bin/bash
xterm -hold -e mpscur "$1"

Just launch any media file from a directory containing music/video using the above xterm script to see what I mean. I hadn't updated Arch for about 3-4 months, but I was still surprised to find that some kind of syntax had changed so drastically as to break this very simple job.

Any ideas why I can't...
- Generate the playlist anywhere other than the directory where the script is launched from (path issues).
- Properly filter out the originally launched file ("$1") from being added to the playlist's shuffle addition entries.

Offline

#2 2013-09-10 23:00:49

*nixer
Member
Registered: 2011-11-11
Posts: 56

Re: MPlayer shuffle script broken...

Sorry for the bump, but I didn't know who to PM. Could a moderator migrate this thread to the 'Programming and Scripting' sub-board?

Offline

#3 2013-09-10 23:40:32

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: MPlayer shuffle script broken...

Just use the "Report" button.


To know or not to know ...
... the questions remain forever.

Offline

#4 2013-09-10 23:55:16

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: MPlayer shuffle script broken...

Moving...

# edit: a quick hack would be to add a `cd /tmp` to the start of the script...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2013-09-11 08:44:12

*nixer
Member
Registered: 2011-11-11
Posts: 56

Re: MPlayer shuffle script broken...

Well... if I change directories to /tmp, it won't list the rest of the files without a hard-coded cd back to the original directory.

Any idea why the pipe to grep isn't removing the first file from the shuffled list additions? It just seems strange that even the original script posted by kokoko3k doesn't work anymore. What's changed in the base system, or did I screw up my install somehow?

Offline

#6 2013-09-11 08:58:37

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: MPlayer shuffle script broken...

*nixer wrote:

Well... if I change directories to /tmp, it won't list the rest of the files without a hard-coded cd back to the original directory.

If you use an absolute path in the find command, it will work fine: `find ~/*`, eg.

Any idea why the pipe to grep isn't removing the first file from the shuffled list additions? It just seems strange that even the original script posted by kokoko3k doesn't work anymore. What's changed in the base system, or did I screw up my install somehow?

It works for me. As to why it worked previously, I have no idea.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#7 2013-09-11 23:14:05

*nixer
Member
Registered: 2011-11-11
Posts: 56

Re: MPlayer shuffle script broken...

Since Linux doesn't support going to the root of any drive due to the way it mounts other partitions, I can't do anything like the windows equivalent of "cd \" can I?

Because, I had also created a previously working script where I had all my media in several folders on the root of a mounted drive (only one directory deep).

#!/bin/bash -x
pls=$RANDOM.pls
readlink -f "$1" >../$pls
cd ..
find "`pwd`" -type f ! -name "*pls" ! -name "*srt" ! -name "$1"|shuf >>$pls
mplayer -playlist $pls
rm $pls

Can anyone tell me if if this or the (non-grep) one above in post #1 works for them?

Last edited by *nixer (2013-09-11 23:14:52)

Offline

#8 2013-10-02 23:18:51

*nixer
Member
Registered: 2011-11-11
Posts: 56

Re: MPlayer shuffle script broken...

Not to be a bore, but did anyone verify if my version worked for them? I for the life of me can't figure out what changed after the reinstall.

Offline

Board footer

Powered by FluxBB