MythMusic Extra Topics

From MythTV Official Wiki
Revision as of 04:03, 1 November 2023 by Twitham1 (talk | contribs) (moved from MythMusic manual)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Important.png Note: The information that follows below may be outdated and no longer work or may not be relevant to the current version of MythMusic.

This was relocated here from the MythMusic manual as of v34.

Media Shares

Mediashares gives a simple walk through of how to export your media directory so its accessible from your other remote Mythtv systems.

Linking Pre-Existing Audio Archive with MythMusic

iTunes

Here is how I sync'd MythMusic with an already established iTunes setup. All of our music is stored on a laptop (my wife is a DJ so it must be portable) that runs Windows XP. I wanted to back the music up to our myth box, and also make the songs and the playlists that were already created in iTunes, available via MythMusic. First, I decrypted any purchased iTunes music using QTFairUse. The decryption was only necessary to allow MythMusic to play music purchased from the iTunes Music Store (Please don't steal music!).

Then I configured the Windows XP laptop to share the iTunes folder (stored in My Documents\My Music by default) on the network:

   1. Right-click on the iTunes folder
   2. Click Properties
   3. Click the "Sharing" tab
   4. Select "Share this folder"
   5. Note the share name, e.g. "iTunes"
   6. Click Ok

On the myth box, I used Samba to mount the laptop's shared iTunes folder, and rsync to copy all files from the laptop to the mythbox:

   $ su
   # mkdir /mnt/iTunes
   # mount -t smbfs -o username=<user> //<laptop IP address>/iTunes /mnt/iTunes
   Password:
   # mkdir -p /storage/music/iTunes    # this is where I keep my music, change as necessary
   # chown -R mythtv:users /storage/music
   # su - mythtv
   $ rsync -q --recursive --perms --times --timeout=600 --delete /mnt/iTunes/ /storage/music/iTunes
     ***This can take a while***
   $ exit
   # umount /mnt/iTunes
   # exit
   $

In mythfrontend, I setup MythMusic to look for music in /storage/music and performed a scan for new music. It found all of the music and populated the database (Note: you must have AAC support enabled for MythMusic to find AAC files).

Next, I wanted all of my iTunes playlists to appear in MythMusic. I found this page that provides a utility script that creates MythMusic playlists from an iTunes library xml file. Since I'm using myth 0.20, I downloaded this version of the script. Versions before 0.20 should download this version. There's a small bug in the 0.20 script as is, so I had to open the script in an editor, search for "playlistid" and replace it with "playlist_id" (Note the underscore). I also had to change the values of the variables at the top of the script to suit my system. Then I ran the script and my playlists were imported into MythMusic.

I finally setup cron scripts to periodically attempt to sync with the laptop (using the same rsync command as above), and rerun the mythtv-itunes.pl script to keep the playlists up to date.

Filename Matcher Script

I wasn't happy with a couple of things that the previous scripts did, and so I started changing them here and there, and eventually most of the thing was gutted. So here's my version of the above scripts, tested and found working on Myth 0.21.

Previous scripts have been more general in that they searched the MythMusic database for similar Artists and Song Name and Album and then they called that a match. I didn't like this behavior for a couple reasons. I could never get non-ascii characters in the ID3 tag to map properly. The script would just give up on those songs. Similarly, I have a few songs where the Album field is blank, but the Song Name and Artist are the same (different recordings, live shows, etc) and the previous scripts would simply match all these to the first finding of the song in the database.

By matching on filename, we actually get the correct matches and the matching is much faster. Instead of accessing the database once for each song in your iTunes library, it accesses the database once for the entire library. Tests thus far have shown a speedup of 400% over previous scripts! We also don’t have to worry about the ID3 tag containing "non-standard" characters, the songs will still map. So you can keep your Latin and German music with it's non-standard characters and still have matches.

A couple of gotchas though. I'm no character encoding genius, in fact I'm probably a character encoding idiot, but from my little research for this project I noticed iTunes will store non-ASCII characters just fine as escaped hex values in the iTunes library XML file. MythMusic, on the other hand, doesn't seem to store that information, being a Latin1 database. I'm also a Perl idiot, so I never figured out how to change the data correctly. Basically, if you have non-standard characters in the actual filename (not the ID3 tag), these songs will probably not map. Sorry, but if someone knows how to do the proper conversions in Perl to make iTunes and MythMusic play nice, that would be a nice feature to add to the script. Also, if you find my explanations to be bogus, just remember I might not know what I'm talking about.

Also, while I really don't believe this will ever be a problem, I might as well disclaim it. I've tested this script on my library (~1700 songs) and it works great. However, because this loads some of the music_songs database into a Perl variable before it starts matching, the memory footprint of this script could be larger than the previous Perl scripts. I'm interested in how even the largest of music libraries perform with this script.

mythtv-itunes-filename-match.pl - Brian.phillips 04:52, 11 January 2009 (UTC)

PHP Script

I started development of an iTunes to MythMusic conversion script using the same XML file when the first two results didn't work out for me. I posted it up at this site and then last fall someone else took a stab at the source and sped the whole thing up. Basically all you have to do is rsync your music to your system and then scan for new music in MythMusic setup. Run the script and it will map each of the files to their ID numbers in the myth database and then create all of your playlists so that they'll be available on any of your mythboxen. The source is made available through subversion so please feel free to develop speed improvements or solutions to the overall puzzle and send me patches but as it stands a 11000 song library takes less than a minute to map and it's only missing the special chars Brian.phillips mentions above and the m4v files that MythMusic doesn't store in it's database.

