LWN.net Logo

[kde-announce] usb_device_amaroKscript 1.1.1.0

From:  Kevin Bulgrien <kbulgrien-AT-att.net>
To:  kde-announce <kde-announce-AT-kde.org>
Subject:  [kde-announce] usb_device_amaroKscript 1.1.1.0
Date:  Wed, 22 Feb 2006 07:07:44 +0100

Name: usb_device_amaroKscript
Version: 1.1.1.0
Type: amaroK Script
Depend: 
License: GPL
More Info:
http://www.kde-apps.org/content/show.php?content=35156

Description:
 USB_Device - An amaroKscript to manage simple USB
mass storage MP3 players.
Copyright (C) 2006  Kevin R. Bulgrien

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 2 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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA  02110-1301, USA.

Initial Release:  February 11, 2006
Original Author:  Kevin R. Bulgrien
Contact Details:  kbulgrien@att.net

Version:  1.1.1.0
Date:     2006.02.21

-------------------------------------------------------------------------------
README
-------------------------------------------------------------------------------

This script brings generic USB media player
support to amaroK because the 1.3.1 release
provided with the Mandriva 2006.0 Free
distribution only supports iPOD media players. 
The script was developed to support various
hot-pluggable USB mass-storage devices that can be
mounted as a file system and is only designed to
supports simple media players that do not require
external applications to maintain special database
files on the device, but simply allow playlists
and media files to be copied directly to it.

The script provides the following functions:

1) USB Device | Copy music to player

   Copy selected amaroK playlist tracks to the USB
device.  This is a simple file copy operation.

2) USB Device | Copy to player & playlist

   Copy selected amaroK playlist tracks to the USB
device.  The script allows the user to create an
m3u playlist of the copied tracks on the target. 
The created playlist entries can be written in a
new .m3u file, or they can be appended to an
existing .m3u file.  This allows the user to
create custom playlists without having to depend
on auto-generated playlists and without having to
use the player interface for playlist creation.

3) USB Device | Create a new playlist

   Select media files from the USB device and
create an .m3u format playlist directly on the
player.


4) USB Device | Delete music & playlists

   Delete media files from the USB device.  This
delete function masks files that it does not
consider to be audio or playlist content, though
the user is afforded the opportunity to identify
file extensions that are allowed to be deleted.

5) USB Device | Delete music in a playlist

   Delete all media files that appear in a given
.m3u playlist file that is on the USB device. 
This function allows a user to pull logical groups
of media files off of the player without requiring
files to be individually selected.

6) USB Device | Purge all music & playlists

   Delete all media files or playlist files from
the USB device to restart loading media on an
uncluttered player.  This delete function masks
files that it does not consider to be audio or
playlist content, though the user is afforded the
opportunity to identify file extensions that are
allowed to be deleted.

7) USB Device | Help

   Displays a dialog that explains the function of
each menu option in greater    detail.

Options 1 and 2 above operate on the amaroK
playlist files that are selected at the time the
function is invoked.  All other USB Device
functions operate
through prompts that allow the user to operate on
files that are already on the
media player.  This can feel somewhat odd for
other functions since one must place and select
files in the amaroK playlist even if the operation
involves
only files that are already on the player.  This
is a consequence of the fact that script functions
can only be invoked with the context menu for
files in the amaroK playlist.

USB_Device automatically handles mounting an
unmounting of the media player when the user has
specified the mount point.  The script generally
expects the mount point to be created by a hotplug
event that occurs when the media player is
connected to the system.  It is the user's
responsibility to be sure to set up any /etc/fstab
entries that might be required in order to make
simple mount and umount commands possible.

Even though USB_Device is capable of mounting and
unmounting the player, it is also smart enough to
leave the player mount alone if the user mounted
it
explicitly.

To use this script, install it into amaroK with
the Tools | Script Manager. The "Install Script"
button will properly install the tarball that
contains these files.

Once the script is installed, use the "Run" button
to start the script so that the context-click
menus are installed and operational.  All script
functions are grouped under the "USB Device"
context menu.  This context menu appears when you
right-click selected files in the amaroK playlist.

Configuration settings are stored in
~/.amarok_usb_device.

The user-configurable options are the media player
mount point, whether or not to use mount/umount
commands, and a selection of music file extensions
that may be deleted when "Purging" the media
player.

-------------------------------------------------------------------------------
REQUIREMENTS
-------------------------------------------------------------------------------

The following requirements are based on the RPM
package organization in the Mandriva 2006.0 Free
distribution.  The script automatically checks for
the presence of all requirements when it starts
up.

RPM Package    Executables
=============  ============
kdebase-progs  kwriteconfig
               kreadconfig
               kfmclient
               kdialog

kdelibs-common dcop

coreutils      basename
               printf
               df
               du
               rm

mount          umount
               mount

mp3info        mp3info

bash           bash

findutils      find

gawk           awk


