View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 6 posts ] 
Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Sun Mar 18, 2007 3:21 pm 
Offline
Joined: Sun Apr 16, 2006 10:30 am
Posts: 13
I have a fairly large collection of MP3's, and wanted to be able to list them in MythMusic both by Artists and by Album. I couldn't figure out how to do this with the smart playlists, but, since I am fairly well versed in SQL, I decided to write a script that would create a playlist for each of my albums in MythMusic. This way, I can sort my collection by Artist, and then in playlists, have all my albums.

I'm using R5D1 but upgraded to the latest mythtv that debian-multimedia.org has, so I'm not sure if the db schema is the same for the stock R5D1, but it should be fine for R5E50 (I think).

Let me know if this works for you.

I'm not in front of my machine right now, so the steps may not be completely correct, if not, please correct me.

Anyways, basically you have to run the script on your mythtv database. Unfortunately, you will have to run this script every time you add a new album to your collection as well.

Anyways, here is the script:
Code:
CREATE TEMPORARY TABLE _temp
(
   playlist_id INT,
   playlist_name VARCHAR(255),
   playlist_songs TEXT,
   last_accessed TIMESTAMP,
   length INT,
   songcount SMALLINT,
   hostname varchar(255)
);

INSERT INTO _temp (playlist_id, playlist_name, playlist_songs, last_accessed, length, songcount, hostname)
   SELECT
      (SELECT playlist_id FROM music_playlists WHERE playlist_name = music_albums.album_name) AS playlist_id,
      music_albums.album_name AS playlist_name,
      GROUP_CONCAT(song_id) AS playlist_songs,
      CURDATE() AS last_accessed,
      SUM(music_songs.length),
      COUNT(music_songs.song_id) AS songcount,
      'mythtv-01' AS hostname

   FROM music_albums

   INNER JOIN music_songs
      ON music_albums.album_id = music_songs.album_id
   INNER JOIN music_artists
      ON music_songs.artist_id = music_artists.artist_id

   GROUP BY
     music_albums.album_name;

INSERT INTO music_playlists
   SELECT * FROM _temp ORDER BY playlist_name
   ON DUPLICATE KEY UPDATE playlist_id = VALUES(playlist_id);

DROP TEMPORARY TABLE _temp;


Save that script into a file called CreateAlbums.sql. NOTE: Be sure to change the hostname in the script above from 'mythtv-01' to whatever your mythtv box's hostname is.

Then run the script on the database:
Code:
mysql -u mythtv -p mythconverg < CreateAlbums.sql


Be sure to enter the password you set up for the mythtv user in the database when it prompts you. (Probably 'mythtv');

Then check out your Playlists in MythMusic. You should have a playlist set up for each of your albums.

When you add a new album to your collection, after you add it to the database (when it scans for music), you can run this to add it to the playlists. This will not remove any playlists you have created, nor will it remove the ones created with this script, but if you add a single song to an album, as long as the album has the same name, then it will add it to the playlist for that album. NOTE: Different Albums with the same name will probably show up under a single entry in the playlists. I'm not sure of a way around this.

I hope this fills a need out there. It sure did in my house.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 18, 2007 10:33 pm 
Offline
Joined: Tue Dec 20, 2005 3:35 pm
Posts: 57
Location: Seattle, WA
Did't work for me... I got:

root@mythtv:/home/mythtv# mysql -u mythtv -p mythconverg < Create_Albums.sql
Enter password:
ERROR 1064 at line 12: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT playlist_id FROM music_playlists WHERE playlist_name = m
________
Lamborghini espada


Last edited by mz4wheeler on Thu Feb 24, 2011 1:17 am, edited 1 time in total.


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 19, 2007 12:34 pm 
Offline
Joined: Sun Feb 19, 2006 1:09 pm
Posts: 29
Location: Munich, Germany
Nice script... Thanks a lot!

Work fine for me on R5E50...

_________________
KnoppMyth R5E50
3 x SkyStar2
1 x Pinnacle PCTV 400e USB
nVidia GeForce FX 5200 (MBE)
nVidia GeForce 7100 GS (FE)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 30, 2007 6:18 pm 
Offline
Joined: Tue Aug 08, 2006 7:08 pm
Posts: 561
Location: UK
I stumbled across this thread when looking about setting up playlists in Mythmusic (as well as this which refers to importing m3u files).
Does the "mythtv-01" in COUNT(music_songs.song_id) AS songcount, 'mythtv-01' AS hostname refer to the hostname of the actual box it was run on?

Bruce S.

_________________
Updated 2019/10/26: AthlonII X2 265 Gigabyte GA-970A-DS3P
16Gb PC 1866 DDR3, 500GB+2TB+4TB SATA HDD,
SATA DVD-RW Asus DRW-24D5MT , NVIDIA GeForce GT1080
Hauppauage Nova-T 500, Nova-T LinHes R8.6.1


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 30, 2007 7:02 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
Yes. A number of the DB tables, including "music_playlists", are keyed by the hostname of the machine. This is done so that you can have separate settings for different FE boxes. I posted a complete list somewhere around here in the past couple months.

OBTW - The list of tables is: capturecard inuseprograms jobqueue jumppoints keybindings music_playlists musicplaylist profilegroups recorded settings mythlog


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 31, 2007 3:40 am 
Offline
Joined: Tue Aug 08, 2006 7:08 pm
Posts: 561
Location: UK
Thanks.

Bruce S.

_________________
Updated 2019/10/26: AthlonII X2 265 Gigabyte GA-970A-DS3P
16Gb PC 1866 DDR3, 500GB+2TB+4TB SATA HDD,
SATA DVD-RW Asus DRW-24D5MT , NVIDIA GeForce GT1080
Hauppauage Nova-T 500, Nova-T LinHes R8.6.1


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 


All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu