Tech

media management script

I’ve always heard “necessity is the mother of invention”.  I’m sure you’ve come across this a time or two as well.  While this idiom is true, it is not a whole truth.  Necessity is not the ONLY mother of invention ;)  Laziness, boredom — pick your poison.  Well, I’ve sure been bored.  Bored enough to write a script that I could have likely picked up on my first search of google.  Last night I was watching a movie, fighting boredom tooth and nail the entire way, and I lost.  I was thinking about how I always manually manage my movies and music.  So very 20th century.

I decided I’d write a quick little script to manage this, and so I did.  And here it is, nothing fancy.  This fits my personal needs,  but I’d be happy to oblige any change/fix requests.  It will use the ID3 tag data from the first file in a directory to create destination directories and move all MP3s there.  The script utilizes mp3info to perform this ID3 tag information retrieval, so be sure you have it installed.  I did not add any sanity checks to the script!

There is one caveat soundtracks will not workout in your favor, additional logic is required to handle these.  I rarely if ever download soundtracks, so it has not been included — yet.  This has been addressed and soundtracks are now supported.

As I’m sure you’re aware, the easiest method for implementing this script is a cron job.  Below is my cron entry:

*/15 * * * * /usr/bin/mvdownloads >> /tmp/mvdownloads.log

This will run the cron job every 15 minutes and redirect the output to /tmp/mvdownloads.log.  Very simple.  I believe that covers everything — oh, if you do not restart your machine often, make sure that you have some mechanism for removing temp files/logs that either or not needed or are too large :)  Logging in this script is very basic!

Updates:

(12-20-09) – Fixed a bug where small or sample media files would not get deleted.  Included variable for movie size threshold so this can be adjusted based on your management needs.  Finalized logging output. Included support for soundtracks (Note: this causes the script to run longer, not much, and once the initial execution is complete, you will find it is negiligible.). Removed unnecessary debug logging, script is complete for now.

(12-19-09) – Added additional protection for primary source directory to ensure files are not lost, cleaned up logging, and organized script a bit better.  Added functionality to update firefly media server database.  Please note, this functionality requires additional variables set in the mt-daapd configuration file, read the script comments before using this or you will see no gain!  I’ve decided not to add concatenation support into the script, as sequence matching would be a bit iffy and the little benefit from this isn’t worth the possible issues.

(12-14-09) – Modified script so that the find command is case insensitive for all occurrences.

So here it is, enjoy: http://www.trippholden.com/wp-content/uploads/2009/12/mvdownloads

Chromium command line arguments

It took me a while to come across an extensive list of these, but someone kindly pasted the source of the file that lists the switches, so I’ve put them here as well.  Hopefully someone will stumble across them when they need them as well.  It’s a nice reference sheet for those of us who are using chromium on linux.

http://src.chromium.org/viewvc/chrome/trunk/src/base/base_switches.cc

// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include “base/base_switches.h”

namespace switches {

// If the program includes chrome/common/debug_on_start.h, the process will
// start the JIT system-registered debugger on itself and will wait for 60
// seconds for the debugger to attach to itself. Then a break point will be hit.
const wchar_t kDebugOnStart[] = L”debug-on-start”;

// Will wait for 60 seconds for a debugger to come to attach to the process.
const wchar_t kWaitForDebugger[] = L”wait-for-debugger”;

// Suppresses all error dialogs when present.
const wchar_t kNoErrorDialogs[] = L”noerrdialogs”;

// Disables the crash reporting.
const wchar_t kDisableBreakpad[] = L”disable-breakpad”;

// Generates full memory crash dump.
const wchar_t kFullMemoryCrashReport[] = L”full-memory-crash-report”;

Read the rest of this entry »

Convert VirtualBox .vdi disk to VMWare .vmdk

A couple months ago, I received a laptop upgrade from my company.  Naturally, it came with Windows…bleh.  I decided to install Ubuntu and dual boot it with XP in the event that I need Windows (which is unfortunately much more frequent than I’d like).  I didn’t put too much effort into application support before installing the latest version of Ubuntu, which brings me to the point of this post.  VMWare Workstation 6 will not work with the kernel I’m using.

I decided to give VirtualBox a shot given the fact that I did not want to buy a new license.  After using VirtualBox for a couple of months, I’m quite pleased with its functionality and ease of use.  Disk, and machine configuration are very intuitive and basic.  My only quarrel is that it does not allow resizing of virtual disks.  This is an issue because I do not want to size a disk extremely large to accomodate future additions or so small that it cannot support my future needs.  The ability to resize a disk is very handy for someone like me who creates templates and builds test boxes for each new project that I’m on.

I was finally able to obtain a VMWare Workstation 6.5 license and I’ve been looking into converting an existing VirtualBox .vdi disk file to the VMWare supported .vmdk format.  Why waste the effort of installation and configuration of a perfectly good virtual machine?  After some extensive reading on options, I discovered a very clean method for handling this.  Below are the steps that I’ve taken to convert my disks (note these instructions will have to be modified for your paticular flavor of linux).  These are very simple, yet sparingly documented steps for converting a virtual disk from the VirtualBox .vdi format to VMWare .vmdk format.

1. Install Qemu:

sudo apt-get install qemu

QEMU is an open source cross-platform emulator for Linux hosts. It comes with a program called qemu-img, which is a disk image management application. This program can be used to convert disk images to different formats and in the case of our exercise we will use it to convert the raw data to a vmdk format file.

2. Convert the .vdi disk to raw format:

VBoxManage internalcommands converttoraw winxp.vdi winxp.raw

3. Convert the raw data file to VMWare supported .vmdk disk image:

qemu-img convert -O vmdk winxp.raw winxp.vmdk

4. Remove the raw data file now that it is not needed:

rm winxp.raw

5. Resize the disk if necessary:

vmware-vdiskmanager -x 15GB winxp.vmdk

Finally I have space on my windows XP image to store performance data!  I hope this exercise helped you as much as it did me.