Changelog:
 Version:  1.1.1.0
Date:     2006.02.21

-------------------------------------------------------------------------------
VERSION NUMBER DESCRIPTION
-------------------------------------------------------------------------------

usb_device.amarokscript is versioned as follows:

  x.y.z.w

x) Major release number.

   For this version to be incremented, a major
change in the implementation or feature-set of the
script must occur.

y) When a release incorporates new functionality,
this portion of the version number is incremented.

z) When a release is comprised minor feature
changes and/or bug fixes at the   same time, this
portion of the version number changes.

w) This version number is reserved for tracking
new releases that are strictly
bug fix releases.

-------------------------------------------------------------------------------
CHANGELOG
-------------------------------------------------------------------------------

1.1.1.0  Bug fixes, error handling improvements,
and addition of help dialog.

usb_device.amarokscript.sh
- Update script version and date.
- Rename the script function menu names to make
them more meaningful to normal human beings. 
Affects start(), stop() and the main loop.
- Add a new script menu item for a Help function. 
Affects start(), stop(), and the main loop.
- Removed script dependency of "kfmexec" in
requires() due to a rewrite of the transfer()
function.  Change made possible by url_encode() &
url_decode().
- Improve the m3u_playlist() dialog title that
asks for a playlist file to be chosen.
- Improve the wording of the selectable options in
the m3u_playlist() dialog that asks whether to
overwrite or append to pre-existing playlist
files.  Replace the term "track(s)" with "music"
in this dialog, and in a related dcop message.
- Associate the amarok icon with various dialogs
that did not previously do so. Affects
m3u_playlist(), m3u_erase().
- Function copier() is removed and the code
incorporated into transfer() due an improvement in
the structure of transfer().
- Function transfer() rewritten to remove a
vulnerability to a script crash that occurs if any
of the files to be copied are not readable.  This
can happen particularly easily if the amaroK
collection resides on a network share.  Each file
is now checked for readability prior to starting
the copy operation.  If any file is found to be
unreadable, the copy is cancelled.
- The use of kfmexec in transfer() existed to
allow shell commands to use URLs instead of
filenames when checking the size of files.  Since
url_decode() is now available, it is no longer
necessary to use kfmexec and the dependency has
been removed from usb_device.amarokscript.sh.
- The user is no longer offered the option of
continuing with a copy operation in transfer()
when it would fail because the USB device does not
have enough room for all of the selected files. 
NOTE:  The check is not entirely fool proof since
it does not consider that files might be
overwritten if they happened to already exist on
the USB Device.  This change simplifies the
structure of transfer().
- Error conditions in transfer() are now
communicated to the user by way of a dialog with
an exclamation point dialog.  Error information is
presented to the user in the text area of the
dialog.
- The transfer() function now reports space in
megabytes instead of kilobytes.
- The transfer() function now returns an error
status if the transfer is aborted for any reason.
- The playlist() creation function no longer
includes playlist files in the dialog that prompts
the user to select the files to be entered into
the playlist.  The title of this dialog has been
corrected.  It previously was a copy/paste error. 
The title indicated that files were being selected
for deletion instead of for addition to a
playlist.
- Fixed regression introduced in playlist() with
the introduction of a call to url_encode().  When
the user cancels out of the file selection, the
script now properly avoids creating a playlist
file.
- Fixed regression introduced in delete() with the
introduction of a call to url_encode().  When the
user cancels out of the file selection, the script
now properly avoids attempting to delete files.
- The delete() function dialog title has been
improved.
- The eraser() function now raises a dialog if any
files could not be erased. The files that could
not be erased are listed in the dialog.
- The eraser() function has been changed back to a
for loop so that the number of files that were
deleted can be reported to the user in a dcop
message.
- The m3u_erase() function dialog title has been
improved.
- The m3u_erase() function did not call
url_encode(), and therefore was likely to fail if
the USB Device playlist contained references to
files with spaces in their names.
- The purge() function dialog title has been
improved, and the instructions on the dialog have
been corrected.  The text previously instructed
the user to include periods when listing file
extensions.  The text was supposed to say that
periods should not be included.
- The main loop option to copy music and create
playlists no longer attempts to create a playlist
if the copy failed.
- A helper() function has been added that simply
displays help information in a message box dialog.
- The main loop now checks for an indication that
the Help command has been invoked, and calls the
helper() function as needed.

CHANGELOG
- Modified the version number description to
better fit the intended use of the field
positions.

README
- Updated the script version and date information.
- Updated the script function titles to match the
changes made in the script.
- Added a reference to the new Help function.
- Updated the requirements to remove kfmexec.

TODO
- Updated the script version and date information.
- Added an idea for a status command.



_______________________________________________
kde-announce mailing list
kde-announce@kde.org
https://mail.kde.org/mailman/listinfo/kde-announce


(Log in to post comments)

Copyright © 2006, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds