# Libretime Song Database - using existing song library?

**URL:** <https://discourse.libretime.org/t/libretime-song-database-using-existing-song-library/122>\
**Category:** Get Help\
**Created:** [March 15, 2018, 10:20pm UTC](https://discourse.libretime.org/t/libretime-song-database-using-existing-song-library/122 "2018-03-15T22:20:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![btonbadger](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/btonbadger/32/109_2.png) [@btonbadger](https://discourse.libretime.org/u/btonbadger)\
**Post date:** [March 15, 2018, 10:20pm UTC](https://discourse.libretime.org/t/libretime-song-database-using-existing-song-library/122/1 "2018-03-15T22:20:05Z")

</div>

Hi,

I have an existing song library of around 1 terabyte of songs.

I’ve had a poke around the database directly and found I could manually add songs to it and as long as the required data fields were present these would appear and work within libretime.

So my next step was to mount my network storage and set this as my libretime audio folder but when I repeat the above steps the database entry appears correctly but the audio won’t play within Libretime.

Has anyone tried this and made it work? Does the Network storage need to be mounted as a specific user for Libretime to be able to access the files perhaps? Do I need to map the existing file structure?

The songs are all direct cd ripped wav files at 44.1kHz stereo and play fine except from the network storage.

What I’d like to achieve is to write a script to import my existing metadata database into Libretime (the easy bit) but use the songs in their current location on the network storage (the bit I’m struggling with).

Any advice gratefully received,

BB

---

<div class="post-metadata">

**Author:** ![btonbadger](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/btonbadger/32/109_2.png) [@btonbadger](https://discourse.libretime.org/u/btonbadger)\
**Post date:** [March 16, 2018, 9:53am UTC](https://discourse.libretime.org/t/libretime-song-database-using-existing-song-library/122/2 "2018-03-16T09:53:02Z")

</div>

A little more experimentation today. Here’s what I have tried…

The nas is mounted as /media/nas/ and the songs live in the audio subdirectory. I can view the file list and play the songs from this directory.

In order to match the libretime directory structure I have added a new root directory to the local mount called “audio”. In there I have symlinked a folder called 1/ to my /media/nas/audio directory. Libretime is set up to use the audio directory as it’s default directory.

I’ve added the song to the database and in the database field “directory” I’ve added 1.

The NAS is mounted with www-data as it’s owner and this is verified when issuing ls -l command on

Prior to doing all of this the zendlog.php file was reporting that the song was not found. After doing this the zendlog.php file reports the following:

ERR (3): 10.0.0.56 [MediaController.php:89 - downloadAction()]

---

<div class="post-metadata">

**Author:** ![robbt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/robbt/32/15_2.png) [@robbt](https://discourse.libretime.org/u/robbt)\
**Post date:** [March 17, 2018, 5:31pm UTC](https://discourse.libretime.org/t/libretime-song-database-using-existing-song-library/122/3 "2018-03-17T17:31:17Z")

</div>

Not sure but you should check out the work done thus far on [https://github.com/LibreTime/libretime/pull/111](https://github.com/LibreTime/libretime/pull/111)  
There was also an airtime-import function provided with previous versions of Airtime but it wasn’t rewritten to work with airtime\_analyzer used by LibreTime.

What you are describing seems like it would be tricky to do.

---

<div class="post-metadata">

**Author:** ![btonbadger](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/btonbadger/32/109_2.png) [@btonbadger](https://discourse.libretime.org/u/btonbadger)\
**Post date:** [March 18, 2018, 10:38pm UTC](https://discourse.libretime.org/t/libretime-song-database-using-existing-song-library/122/4 "2018-03-18T22:38:59Z")

</div>

Thanks Robbt. I’ll share what I’ve learned today - even though my end goal is not to write an importer but to directly add the songs into the libretime database.

I’ve set my media folder to "/audio/ ". Songs that are imported using the web upload get put into a subfolder within that: “/audio/imported/1/filename.wav”.

Originally I was trying to symlink my directory of songs to that same location but it was breaking more things than I was fixing. I was also using just the filename (no folder info) in the database field which was incorrect. This resulted in Libretime being unable to find the files.

I’ve now symlinked my songs folder to “/audio/songs/” . I’ve added one file manually to the database (I’m using PSequel on a mac to connect to the database over IP) and it works!

The file list lives in the database table cc\_files. Fields that I’ve added in order for the entry to be recognised are:

id: (I have a 5 digit song ID number in my existing database so I’ve used that)  
mime: audio/x-wav  
ftype: audioclip  
filepath: songs/filename.wav  
directory: 1  
import\_status: 0 (this appears to be important to make Libretime think it’s already processed the file itself)  
track\_title: song title  
artist\_name: song artist  
sample\_rate: 44100  
cuein: 00:00:00  
cueout: 00:03:30.255 (point at which the next song should start)  
filesize: the file size in bytes.

I’ve added two songs by manually copying and pasting the fields and it works successfully. Tomorrow I’ll think about a way of automating my database transfer!
