Jump to content

How to setup Relations (?) for a MP3 DB with PW?


horst
 Share

Recommended Posts

Cool! What did you find was the issue with the importer?

 It was that thing with that a selector query for titles longer than 50 chars haven't found allready existing pages. After Soma has found the answer for that, I have rewritten that part, because the pages of type genre and artist have to be unique whereas the pages for albums and songs could have duplicate titles. This is working now.

Yes, please wait with the update until tonight incase there are issues to report, thanks. :)

Gladly!

Link to comment
Share on other sites

Horst,

I have changed all "multiple page selection" to "single page selection" for the following pages and it works OK but I get an error in the module config. See attachment:

  1. album         
  2. artist         
  3. bitrate     
  4. bitratemode 
  5. genre         
  6. samplerate

By my reckoning there's no need for these pages to be multiple select types. E.g., a track/song can only have one of #3 - 4 & 5; Btw, the case of one song by the same artist but appearing in different albums is not a problem since the different albums will be used to categorise the songs, no?

I'll wait for your update.

Two feature requests:

  1. Automatically copy album cover to PW using the import script. Is this possible? It is tedious manually copying images for each album in PW. Maybe I could use phpMyAdmin to do this (after the fact) and manually create the folder images and copy them to PW.
  2. Reading and recording the songs bpm

Thanks.

post-894-0-55997800-1368046110_thumb.jpg

Link to comment
Share on other sites

 I have changed all "multiple page selection" to "single page selection" for the following pages and it works OK but I get an error in the module config. See attachment:

  1. album         
  2. artist         
  3. bitrate     
  4. bitratemode 
  5. genre         
  6. samplerate

By my reckoning there's no need for these pages to be multiple select types. E.g., a track/song can only have one of #3 - 4 & 5; Btw, the case of one song by the same artist but appearing in different albums is not a problem since the different albums will be used to categorise the songs, no?

 That's right. My bad, I have selected the wrong type. Will correct it with the update.

Two feature requests:

  1. Automatically copy album cover to PW using the import script. Is this possible? It is tedious manually copying images for each album in PW. Maybe I could use phpMyAdmin to do this (after the fact) and manually create the folder images and copy them to PW.
  2. Reading and recording the songs bpm

 1) Will be done by the importer. Is allready prepared to run, but yet not enabled, because I first want to have all other stuff stable.

     BTW, what do you think is better: should I create a separate script what only import a cover for each album. It could be called automatically at the end of the importer  script. Or should it better be together with the importer script as a single script?

 2) Where is it stored?

     ID3v2 only, or could it be into ID3v1 too?

     Is it called bpm or BPM or BpM (maybe you can pm me a sample mp3 where it is set)

Link to comment
Share on other sites

 That's right. My bad, I have selected the wrong type. Will correct it with the update.

 1) Will be done by the importer. Is allready prepared to run, but yet not enabled, because I first want to have all other stuff stable.

     BTW, what do you think is better: should I create a separate script what only import a cover for each album. It could be called automatically at the end of the importer  script. Or should it better be together with the importer script as a single script?

 2) Where is it stored?

     ID3v2 only, or could it be into ID3v1 too?

     Is it called bpm or BPM or BpM (maybe you can pm me a sample mp3 where it is set)

1. Both options could work. The important thing is perhaps there should be a pause to prompt the user to make the choice? A separate script would be nice where one needs to add/replace cover images in future. Of course you can also enable this as an option in the main script where the user would be asked whether they wish to import cover images only or audio as well. I prefer the second option though; one single script but with a prompt to the user if they wish to import cover images or not. 

2. ID3v2.4.0 onwards I think (wikipedia). It is BPM. I'll PM you a sample mp3.

  • Like 1
Link to comment
Share on other sites

  2. ID3v2.4.0 onwards I think (wikipedia). It is BPM. I'll PM you a sample mp3.

Have read in wikipedia about BPM:

ID3v2.4 is the latest version published, dated November 1, 2000

Windows Explorer and Windows Media Player cannot handle ID3v2.4 tags in any version, up to and including Windows 8 / Windows Media Player 12.

Windows can understand ID3v2 up to and including version 2.3

 Lazy Boys from Redmond :(

  • Like 1
Link to comment
Share on other sites

Hmm, it seems I cannot add attachments to the PM...I think that is disabled by Admin. I may have to send it to you via a cloud service...Should I do this?

Btw, track length is shown in what I assume to be seconds in my tests. Minute:Seconds would be nice :)

Link to comment
Share on other sites

I keep forgetting...

1. When the script fails, it does so and closes without giving the user a response..

2. To add albums later on, do I just run the script again against my new albums? Btw, would it detect if that album is already in the database and not bother to import it?

Thanks!

Link to comment
Share on other sites

 ...

Btw, track length is shown in what I assume to be seconds in my tests. Minute:Seconds would be nice :)

Hhm, I want to stay with seconds in DB-field because than one can easily calculate total times of albums, the whole DB or what ever.

