Sonerezh / sonerezh

A self-hosted, web-based application to stream your music, everywhere.
https://www.sonerezh.bzh
GNU Affero General Public License v3.0
769 stars 122 forks source link

Run importError: SQLSTATE[01000]: Warning: 1265 Data truncated for column 'track_number' at row 1 #269

Open Amgine0 opened 7 years ago

Amgine0 commented 7 years ago

I do not know what might cause this error.


Welcome to CakePHP v2.8.1 Console
---------------------------------------------------------------
App : app
Path: /raid/www/sonerezh/app/
---------------------------------------------------------------
[INFO] Scan [path]/Music/...
[INFO] Found 22105 audio files (780 already in the database). Continue? (yes/no) 
[yes] > 
[INFO] Run importError: SQLSTATE[01000]: Warning: 1265 Data truncated for column 'track_number' at row 1
#0 /raid/www/sonerezh/lib/Cake/Model/Datasource/DboSource.php(461): PDOStatement->execute(Array)
#1 /raid/www/sonerezh/lib/Cake/Model/Datasource/DboSource.php(427): DboSource->_execute('INSERT INTO `So...', Array)
#2 /raid/www/sonerezh/lib/Cake/Model/Datasource/DboSource.php(1019): DboSource->execute('INSERT INTO `So...')
#3 /raid/www/sonerezh/lib/Cake/Model/Model.php(1933): DboSource->create(Object(Song), Array, Array)
#4 /raid/www/sonerezh/lib/Cake/Model/Model.php(1751): Model->_doSave(Array, Array)
#5 /raid/www/sonerezh/app/Console/Command/SonerezhShell.php(128): Model->save(Array)
#6 /raid/www/sonerezh/lib/Cake/Console/Shell.php(458): SonerezhShell->import()
#7 /raid/www/sonerezh/lib/Cake/Console/ShellDispatcher.php(212): Shell->runCommand('import', Array)
#8 /raid/www/sonerezh/lib/Cake/Console/ShellDispatcher.php(66): ShellDispatcher->dispatch()
#9 /raid/www/sonerezh/app/Console/cake.php(36): ShellDispatcher::run(Array)
#10 {main}
DarwinAwardWinner commented 7 years ago

I'm seeing this same error, and I have narrowed it down to a few files that are causing it.

DarwinAwardWinner commented 7 years ago

This seems to be caused when the track number and track total in a FLAC file are stored together in the "tracknumber" tag as e.g. "1/16", instead of storing them separately in the "tracknumber" and "tracktotal" tags. Removing and re-adding the track numbers with a tool that sets these tags correctly allows the track to be imported.

pjwerneck commented 7 years ago

Had the same problem with mp3 files. I tried removing and re-adding the tags and track numbers with several different tools, but nothing worked. After looking into the offending files closely with mp3diags, I found out they had an Ape tag with a Tracks=num/num value. I removed the Ape tag and it works, but maybe the app should either ignore Ape tags completely, or handle the "num/num" format.

nkoep commented 6 years ago

I'm facing the same problem. At the very least, the error message should indicate which file caused the problem, but mainly the importer should simply skip the file instead of aborting the entire import process.

oei commented 6 years ago

I have changed the column into a varchar(10) it looks it does the trick.

MightyCreak commented 6 years ago

You could try to use the @gs11's fork which is more advanced and may have fixed this issue already: https://github.com/gs11/sonerezh

davebiffuk commented 4 years ago

In Lib/SongManager/SongManager.php the code to handle the "track" tag needs the same ability to handle xx/yy format as the code to handle the "track_number" tag does. I hand-patched my copy to look like this (around line 69) and I don't get that error any more. I will make a pull request.

        // Song track number
        if (!empty($file_infos['comments']['track'])) {              // MP3 Tag
            //$metadata['track_number'] = (string)end($file_infos['comments']['track']);
            $track = explode('/', (string)end($file_infos['comments']['track']));
            $metadata['track_number'] = intval($track[0]);
        } elseif (!empty($file_infos['comments']['track_number'])) { // MP3 Tag
            // Some tags look like '1/10'
            $track_number = explode('/', (string)end($file_infos['comments']['track_number']));
            $metadata['track_number'] = intval($track_number[0]);
        } elseif(!empty($file_infos['comments']['tracknumber'])){   // OGG Tag
            $metadata['track_number'] = end($file_infos['comments']['tracknumber']);
        }