Re: Newbie Questions

Matt McClure <[email protected]> Wed, 30 Jul 2003 10:59:25 -0400
Newsgroups gmane.comp.audio.netjuke.user
Organization me
Message-ID <[email protected]>
On 7/30/2003 9:46 AM, Florian Maul wrote:
>> 3) Why is the import done in PHP? Surely it would be much more 
>> efficient to write a native app which could be run on a cron job or
>>  whatever just to synchronise the DB to the media files?
> 
> I don't think it is that inefficient - not as fast as native code 
> could be, I admit. But on the other hand PHP provides easy access to
>  database (adodb) and the getid3 library for tag reading. The cronjob
>  ability should definitely be addressed in 1.1 but I'd opt for an 
> additional php-shellscript which can be called to update the 
> database.
> 
>> Hope someone can answer these questions. I am willing to code some 
>> of the above if required (particularly the offline DB synchroniser)
>>  just let me know if you think I can help.
> 
> For an easy solution you could try to query the tabfile-recursive.php
>  with lynx or wget from a cronjob. I haven't done this so far and it
>  might require altering code (or pass cookies) for authentication.

Here's a short shell script I use to create a random playlist and load
it into xmms.  It uses curl to manage cookies for authentication and do
https -- both ideas I took from someone else on this list, but I can't
remember who at the moment.  It might give you a start toward a script
for keeping the Netjuke database in sync with the mp3s on your filesystem.

-- 
Matt
http://www.faradic.net/~mmcclure/

    The whole genre of the one-bedroom apartment on the Lower East
    Side has escaped the [MTV] Cribs radar.
        -Mike Doughty
random_mp3s.sh (text/plain, 838 B)
#! /bin/sh

user=
password=

numtracks=10
usage="usage: $0 [numtracks=$numtracks]"

if [ $# -eq 1 ]; then
    numtracks=$1
elif [ $# -ne 0 ]; then
    echo $usage
    exit 1
fi

playlist=`curl -b 'fake_cookie=to_enable_cookie_parser' -Ls -F "netjuke_login=$user" -F "netjuke_password=$password" -F 'do=select' -F "limit_pl=$numtracks" -F 'genres[0]=0' 'https://my.secure.webserver/netjuke/random.php' | grep -e 'pl_id=[0-9]\+' | head -n 1 | sed -e 's/.*pl_id=\([0-9]\+\).*/\1/'`

curl -Ls -F "netjuke_login=$user" -F "netjuke_password=$password" -F 'do=plist' -F "val=$playlist" 'https://my.secure.webserver/netjuke/play.php'> /tmp/playlist.m3u

xmms -s /tmp/playlist.m3u

curl -Ls -F "netjuke_login=$user" -F "netjuke_password=$password" -F 'do=del_pl' -F "pl_id=$playlist" 'https://my.secure.webserver/netjuke/pl-edit.php' > /dev/null
signature.asc (application/pgp-signature, 249 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE/J91NrGgMpZIoLA8RAmMaAKDZ4dND/GhPTmpiLGse03OsX6EvAwCfTQa+
QXoe1qgqWnEcFMn0Y18nXyg=
=cGh3
-----END PGP SIGNATURE-----