I think it could be done on the fly. I have allready included some sort of this into the frontend-class for that.

to store both into the DB is much unwanted redundant data, Wanze would say :-)

 2. To add albums later on, do I just run the script again against my new albums? Btw, would it detect if that album is already in the database and not bother to import it?

No, it

  1. recognizes Tracks by filename and skip them when already in DB
  2. it calculates a checksum to recognize duplicate files stored at different places
  3. and it checks sanitized strings for artist / album / song, so it also detects duplicate songs where the ID3Tags are a (very) little bit different (lower/ uppercase) or when you have the same song in different Bitrates

Also all tasks are logged into files in site/assets/log/SubFolder/ ...

post-1041-0-76765900-1368053179_thumb.jppost-1041-0-34305400-1368053181_thumb.jppost-1041-0-09632600-1368053183_thumb.jp

Edited by horst
Link to comment
Share on other sites

Ok, here are the list:

  • AlbumCover-Import is done
  • new field for BPM in Songs is done
  • ImporterScript now asks the user for every Task to enter a yes or no:   (done)
  • optionally delete all Pages (reset DB)
  • import Files- and Metadata
  • import AlbumCovers
  • recreate the complete CacheData
  • ImporterScript also ends with a question for 'Enter' to avoid closing the shellwindow   (done)

:)
 
 
ToDo:

  • As of the different CharEncodings with ID3v2.3 and ID3v2.4 (I think these are the two most common today) I have to rewrite the core ID3Tag-Reading. Until now I've used  3.party-code for that, but to play save on a per-file or per-field basis with mixed ID3Tag-Versions it's better to rewrite this.
  • Some minor things here and their

:mellow:

After that I can upload a useful SiteProfile. :)

post-1041-0-26413100-1368260862_thumb.jppost-1041-0-11140500-1368260861_thumb.jp

  • Like 1
Link to comment
Share on other sites

Good progress!

Btw, how to deal with albums with various artists? Currently such albums will appear under the listings of all those artists who contributed. Not much choice here since using "various artists" as artist title will quickly cause confusion where there are several such albums.

Link to comment
Share on other sites

Horst,

OK, here I am to throw a spanner in the works again :). I have just noticed songs with VBR are not getting their bitrates captured. I suppose this is because they do not fit into the predefined bitrates we have. So, something with a bitrate of 206 is not getting that captured. The field remains empty. Makes me wonder whether bitrates should just be text (int) fields entered directly in the tracks template (if missing after import) rather than pulled in as page fields? Currently, there is no way to manually edit the bitrate because they are presets :) What do you think? It also doesn't make sense to create pages just for such uncommon bitrates...

edit: File names with potentially risky characters are getting these stripped off on render. E.g. echoing the file name "Let's sing a song..." will have everything after the apostrophe stripped off include ending up with broken paths like this "Let...." Seems some strip tags something is getting to work!

Cheers.

Edited by kongondo
Link to comment
Share on other sites

Hi kongondo,

that with the bitrates I have allready solved that way that I capture them rounded (to fit into the predefined).

That with the filenames I don't understand. ?? But the actually code has changed a lot, comparing against the first version.

Link to comment
Share on other sites

Horst,

OK, thanks. About the filename, what I mean is that if you want to embed a song to play on your site, you need, of course, the path to that filename. Let's say your path is as follows:

F:/path/to/my/mp3/in/local/pw/host/01. let's reach for the sky.mp3

In your template, if you try to echo that out, e.g. ...

<a data-src='{$config->urls->templates}{$track->filename}' href='#'> 

The output will be

 F:/path/to/my/mp3/in/local/pw/host/01. let

which will generate a media not found error, of course...

Hope it is clearer now :)

Link to comment
Share on other sites

Been having fun with this! Here's the output..A frontend demo of Horst's Local Audio Module...It's been fun playing with PW selectors and variables. First, I'd like to thank all the forum folks who've helped answer my API questions :) - Teppo, Soma, Diogo, Nik, etc....you know, the usual suspects.... :P  O0  Thanks to AnotherAndrew for this post. It led me to the nice jQuery plugin, Filtrify.  Horst, big thanks for the module.!

It's been a massive learning process for me besides having fun (and at times frustration ! ;)) along the way. There were times I went round in circles only to realise I was making simple things difficult; this is PW, the solutions are usually simple! Most of the theme is based on Filtrify's demo so all credits to Luis Almeida. Of course I won't be releasing his theme; this is just a demo ;) (unless of course there are no restrictions). I think what I enjoyed most was the logic behind PW and how I could apply that to the demo [being a newbie and all!]. More than getting a solution I like the reasoning that comes before a solution, the journey to an end if you like. The power and sheer genius of PageReference fields and chaining selectors really clicked for me while working on this. 

Tools used:

  1. PW (duh!)
  2. This module (duh!x2)
  3. jTable (as I wait to learn DataTable) - for tabular track list
  4. Filtrify to create album catalogue
  5. Audio.js to play the embedded audio