iTunes Playlists in MythTV - Weezey 11:55, 22 April 2009 (UTC)


RubyRipper

I use RubyRipper to rip my CD Music library. I also prefer a much different directory and file layout then MythMusic uses. The RubyRipped files are my 'master'. MythMusic 'Scan for new music' will NOT successfully identify music files that are themselves symbolic links. Scanned files, for now, must be hard links. As space is a consideration though, I don't want to manage two sets of directories with duplicate copies of the same data. So, the solution is to do a HARD LINK from the master audio archive directory to the target mythtv/music directory.

Important.png Note: Hard links must exist on the same file system. So, this only works if your audio library directory and mythtv director are on the same volume/partition.

This little perl script when run will find the all files under audioarchive/vorbis. It then splits the path. This script array elements 4,6,7 of that path align with genre/artist/album. Directories are created under /mythtv/music and a second HARD LINK is created to the master audio file. You'll need to adjust the array element numbering to match your archive path structure and also adjust the order for your MythMusic path.

I also modify the permissions of the '/mythtv/music' directory and files to be 'read-only' because I don't rip from MythMusic setup. While the built in ripper is very flexible and includes all the elements for creating a complex and unique hiearchy -- it doesn't support ripping multiple formats at once like RubyRipper, or swapping out the default ripper with a command reference to a ripper of choice.

So, note that if you use the permission settings in the perl script, all attempts to rip from the MythMusic interface should/will fail since the mythtv user has no write permissions under /mythtv/music.

Application-x-perl.png script

#!/usr/bin/perl

$audioArchive = '/audioarchive/vorbis';
$mythMusic = '/mythtv/music';

@fileList = `find $audioArchive -type f -print`;

foreach $file (@fileList) {

        chomp($file);
        # The RubyRip setup is format/genre/year/artist/album/title
        # Constructing for MythMusic in genre/artist/album/title
        @rubyRip = split('/', $file);
        $mythMusicPath = join('/', ($mythMusic, $rubyRip[4], $rubyRip[6], $rubyRip[7]));

        next if ($rubyRip[8] == 'ripping.log');

        # Make first the directory structure genre/artist/album under mythMusic
        # and the symbolic link to the song titles.
        `mkdir -p "$mythMusicPath"`;    # -p no error on existing. Save Cyles with first -x check?
        if ($@) { print "ERROR Making Directory: $@\n"; exit (1); }

        # Now link the file.. [HARD LINKS]
        `ln "$file" "$mythMusicPath/$rubyRip[8]"`;
        if ($@) { print "ERROR Linking: $@\n"; exit (1); }

}

# Update perms
`chown -R mythtv.mythtv "$mythMusic"`;
`find "$mythMusic" -type d -exec chmod 555 {} \\;`;
`find "$mythMusic" -type f -exec chmod 444 {} \\;`;

Troubleshooting

Error Message Looking up CD on cddb

The full text of the message will say:

databasebox.o: Couldn't find your CD. It may not be in the freedb database.

More likely, however, is that you need to delete /.cddb and /.cdserverrc and restart MythMusic. To do this, go to the home directory of whatever user MythMusic is running as and type:

   rm .cdserverrc
   rm -rf .cddb/

These files aren't automatically deleted because of a conscious design decision by the author that programs that automatically delete things are bad.

The files are used to locally cache CD lookups. If you are re-inserting CDs, your machine will not actually have to go out to the Internet to determine what is on them. However, the URL used to access the freedb database has recently changed, so the stale information in the files from previous runs of MythMusic would cause the error above. Once the files have been deleted the stale information will be gone and your local database will be rebuilt as you use CDs.

The default cddb server in .cdserverrc doesn't seem to be working very well all the time, here's a list of servers you can add:

 SERVER=cddbp://freedb.freedb.org:8880/ CDDB
 SERVER=http://freedb.freedb.org:80/~cddb/cddb.cgi CDDB
 SERVER=cddbp://at.freedb.org:8880/ CDDB
 SERVER=http://at.freedb.org:80/~cddb/cddb.cgi CDDB
 SERVER=cddbp://ca.freedb.org:8880/ CDDB
 SERVER=http://ca.freedb.org:80/~cddb/cddb.cgi CDDB
 SERVER=cddbp://cz.freedb.org:8880/ CDDB
 SERVER=http://cz.freedb.org:80/~cddb/cddb.cgi CDDB
 SERVER=cddbp://no.freedb.org:8880/ CDDB
 SERVER=http://no.freedb.org:80/~cddb/cddb.cgi CDDB
 SERVER=cddbp://uk.freedb.org:8880/ CDDB
 SERVER=http://uk.freedb.org:80/~cddb/cddb.cgi CDDB
 SERVER=cddbp://us.freedb.org:8880/ CDDB
 SERVER=http://us.freedb.org:80/~cddb/cddb.cgi CDDB
 

No Sound From Digital Output

If you have working sound via a digital output from video recordings, but nothing from MythMusic, make sure the correct audio device is configured for MythMusic. In particular, check for the following error in /var/log/mythtv/mythfrontend.log

AudioOutput Error: Rate doesn't match (requested 44100Hz, got 48000Hz)

If this error is present, you may need to edit the audio device. Go to Utilities/Setup -> Setup -> Media Settings -> Music Settings -> General Settings and edit the "Audio device" field. Enter the value, "ALSA:plug:iec958".