When this is done, @Horst, we probably want to do a tutorial/write-up about your project and how I did the frontend?

Cheers

  • Like 3
Link to comment
Share on other sites

OK, thanks. About the filename, what I mean is that if you want to embed a song to play on your site, you need, of course, the path to that filename. Let's say your path is as follows:

In your template, if you try to echo that out, e.g. ...

<a data-src='{$config->urls->templates}{$track->filename}' href='#'>

Ok, now I know what you mean :) !

first: it wasn't intended to use the filename as output in the frontend, (I never had thought that one want to do that). I provide stream-Urls for playing/downloading with the frontend-handler: echo $fe->streamurl(); // outputs something like: /stream/12345/song.mp3 whereas 'song.mp3' is an optional fake filename what is needed by Yahoo-Webplayer for example. Or you simply use "/stream/{$song->id}/". Has you used the FrontEndHandler with your code? - or have you done every thing without it? (I know there were no docs with it, but I've said that it is in a very, very early state, sorry  :-[  )

second: I'm not shure about data-src, (but as you use $config->urls, I assume you want use an url with it), - would one not to have to url_encode the filename? - But anyway, I never would use filenames with it, but stream-urls.

------------

@kongondo: Oho, - this is an awesome Frontend! Very cool, - feature rich, - good design. :)

And yes, when all is ready, there should be something like a tutorial or maybe a good screencast (like Joss described how to do it). But I'm at the very beginning with the project :lol:. There are lot's to do. Just the importer seems to be stable right now. And what is really needed is some documentation that ships with the SiteProfile. I write some points down here and include them into the site later:

-------------------------------------------

LocalAudioFiles provide a FrontEndHandler ($fe) for different data, - allready prepared for most usage:

  • streamurl, (provides partial-downloads! and directly starts playing)
  • playlist generation as m3u or pls,
  • objects like $page, (but they are not real PW-pages) for the current page, because as of the DB-structure an album hasn't children that are songs, but it is really usefull to have children (and also it is logical). So when calling the FrontEndHandler it creates automaticaly the object for the current page: $genre, $artist, $album, $song. The $genre has PageArray artists as children, the $artist has PageArray albums as children and $album has PageArray songs as children.
  • $album and $song have cover as PageImage, so you can use it like $album->cover->width(200)->url
  • the FrontEndHandler also provides fully customizable FormSelectFields. You can call them like $fe->getFormSelect('album') or $fe->getFormSelect('artists'), whereas if you use genre, artist, album - you get a SingleSelectField, if you use the plural, genres, artists, albums you get a MultiSelectField!
  • the data for select fields, - or for any other complete list is retrieved from an own Cache, that makes it really fast, once the cache is created. (after importing files, there is an option to (re)build it, otherwise it creates itself on demand)
  • Forms for playlists, also random ones, will be send as POST-Request to /playlist/m3u/ for retrieving a m3u-playlist and to /playlist/pls/ for pls-type.

    With fieldnames album|albums - genre|genres - artist|artists you have to send IDs.

  • you also can send a single song or album id to /playlist/m3u/{$id}/ as a GET-Request, (or: /playlist/pls/{$id}/)
  • and there are more things, ...
  • I have to write down it all, but it will take some time. I have started to add a demo section to the site, - but there are some points that needs to be coded (CacheRebuild), there are others that needs to be rewritten (CharEncoding with different ID3-Versions). The Docs need to be written, (oh, yes - I've allready said that :) ), ...
  • ... and when working/playing with it, I get new ideas for new things :) like a playing history (has to go into stream-code, where we have control how many of a song is played, maybe when 80% of a song is streamed it counts up 1), OR - oh, now that I have $song, $album, $artist, $genre I should rewrite the getDBinfo-Methods to have not arrays but objects too: $genres, $artists, $albums, within all page-types,  or, or, or, ... (- help, - I'm pinched for time ).

So, - I have to find a cut and provide a useful and good understandable siteprofile, but what has some allready known limitations, and (for shure) some unknown bugs :-[ . This will be the point when ID3-CharEncoding and CacheRebuild is done, besides some minor bugs I have allready figured out and on my list. All other stuff, I think I should start later.

-------------------------------------------

Here are a screencast showing what the FrontEndHandler provides, including some examples of the DemoSection:

https://youtu.be/LaIZ0mpfNew

  • Like 2
Link to comment
Share on other sites

Horst,

Thanks for the comprehensive post! I'll write a better reply later on...

data-src: data-* where * is an attribute is a HTML5 custom data attribute element. See also here and here. So, in this case, data-src is a url. Used this as it came with the audio.js example :)

I didn't know about streamurl so was directly accessing the file :). I look forward to experimenting with those frontendhandlers.

More later!

Link to comment
Share on other sites

I have successful hooked new properties to the existing pages (parents: genre|artist|album) and (children: artists|albums|songs), and some more.

With the demos I have made some progress, and I have made a graphical overview:

 post-1041-0-13518300-1368874054_thumb.pn

Edit: new Mindmap

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...